Skip to content

Massive git zombie process leak when a mobile Remote Control client attaches to a running session (per-file git diff --no-index children are never reaped) #53910

Open

Description

@zhangyaseen

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 available

What 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:

  1. 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.
  2. Killing the parent process is the only effective workaround - when it exited, all ~74k zombies were reaped by init instantly.
  3. 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).
  4. 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:

  1. 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.

  2. Desktop app attaches via SSH; a Codex task runs normally in this workspace (no anomaly).

  3. 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.

  4. Mobile client disconnects -> the leak does NOT stop.

  5. 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?

  1. Background diff enumeration must have a bounded queue / concurrency limit and a total output cap.
  2. Diff generation should skip or batch-handle large untracked sets (respect ignore rules, cap file size/count) instead of one git diff --no-index per file.
  3. Client disconnect / cancel must propagate to the task: stop spawning, drain or close pipes, terminate or wait children.
  4. Repeated workspace refreshes / reconnects must not re-submit a full enumeration pass without deduplication.
  5. 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:

Workarounds we use:

  1. Kill the leaking codex task process - zombies are reaped instantly by init; the session JSONL on disk survives and can be resumed.
  2. Add generated-artifact directories to .gitignore so the untracked-file enumeration never sees them.
  3. Never attach a second client (mobile remote) to a session whose task is running.
  4. 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

  1. added
    bug
    on Oct 14, 2026
  2. added
    CLI
    app-server
    on Oct 14, 2026
  3. github-actions commented on Oct 14, 2026

    @github-actions
    Contributor

    Potential duplicates detected. Please review them and close your issue if it is a duplicate.

    Powered by Codex Action

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    CLIapp-serverbugperformanceremote

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions