Repository navigation
Description
What version of the Codex App are you using?
Microsoft Store / MSIX build 26.911.7940.0 (Codex CLI 0.141.0+)
What platform is your computer?
Windows 11 / Windows 10 x64
What issue are you seeing?
The desktop app fails immediately upon launch with the following error dialog:
ChatGPT failed to start.
(code=3221225495, signal=null).
Most recent error: Codex app-server websocket closed (code=3221225495)
Clicking "Check for Updates" results in net::ERR_BLOCKED_BY_CLIENT.
Root Cause Analysis (Reverse-Engineered from app.asar)
1. What 3221225495 Actually Means
Converting decimal 3221225495 to hex gives 0xC0000017.
In Windows NTSTATUS, this is STATUS_NO_MEMORY (ERROR_NOT_ENOUGH_QUOTA).
This is not an actual RAM exhaustion issue (the machine had 40 GB physical RAM with 20 GB free).
2. The Mechanism in Desktop Code
In oW / StdioConnection.spawnProcess() inside app.asar:
let r = {
...process.env,
LOG_FORMAT: 'json',
RUST_LOG: process.env.RUST_LOG ?? 'warn',
CODEX_INTERNAL_ORIGINATOR_OVERRIDE: e.defaultOriginator ?? zU
};
// ...
let n = spawn(executablePath, args, {
stdio: ['pipe', 'pipe', 'pipe'],
env: sanitizedEnv,
cwd: options.cwd
});- When
CreateProcessW/ZwCreateUserProcessis called on Windows inside the MSIX / AppContainer boundary, the kernel allocates memory forRTL_USER_PROCESS_PARAMETERS->Environment. - On Windows NT, the serialized environment block buffer has an allocation quota limit of 32,767 characters (32 KB).
- When
spawn()passesprocess.envdown tocodex.exe, if the serialized environment block exceeds 32 KB, the Windows kernel refuses to allocate the environment block, immediately failing process creation with NTSTATUS0xC0000017(3221225495).
3. Misleading UI Error
Because StdioConnection wraps process termination in a generic transport close handler, it prints:
Codex app-server websocket closed (code=3221225495)
even though the transport kind is stdio rather than websocket, leading users to mistakenly assume a network or proxy problem.
Real-World Case Study: How an Autonomous Agent Session Triggered This Bug
This issue occurred directly as a result of an autonomous development session driven by the agent:
- Autonomous Execution Loop:
The agent was autonomously running extensive test and verification loops during project development. - Ephemeral Directory Build Side Effects:
Each test run created an isolated temporary directory viamkdtemp(e.g.AppData\Local\Temp\test-runner-<id>\dotnet-home) and invoked.NET SDK(dotnet build). - Registry Pollution:
On Windows, the .NET SDK checks if%DOTNET_CLI_HOME%\.dotnet\toolsexists in the persistent user environment and registers it intoHKCU:\Environment\Path. - Self-Sabotaging Environment Bloat:
Across 290+ autonomous test iterations, 291 unique temporary paths were permanently appended to the Windows registry, inflating the UserPATHto 31,686 characters. - The Crash:
Once the desktop app was closed and restarted, the environment block exceeded the 32 KB kernel limit, permanently bricking the desktop app until manual registry remediation was performed.
This reveals a critical need for environment isolation and guardrails during autonomous tool execution.
Workaround for Affected Users
Cleaning bloated User PATH immediately resolves the startup crash without losing any chat history or sessions:
# 1. Check if User PATH is bloated (>10,000 chars)
((Get-ItemProperty "HKCU:\Environment").Path).Length
# 2. Backup registry
reg export "HKCU\Environment" "$HOME\Environment_backup.reg" /y
# 3. Deduplicate and filter out stale/missing directories
$currentPath = (Get-ItemProperty "HKCU:\Environment").Path
$cleanEntries = ($currentPath -split ';' | Where-Object {
$_ -and (Test-Path $_ -ErrorAction SilentlyContinue)
}) | Select-Object -Unique
Set-ItemProperty -Path "HKCU:\Environment" -Name "Path" -Value ($cleanEntries -join ';')
# 4. Broadcast change (no reboot required)
Add-Type -Namespace Win32 -Name NativeMethods -MemberDefinition @"
[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Auto)]
public static extern IntPtr SendMessageTimeout(IntPtr hWnd, uint Msg, UIntPtr wParam, string lParam, uint fuFlags, uint uTimeout, out UIntPtr lpdwResult);
"@
[Win32.NativeMethods]::SendMessageTimeout([IntPtr]0xffff, 0x001A, [UIntPtr]::Zero, "Environment", 0x0002, 5000, [ref][UIntPtr]::Zero)Once the User PATH was pruned from 31,686 chars to ~1,500 chars, ChatGPT.exe and codex.exe started cleanly without any issues.
Proposed Fix & Security Recommendations for Maintainers
- Sanitize
PATHbefore spawningcodex.exe:
InoW(where the sidecar environment dictionary is constructed), sanitize and deduplicater.PATHon Windows, or prune non-existent folders so the environment block never exceeds 32 KB. - Environment Isolation for Agent Tool Execution:
Autonomous agents running shell commands should have their environment modifications sandboxed to process-scope. Modifications toHKCU:\Environmentor calls tosetxby child processes during autonomous tasks should be blocked or isolated in a virtualized hive. - Accurate Error Reporting:
- In
StdioConnection, don't report"websocket closed"when the transport is stdio. - If
process.platform === 'win32'andcode === 3221225495(0xC0000017), display a clear diagnostic message:
"Failed to spawn backend engine due to environment block size limit (0xC0000017). Please ensure your PATH variable does not exceed 32,767 characters."
- In
Activity
[-][Bug]: Windows Desktop app fails to start with code 3221225495 (0xC0000017 STATUS_NO_MEMORY) due to environment block buffer overflow[/-][+][Bug]: Windows Desktop app fails to start: Codex app-server websocket closed (code=3221225495 / 0xC0000017) due to environment block overflow[/+]antilogicrule commentedon Oct 30, 2026
I independently reproduced this exact issue, and it is an unacceptable system-level reliability failure.
My Windows 11 machine (build 26200.9711) became partially unusable after an autonomous Codex development session running repeated .NET builds and tests.
My persistent user PATH had grown to 32,744 characters, containing 316 stale, project-specific
.dotnet\toolsentries created through differentDOTNET_CLI_HOMElocations.After restarting Windows, Task Manager, PowerShell, ChatGPT Desktop, the Start menu, search, and several other system components failed, often with
0xC0000017, despite ample available physical and virtual memory.We conducted controlled experiments:
0xC0000017.An autonomous coding workflow should never be able to progressively break its host operating system through persistent environment pollution.
This is not merely a Codex app crash. It can disrupt Windows itself and force users through hours of recovery and diagnosis.
Please treat this as a high-priority reliability issue. Codex should isolate build environments, prevent unintended persistent PATH modification, detect abnormal environment growth, and provide an actionable error instead of misleading memory failures.
tonym001 commentedon Nov 5, 2026
Additional Windows data point with the same
0xC0000017, but affecting child launches after the desktop app has already started.26.1029.7803.0; Windows x6426H2, build26300.9818.git.exe - Application Errordialog with0xC0000017. In one reproduction the command runner reported exit code 0 with no output forgit --version, despite the Windows dialog.rg,psqlanddotnetlaunches also reported insufficient memory resources from the Codex shell.git --version(2.51.0.windows.2), created a worktree, and built .NET projects. The Codex-side Git dialog recurred. PowerShell built-in file reads still work inside Codex..dotnet\tools; Codex PowerShell process PATH 32,634 characters and its environment block approximately 36,146 characters. No PATH values or logs are attached. No settings were changed and no cleanup A/B test was performed.The symptoms were noticed after an app update, but the update and PATH growth are not proven causes. This may be useful as a related reproduction where the app stays open but tool subprocesses fail, and the tool result can misleadingly appear successful. Expected: successful child launch or an accurate startup-failure result.
pedroformagini commentedon Nov 9, 2026
Additional independent reproduction from my own Windows workstation, including system-tool failures and a recovery that worked.
Environment and evidence
DOTNET_CLI_HOMEdirectories. The corresponding SDK markers were 10.0.400.toolpath.sentinel and 10.0.403.toolpath.sentinel.Pathreached 36,666 characters in the raw registry value / 36,670 after expansion, including 326 generated.dotnet\toolsentries..dotnetparent directories contained SDK tool-path sentinel files.Taskmgr.exe,sfc.exe, andDism.exefailed to initialize with 0xc0000017. There was still approximately 14 GB of available physical RAM during diagnosis.How we recovered this installation
This current recovery demonstrates a persistent environment configuration problem; it does not establish permanent corruption of Windows system files.
Earlier installation lost after reboot
A few days earlier, I experienced the same observable failure pattern on an earlier Windows installation after restarting. The Start menu and taskbar were invisible/unavailable for about ten minutes; they eventually appeared, but the system remained effectively unusable and I could not launch applications or system tools. I did not know about the PATH recovery at the time and ended up formatting/reinstalling Windows, losing that installation.
I now suspect that incident was related, but the old registry state was not preserved, so I cannot verify that earlier installation's exact root cause retrospectively.
Project-level prevention that matters
We traced the current accumulation to a project-specific preflight helper created during agent-assisted development. It set a fresh
DOTNET_CLI_HOMEfor each validation and rebuilt the child environment from an allowlist. SettingDOTNET_ADD_GLOBAL_TOOLS_TO_PATH=falsein the persistent user environment alone was insufficient for that helper, because its allowlist discarded the variable.For projects that have their own development plugins, skills, or build helpers invoking .NET, it would be useful to update the relevant plugin/skill instructions and the project's
AGENTS.md(or equivalent agent instruction file) with this guardrail, and enforce it in the actual launcher:DOTNET_ADD_GLOBAL_TOOLS_TO_PATH=falsein each actual SDK subprocess environment, after any environment filtering.Documentation is useful, but the subprocess configuration must enforce the prevention too. The related SDK-side report is dotnet/sdk#56512. Stronger detection and clearer diagnostics for this failure would help users avoid mistaking an unusable Windows session for an installation that needs reinstalling.