Repository navigation
Description
What version of Codex CLI is running?
codex-cli 0.162.1 (x86_64-unknown-linux-musl) Also reproduced on 0.159.2 (npm install) earlier the same day.
What subscription do you have?
chatgpt pro
Which model were you using?
6.1-sol
What platform is your computer?
x86_64 GNU/Linux
What terminal emulator and version are you using (if applicable)?
Not applicable — the leak occurs in the headless codex app-server (remote-control daemon / SSH-launched) on a Linux server, not in an interactive terminal. No multiplexer involved.
Codex doctor report
not availableWhat issue are you seeing?
On a shared Linux dev server (Ubuntu, ~500 GiB RAM), attaching a mobile Remote Control client to a running Codex session triggers an unbounded background diff enumeration over the repo's untracked files: Codex spawns one git diff --no-index /dev/null <file> per untracked file (with --binary), and the children are never reaped.
Observed on codex-cli 0.162.1:
- ~10-16 git processes spawned per second, sustained for hours
- Up to ~15,000 git children simultaneously ALIVE, stuck in
pipe_write(diff output saturates the stdout pipe and the consumer stops reading) - Tens of thousands of DEAD children accumulate as zombies (Z state) under a single codex parent: 73,994 zombies in the first storm, 67,099 in a second storm the same afternoon; an earlier incident reached ~84,700 simultaneous git processes (298,955 total created) under one parent PID
- Zombies hold no user-space RSS but permanently occupy PID slots and non-swappable kernel memory. At the observed rate the server (pid_max=4194304, shared by the whole team) was ~2.5 days from fork() exhaustion for ALL users
Live sample captured in the storm (stuck in pipe_write):
git -c safe.bareRepository=explicit \
-c core.hooksPath=/dev/null \
-c core.fsmonitor=false \
diff --no-textconv --no-ext-diff --binary --no-index \
-- /dev/null <untracked file>
A minimal control experiment with the same argv confirms the mechanism: with the read end held open and unread, git blocks in pipe_write; closing the read end makes it exit via SIGPIPE; continuously reading completes in ~10 ms.
Key behaviors:
- Disconnecting the mobile client does NOT stop the leak - new git creation continues until the parent task process exits. Even issuing
codex app-server daemon disable-remote-control(confirmed remoteControlEnabled=false + shutdown_requested) did not stop the running task chain for several minutes. - Killing the parent process is the only effective workaround - when it exited, all ~74k zombies were reaped by init instantly.
- Disabling Remote Control does not remediate an affected session - after disabling it, the same session/workspace accessed again via a desktop SSH app-server produced the second storm (~67k zombies).
- Total zombies far exceeded the untracked-file count (73,994 vs ~20,000), indicating the per-file diff enumeration was re-submitted multiple times (workspace refreshes / client reconnects appear to re-trigger full passes) rather than being deduplicated.
What steps can reproduce the bug?
Observed sequence on the server:
-
Repo with a large number of UNTRACKED files (20,000+ at incident time; ~10,000 after cleanup) - generated artifacts, datasets, large binary data files, third-party source copies.
-
Desktop app attaches via SSH; a Codex task runs normally in this workspace (no anomaly).
-
A mobile client attaches to the SAME running session via Remote Control -> within minutes the server starts spawning git at ~10-16/sec; memory and zombie count climb.
-
Mobile client disconnects -> the leak does NOT stop.
-
Observe:
ps -e -o stat= | grep -c Z # grows ~10-16/sec, reaches tens of thousands
ps -e -o stat=,comm= | grep ^Z # all zombies are git
ps -e -o ppid=,stat= | grep Z # all share one parent: the codex task/app-server process
Parent-child chain:
codex app-server (launched either as
`codex app-server --remote-control --listen unix:// --managed-daemon`
or by a desktop app SSH connection)
+- codex task process (code-mode host)
+- tens of thousands of git children, dying and never reaped
What is the expected behavior?
- Background diff enumeration must have a bounded queue / concurrency limit and a total output cap.
- Diff generation should skip or batch-handle large untracked sets (respect ignore rules, cap file size/count) instead of one
git diff --no-indexper file. - Client disconnect / cancel must propagate to the task: stop spawning, drain or close pipes, terminate or wait children.
- Repeated workspace refreshes / reconnects must not re-submit a full enumeration pass without deduplication.
- Every spawned child must be reaped regardless of the pipe/cancel path (kill-on-drop must not drop the waiter task).
Additional information
Related issues:
- ProcessHandle::terminate aborts its only child waiter #32219 (closed as completed 2026-08-07) - PTY/pipe child-process reaping. The fix appears to cover the PTY ProcessHandle path, but this leak reproduces on 0.162.1 via a different path: the per-file
git diff --no-indexbackground diff generation. - Codex.app GUI: MCP child processes not reaped after task completion — 1300+ zombies, 37GB memory leak #12491 - MCP child processes not reaped (1,300+ zombies) - same symptom family.
- Codex for macOS accumulates Computer Use / MCP helper processes and unreaped zombie children, causing HID lag and WindowServer/TCC stalls #25744 - desktop app accumulating 126+ zombies; killing children only increases the count, only parent restart clears.
Workarounds we use:
- Kill the leaking codex task process - zombies are reaped instantly by init; the session JSONL on disk survives and can be resumed.
- Add generated-artifact directories to .gitignore so the untracked-file enumeration never sees them.
- Never attach a second client (mobile remote) to a session whose task is running.
- Monitor: watch -n 30 'ps -e -o stat= | grep -c Z' - if it passes ~50k, kill the task process.
Happy to provide additional evidence: process-tree snapshots with full argv, /proc//stack showing pipe_write, timeline logs, and a quantified incident report.
Activity
github-actions commentedon Oct 14, 2026
Potential duplicates detected. Please review them and close your issue if it is a duplicate.
Powered by Codex Action