Skip to content

Windows app leaves PowerShell child processes running after an unbounded recursive scan #34264

Open

Description

@RaWa-KI

What version of the Codex App are you using (From “About Codex” dialog)?

Codex desktop app package version: 26.715.4045.0

What subscription do you have?

Pro

What platform is your computer?

Windows 11

What issue are you seeing?

Summary

On Windows, the Codex desktop app started an unbounded recursive PowerShell search across my complete user profile.

The command continued running after the conversation had moved on and spawned a Windows PowerShell 5.1 compatibility child process. Both processes remained active until I terminated them manually.

This resulted in locked temporary files and may cause sustained CPU, disk, and memory usage.

Environment

  • Codex desktop app package version: 26.715.4045.0
  • Operating system: Windows 11
  • Shell: PowerShell 7.6.2
  • Compatibility host: Windows PowerShell 5.1
  • Authentication: ChatGPT login
  • Workspace: projectless Codex workspace
  • Session ID: 019f7da6-e113-7971-9ea9-dc0645c15d78

Observed command

Codex started a command with this general shape:

Get-ChildItem -Path 'C:\Users\<user>' -Filter '<external-handoff-file>.md' -Recurse -File -ErrorAction SilentlyContinue

This searched the complete Windows user profile, including AppData and other large directory trees.

The live process tree was:

ChatGPT.exe
└─ codex.exe
   └─ pwsh.exe
      └─ powershell.exe

The PowerShell 5.1 child was started with:

-Version 5.1 -s -NoLogo -NoProfile

The use of -NoProfile confirms that the user's PowerShell profile was not responsible.

What steps can reproduce the bug?

These are the observed steps. I have not yet reduced the issue to a completely deterministic minimal reproduction.

  1. Start the Codex Windows desktop app.

  2. Open a projectless workspace outside the normal repository root.

  3. A bounded custom SessionStart hook reports an external handoff file using a relative path.

  4. Codex cannot directly resolve that path from the current workspace.

  5. Codex starts a recursive PowerShell search across C:\Users\<user>.

  6. Continue the conversation or move on from the command.

  7. Inspect the running processes with:

    Get-CimInstance Win32_Process -Filter "Name='pwsh.exe' OR Name='powershell.exe'" | Select-Object ProcessId,ParentProcessId,Name,CommandLine

  8. Observe a pwsh.exe process owned by codex.exe and a Windows PowerShell 5.1 child process.

  9. The processes remain active until manually terminated.

  10. Some temporary files remain locked while these processes are running.

The affected live process was created on 2026-07-20 at approximately 06:53 local time.

What is the expected behavior?

Codex should:

  1. Avoid recursively searching an entire Windows user profile for one known file.
  2. Prefer bounded search roots and tools such as rg --files.
  3. Apply a timeout to potentially expensive recursive searches.
  4. Cancel the complete process tree when a command times out, is interrupted, or the task moves on.
  5. Clean up PowerShell compatibility sessions and temporary proxy modules.
  6. Warn before recursively scanning %USERPROFILE%.
  7. Avoid repeating the same expensive search after reopening Codex.

Additional information

Restart clarification

At first, this looked like a process that had survived a Windows restart.

Further investigation showed that the previous process had been terminated by the restart, but Codex created a new instance of the search after the app was opened again.

The searched handoff filename was several days old, while the live process creation timestamp was from the current day. Historical temporary directories remained on disk across restarts, making the process appear older than it actually was.

Temporary directory impact

Many directories with names similar to the following accumulated under %TEMP%:

remoteIpMoProxy_DnsClient_1.0.0.0_localhost_<guid>

Some could not be removed because files inside them were held open by active PowerShell processes.

A typical error was:

The process cannot access the file because it is being used by another process.

Administrator privileges and -Force did not help because these were active file locks rather than permission errors.

Local configuration assessment

There is also a local configuration issue: the SessionStart hook supplied an external handoff using a relative path in a projectless workspace.

The hook itself is bounded, read-only, starts no child processes, and does not perform the recursive search. I will correct the local path handling separately.

However, the Codex runtime should still bound and terminate a shell command and its child processes when an agent proposes an overly broad search.

A total of 253,488 matching temporary directories were counted. A second measurement after 10 seconds returned the same count, confirming that directory generation had stopped and that this was a stable accumulated backlog.

Related reports

I searched the existing issues and did not find an exact duplicate.

Potentially related reports:

Those reports concern child-process cleanup or high resource usage on Windows. This report adds a concrete pwsh.exe to powershell.exe process chain, an unbounded recursive filesystem scan, locked PowerShell proxy directories, and evidence that the process was recreated after restarting and reopening Codex.

I can provide sanitized screenshots, process timestamps, sanitized command lines, relevant session logs, and the bounded SessionStart hook if requested.

Activity

  1. added
    app
    on Jul 20, 2026
  2. added
    bug
    windows-os
    tool-calls
    on Jul 20, 2026
  3. willamboss commented on Sep 9, 2026

    @willamboss

    Reproduced on Codex App 26.901.6511.0 with bundled CLI 0.153.4 on Windows 11 x64.

    Four concurrent rg.exe commands recursively searched large historical JSONL files under .codex/sessions. After the tool calls timed out/yielded, the processes were not terminated, and additional searches were started.

    After approximately 40 minutes:

    • The four orphaned rg.exe processes consumed about 60% CPU combined.
    • Each process accumulated roughly 9,700–12,900 seconds of CPU time.
    • Two Codex runtime pwsh.exe parent processes also remained active, consuming about 862 MB of memory combined.
    • The entire computer became nearly unusable. The resource usage was severe enough that the user initially believed the machine had been infected with cryptomining malware.

    Manually terminating the four rg.exe and two pwsh.exe processes immediately restored system responsiveness.

    This occurrence shows that multiple expensive searches can accumulate after timed-out or abandoned tool cells. Codex should terminate the complete process tree, enforce per-session resource/concurrency limits, warn before scanning the full session archive, and provide a visible "stop all background commands" control.

  4. GuanYuankai620 commented on Nov 10, 2026

    @GuanYuankai620

    Another Windows Codex desktop observation with a lingering rg.exe process.

    • App package version: 26.1103.7773.0, Windows x64.
    • A Codex task generated a PowerShell command that passed the result of rg --files ... | rg 'Service.java$' as the path argument to a second rg. The file list was empty. The observed second process had only rg.exe -n -i 'status|flow|approve' and searched the working directory.
    • The originating Codex chat was idle, while the process chain remained ChatGPT.exe → codex.exe app-server → codex.exe --__codex-windows-mxc → pwsh.exe → rg.exe. The rg process had been running for roughly 40 minutes and showed around 56% CPU and roughly 0.9 GB working set at inspection.
    • After manually terminating that specific rg process, three system CPU samples were approximately 33%, 39%, and 37%, down from approximately 96–97% in earlier Task Manager screenshots. Other tasks were running, so the samples are not a controlled benchmark.
    • The command record was observed as failed after termination. The exact runtime cleanup failure and a deterministic minimal reproduction have not been established.

    Please investigate tracking and terminating the complete process tree when a task or command is no longer active, including Windows sandbox execution.

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

    appbugperformancetool-callswindows-os

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions