Windows app-server PowerShell AST parser can leak ~185GB commit memory and break RDP/RPC/SSH exec
Summary
On a Windows host running Codex Desktop / app-server, the long-lived internal PowerShell AST parser process used by the Windows command-safety layer grew to about 185 GB of committed memory. This triggered Windows resource exhaustion and temporarily broke RDP, RPC, SSH exec, and local services. The machine later recovered without reboot after the offending process exited or was terminated.
This appears related to the Windows command-safety PowerShell parser discussed in #20510 and the broader desktop resource issues discussed in #27848, but this report includes concrete Windows Resource-Exhaustion-Detector evidence and a severe system-wide failure mode.
Environment
- Product: Codex Desktop / app-server on Windows
- Package version observed:
OpenAI.Codex_26.616.6631.0_x64__2p2nqsd0c76g0 - OS: Windows host, accessed over RDP and OpenSSH
- Codex process chain observed before mitigation:
Codex.execodex.exe app-server --analytics-default-enabledpowershell.exe- child helper
node.exe ./mcp/server.bundle.mjs
The PowerShell child command line decoded to an internal helper whose comments identify it as:
Long-lived PowerShell AST parser used by the Rust command-safety layer on Windows.
What happened
The Windows host became partially unusable:
- RDP stopped working; the user saw a black screen / failed desktop session.
- RPC became unavailable.
- SMB and service-control queries failed.
- OpenSSH still accepted authentication, but could not create exec sessions:
exec request failed on channel 0
- PowerShell startup failed intermittently with resource-related errors, including
0x800705AF. - Windows services such as Windows Error Reporting, AppXSVC, and ClipSVC failed because the system could not allocate enough resources / create threads.
The host later recovered without reboot after memory pressure cleared. Killing the Codex Desktop / app-server process tree stabilized the machine.
Windows event log evidence
Microsoft-Windows-Resource-Exhaustion-Detector, Event ID 2004, recorded the following process memory usage:
powershell.exe (26244) used 185,759,944,704 bytes
python.exe used about 1.8 GB
ToDesk.exe used about 677 MB
Earlier resource-exhaustion events in the same incident showed the same PowerShell process growing:
powershell.exe (26244) used 90,265,735,168 bytes
powershell.exe (26244) used 185,430,315,008 bytes
powershell.exe (26244) used 185,481,949,184 bytes
powershell.exe (26244) used 185,759,944,704 bytes
Related service failures after memory exhaustion included:
Windows Error Reporting Service stopped: page file too small to complete the operation
AppX Deployment Service failed: unable to create new service thread
Client License Service failed / timed out
Current workaround
I killed the Codex process tree on the affected host:
Codex.execodex.exe app-server- MCP
node.exechildren - the long-lived PowerShell AST parser child
After that, memory returned to normal and no Codex residual processes remained.
Expected behavior
The command-safety PowerShell parser should have bounded memory usage and should not be able to exhaust system commit memory. If the parser process grows unexpectedly, Codex should restart or kill it before it can destabilize the host.
Possible fixes
- Add a memory limit / watchdog for the long-lived PowerShell AST parser.
- Restart the parser after a bounded number of parse requests.
- Avoid keeping a single unbounded long-lived PowerShell parser process on Windows.
- Expose a configuration switch to disable the long-lived parser or fall back to per-command parsing.
- Surface parser health in app-server logs so this failure mode is easier to diagnose.
Impact
This is high impact on Windows servers or remote workstations. A single Codex app-server helper process can make the host appear offline by breaking RDP/RPC/SSH exec even though the kernel and network stack are still partially alive.
4 Comments
Potential duplicates detected. Please review them and close your issue if it is a duplicate.
Powered by Codex Action
The parser helper needs resource boundaries like any other long-lived service. I would track pid, parent session, command hash, parses served, heap/commit high-water mark, last request age, and kill reason. Then add a hard ceiling that recycles the helper before Windows resource exhaustion breaks unrelated services. The bug report has enough evidence to make this a watchdog test, not only a leak investigation.
---
_Generated with ax._
Additional reproduction: long-running test succeeds, then Codex Desktop exec host fails with 0xC0000142
I hit what looks like the same Windows Desktop exec/helper failure mode, with one extra detail: the long-running child command can complete successfully first, and only then the Codex Desktop execution host enters a broken state.
Environment
OpenAI.Codex_26.616.10790.0_x64__2p2nqsd0c76g0Microsoft.WindowsTerminal 1.24.11321.0powershell.exepwsh.execmd.exeReproduction
``
cmd
``.\.venv\Scripts\python.exe -m pytest tests -q
``
text
``1633 passed, 158 subtests passed in ~66s
exit code 0
``
cmd
``echo still-ok
``
text
``Process exited with code -1073741502
echo,cmd.exe /c echo ok,Get-Date, orgit diff --checkfail from Codex with the same exit code.Additional observations
``
text
``The Win32 internal error "No process is on the other end of the pipe" 0xE9 occurred while setting the console window title.
pwshstill reproduced the failure.cmd.exe, so it is not only a user-selected PowerShell shell problem..codexsandbox/cache is not required to recover and can make the situation worse.codex execworkflows, which may increase the chance of triggering the issue, but the repro above happened inside Codex Desktop and leaves the Desktop exec host broken.Expected behavior
After a child command completes successfully, Codex Desktop should remain able to launch subsequent commands.
Actual behavior
The child command succeeds, but the Codex Desktop execution host enters a broken state where every subsequent command fails with
0xC0000142/-1073741502.Workarounds tested
Additional independent evidence from a newer Windows Desktop build
I observed what may be the same or an adjacent Windows PowerShell lifetime/resource-exhaustion failure. I cannot confirm that the leaking process was the long-lived AST parser described in this issue, because I deliberately did not retain or publish raw command lines. The evidence does show completed Codex shell activity followed by a PowerShell process remaining alive for about two hours and exhausting system commit.
Environment
26.721.4979.00.146.0-alpha.3.126100Windows Event ID 2004 evidence
2026-07-29 18:13 KST
powershell.exePID 19268: 19,956,244,480 bytesvmmemWSL: 4,774,883,328 bytesEarlier event on 2026-07-29 00:42 KST
powershell.exePID 9120: 6,182,174,720 bytespowershell.exePID 38900: 5,206,028,288 bytesvmmemWSL: 5,803,929,600 bytesA privacy-preserving correlation pass retained only timestamps, tool names, byte lengths, and SHA-256 metadata. It did not retain commands, outputs, call IDs, environment values, tokens, or credentials.
Causality boundary
Expected behavior
After a shell tool returns or times out, Codex should close or explicitly account for its child process tree and pipe handles. Long-lived internal helpers should have bounded memory and be recycled before system commit exhaustion.
Local mitigation and validation
I installed a fail-closed local boundary using a Windows Job Object with
KILL_ON_JOB_CLOSE, bounded runtime/memory/output, concurrent stdout/stderr draining, and a one-minute watchdog. The watchdog terminates only a confirmed Codex-lineage PowerShell orphan after all conditions hold: at least 4 GB, at least 10 minutes, three consecutive low-CPU samples, no active child, and not interactive/scheduled/service/excluded.A synthetic suite passed 15/15, including exact orphan-tree termination and preservation of CPU-active, interactive, unrelated, child-bearing, and service processes. This is only a local mitigation, not a product fix.
I can provide redacted Event ID 2004 exports and metadata-only process/timing evidence through an approved secure channel. I will not publish raw Codex transcripts, command lines, environment values, credentials, or unrelated crash dumps.