Skip to content

Windows Desktop: root-only abort races taskkill /T, leaving Git descendants alive #45172

Open

Description

@WitconAB

Summary

Codex Desktop's Windows local-execution cancellation path appears to register two handlers on the same AbortSignal: the low-level handler kills only the root process, while the higher-level handler subsequently tries to terminate the tree using taskkill /pid <root-pid> /t /f.

If the first handler removes the root before taskkill enumerates it, taskkill exits with code 128 ("process not found"), while Git descendants remain alive. An isolated A/B test reproduced this failure using unmodified Git for Windows.

Please fix cancellation ownership and add a regression test that verifies descendant termination, not just a cancelled command result.

Environment and verification scope

  • Windows 11 x64.
  • Codex Desktop/MSIX 26.903.9818.0: packaged code inspected; cancellation order reproduced independently.
  • Codex Desktop/MSIX 26.908.4834.0: packaged worker code inspected; the same two-handler arrangement remains present. The full reproduction was not rerun against this newer build.
  • Git for Windows 2.54.0.windows.1.

This concerns the desktop local execution host, including internal Git status/review work; it is not a model-output or global AGENTS.md concurrency issue.

Implementation observations

In the desktop worker's local execution host:

  1. The spawn layer forwards signal: options.signal to a lower-level subprocess wrapper.
  2. That wrapper registers an abort listener which calls child.kill().
  3. The local execution host also registers an abort listener which invokes its execution object's kill method.
  4. When killProcessTree is enabled, the latter invokes taskkill against the original root PID.

The earlier build also allowed cancellation to be reported before tree cleanup completed and suppressed cleanup failures. The newer build appears to await a pending cleanup promise in its wait path, but still retains the root-kill/tree-kill ordering hazard. Please inspect both cancellation ownership and cleanup error handling.

These are observations from locally inspected packaged code, not a claim about an identified public-source commit.

Isolated reproduction

Use a disposable repository and a Node.js harness on Windows. Do not run this as a stress test.

  1. Spawn the standard Git for Windows command wrapper with argument array:
    ['-c', 'alias.repro=!sleep 10', 'repro'].
    The alias is supplied only for this invocation; no persistent Git configuration is needed.
  2. Use piped stdin/stdout/stderr and windowsHide: true. Allow descendants to start and record only this test process's descendants.
  3. A — existing ordering: call child.kill(), then directly invoke taskkill.exe with ['/pid', String(child.pid), '/t', '/f'] using execFile (no shell).
  4. B — control: repeat with a fresh test process, invoking tree termination without the preceding root-only kill.
  5. Inspect the recorded descendants promptly, before the ten-second sleep ends. Clean up only the test's recorded processes.

Observed:

Case taskkill result Root Descendants after cancellation
A: root kill followed by tree kill 128, process not found exited git.exe, sh.exe, sleep.exe and conhost.exe remained alive
B: tree kill only success exited none remained

In case A, the Node child close event had also not fired at the observation point. All test descendants were explicitly cleaned up afterward.

This establishes the failure mechanism independently; it does not establish its frequency in ordinary desktop sessions.

Impact and limits of attribution

The investigation began after repeated system-wide stalls during Codex use and internal Git operations timing out. Local crash-dump counters independently confirmed system commit exhaustion. However, historical per-process totals are unavailable, so the cancellation bug has not been proven to account for all memory consumption or the full Windows freezes.

A later experimental local process-tree wrapper did not resolve the incidents and was removed. Its subsequent out-of-memory failures should not be attributed to unmodified Git or used as independent proof of the desktop bug. The isolated reproduction above used standard Git.

Requested fix and regression coverage

  • Give cancellation one owner when process-tree termination is requested; prevent the lower layer from independently killing the root first.
  • Await bounded cleanup and surface failures.
  • Verify that descendants are gone after abort and timeout, including descendants retaining inherited output handles.
  • Test both live-root cancellation and unexpected root exit.
  • Bound cleanup-helper concurrency and execution time so failed cleanup cannot create another process storm.

Related reports: #34260 and #33776 describe Windows cleanup-helper accumulation. This report adds a distinct, reproduced root-first termination race; it does not assume those reports share exactly the same cause.

Privacy

Text-only technical report. No raw logs, crash dumps, screenshots, conversation/session IDs, repository content, private project names, user-specific paths, hostnames, network addresses, credentials, or environment-variable values are included.

Activity

  1. added
    bug
    app
    windows-os
    tool-calls
    on Sep 13, 2026
  2. WitconAB commented on Sep 13, 2026

    @WitconAB
    Author

    Follow-up: sampled Git process accumulation confirms a major memory consumer

    A locally retained, read-only process/memory capture has now been analyzed. Unlike the earlier shutdown-warning counts, these are process records with 20,999 distinct Git PIDs in a single enumeration.

    Measurement Before growth Peak
    Git processes 0 20,999
    Combined Git private bytes 0 MiB approximately 83,493 MiB (81.5 GiB)
    Total processes 278 21,281
    System commit 14,041 MiB 120,444 / 121,059 MiB
    Available physical memory 19,047 MiB 30 MiB

    The growth went from no Git processes to over 5,000 within roughly two minutes of the last zero sample, and then to the peak within approximately ten minutes. Git processes accounted for most of the sampled process-private memory. After they disappeared, system commit returned to approximately 15 GiB.

    Measurement method: .NET Process enumeration approximately every 30 seconds, recording PID, process name, PrivateMemorySize64, working set and handle count, together with GlobalMemoryStatusEx. This is not an atomic OS snapshot; the peak enumeration nevertheless contained 20,999 distinct Git PIDs. The recorder neither invoked Git nor terminated processes.

    The capture was on the 26.908.4834.0 session after the experimental launcher had been disabled and ordinary Git selection verified. Desktop worker logs during the same interval showed repeatedly cancelled internal status/diff operations. The capture did not record executable paths, command lines or parent PIDs, so it does not prove the origin of every Git process, whether each was running or blocked, or that the previously reproduced abort race is the sole trigger.

    Separately, a subsequent reboot recorded Windows bugcheck 0x1A (MEMORY_MANAGEMENT), parameter 1 = 0x783. No process capture covers that latest crash, and its kernel dump has not yet been analyzed. Please do not treat the bugcheck as proof of the same cause.

    This materially strengthens the evidence for Git-process accumulation exhausting system resources, while leaving the exact spawning path and latest kernel crash under investigation. Please prioritize a bounded Windows Git subprocess lifecycle and concurrency safeguards.

    Privacy: only aggregate measurements and technical descriptions are shared here. No raw process lists, logs, dumps, local paths, project information or session identifiers are attached.

  3. WitconAB commented on Sep 13, 2026

    @WitconAB
    Author

    New evidence narrows the process-explosion trigger beyond the cancellation race in the original report.

    On the same Windows desktop package (26.908.4834.0), a passive capture observed 38 Git processes at once. Recorded root Git processes were direct children of codex.exe (app-server), with the normal cmd/git.exe -> mingw64/bin/git.exe wrapper chain. The captured commands all had this form against different untracked files:

    git -c safe.bareRepository=explicit -c core.hooksPath=NUL -c core.fsmonitor=false diff --no-textconv --no-ext-diff --binary --no-index -- NUL <untracked-file>

    A subsequent read-only inventory of that repository found 19,472 untracked files, including 19,413 diagnostic scratch files in one temporary directory. This command family matches diff_against_sha in public source, which maps every untracked file to a Git future and awaits join_all without a concurrency bound at that level:

    if let Some(untracked_output) = run_git_command_with_timeout_from(
    git,
    &["ls-files", "--others", "--exclude-standard"],
    cwd,
    fsmonitor,
    )
    .await
    && untracked_output.status.success()
    {
    let untracked: Vec<String> = String::from_utf8(untracked_output.stdout)
    .ok()?
    .lines()
    .map(str::to_string)
    .filter(|s| !s.is_empty())
    .collect();
    if !untracked.is_empty() {
    // Use platform-appropriate null device and guard paths with `--`.
    let null_device: &str = if cfg!(windows) { "NUL" } else { "/dev/null" };
    let futures_iter = untracked.into_iter().map(|file| async move {
    let file_owned = file;
    let args_vec: Vec<&str> = vec![
    "diff",
    "--no-textconv",
    "--no-ext-diff",
    "--binary",
    "--no-index",
    // -- ensures that filenames that start with - are not treated as options.
    "--",
    null_device,
    &file_owned,
    ];
    run_git_command_with_timeout_from(git, &args_vec, cwd, fsmonitor).await
    });
    let results = join_all(futures_iter).await;

    I have not established that this public revision exactly matches the installed binary. The captured burst is also not a complete process timeline through the subsequent freeze.

    Another forced reboot occurred. Immediately preceding it, dwm.exe crashed with STATUS_FATAL_MEMORY_EXHAUSTION (0xC00001AD). Two new Git crash dumps recorded total system commit of 130,448 / 130,658 MiB and 130,401 / 130,658 MiB; paged kernel pool was about 15,090 MiB. Thus this recurrence had confirmed system-wide memory exhaustion, though those dumps do not identify aggregate per-process ownership at that instant.

    Local mitigation: added only the diagnostic scratch directory to this repository's .git/info/exclude, reducing untracked candidates from 19,472 to 59. No files were deleted, no tracked files were present there, and normal Git remains enabled. Long-term stability is not yet verified. Full-system process/memory sampling is running locally.

    Please investigate unbounded untracked-file diff fan-out as well as descendant cleanup. This matches the recent no-index follow-up in #17229. No repository names, personal paths, file contents, credentials or raw dumps are attached.

  4. Arnolddam commented on Nov 17, 2026

    @Arnolddam

    I observed the same symptom during automatic turn-diff captures in Codex Desktop on Windows. In normal use after relaunching the app, five bundled Git descendants remained alive after their captures were logged as canceled, with their launcher processes gone. The oldest was still running more than 18 minutes after cancellation.

    A separate cleanup attempt reported “process not found” for a launcher that had previously been observed as the parent of a surviving Git process. That is consistent with the race described here. The exact order of the two abort handlers was not traced in these instances.

    Please include automatic turn-diff capture in the regression coverage and verify that its Git descendants exit even if the launcher has already exited.

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

    appbugtool-callswindows-os

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions