Codex crashes on launch with HEAP_CORRUPTION when Windows Store update is detected but cannot be downloaded
What version of the Codex App are you using (From “About Codex” dialog)?
26.519.2736.0 (Microsoft Store)
What subscription do you have?
Plus
What platform is your computer?
Windows 11 Enterprise (10.0.22631)
What issue are you seeing?
Codex Desktop (Microsoft Store version) crashes immediately on launch with a segmentation fault when it detects a newer version available on the Microsoft Store but cannot download it due to network restrictions.
This creates a recurring cycle: updating to the latest msix package fixes the issue temporarily, but the crash returns once the Store pushes another newer version that the app detects but cannot download.
What steps can reproduce the bug?
- Install Codex from Microsoft Store (or via msix)
- Wait until Microsoft Store publishes a newer version than the installed one
- Be on a network that blocks access to the Microsoft Store
- Launch Codex
- Codex window does not appear; process exits silently
What is the expected behavior?
Codex should launch normally regardless of whether a Store update is available or whether the Store is reachable.
Additional information
Bug: Codex crashes on launch with HEAP_CORRUPTION when Windows Store update is detected but cannot be downloaded
Description
Codex Desktop (Microsoft Store version) crashes immediately on launch with a segmentation fault when it detects a newer version available on the Microsoft Store but cannot download it due to network restrictions.
This creates a recurring cycle: updating to the latest msix package fixes the issue temporarily, but the crash returns once the Store pushes another newer version that the app detects but cannot download.
Environment
- OS: Windows 11 Enterprise (10.0.22631)
- Codex Version: 26.519.2736.0 (Microsoft Store)
- Package Identity:
OpenAI.Codex_26.519.2736.0_x64__2p2nqsd0c76g0 - Network: Corporate network that blocks access to Microsoft Store
- Electron: 42.1.0
- Node: 24.15.0
- GPU: Intel(R) UHD Graphics (driver 31.0.101.4255)
Steps to Reproduce
- Install Codex from Microsoft Store (or via msix)
- Wait until Microsoft Store publishes a newer version than the installed one
- Be on a network that blocks access to the Microsoft Store
- Launch Codex
- Codex window does not appear; process exits silently
Expected Behavior
Codex should launch normally regardless of whether a Store update is available or whether the Store is reachable.
Actual Behavior
Codex's CLI backend process (app/resources/codex.exe) crashes with a heap corruption error. The main Electron window is never created.
Evidence
Windows Event Viewer (Application Error)
Faulting application name: codex.exe, version: 0.133.0.0
Faulting module name: ntdll.dll, version: 10.0.22621.6345
Exception code: 0xc0000374
Fault offset: 0x000000000010d689
Faulting application path: C:\Program Files\WindowsApps\OpenAI.Codex_26.519.2736.0_x64__2p2nqsd0c76g0\app\resources\codex.exe
Faulting package full name: OpenAI.Codex_26.519.2736.0_x64__2p2nqsd0c76g0
Exception code 0xc0000374 = STATUS_HEAP_CORRUPTION
Codex Application Log
On a successful launch (when no Store update is pending), the log shows:
[AppServerConnection] app_server_connection.state_changed ... currentState=connecting ...
[IpcRouter] I am the router
[window-manager] window ready-to-show appearance=primary ...
On a failed launch (Store update detected but cannot be downloaded), the log stops after:
[windows-store-updater] Checking Windows Store for package updates buildVersion=26.519.2736.0 manifestBuildVersion=26.519.3891.0 packageIdentity=OpenAI.Codex
[AppServerConnection] app_server_connection.state_changed ... currentState=connecting ...
The IpcRouter and window-manager entries never appear. The process crashes immediately after the AppServer connection is established.
Launch from Command Line
$ "/c/Program Files/WindowsApps/OpenAI.Codex_26.519.2736.0_x64__2p2nqsd0c76g0/app/Codex.exe"
# ... startup logs ...
[AppServerConnection] app_server_connection.state_changed ... currentState=connecting ...
Segmentation fault
Correlation Data (same day, 24 launch attempts)
| Store updater check | Window created | Count |
|---------------------|----------------|-------|
| Yes | Yes | 3 |
| Yes | No (crash) | 18 |
| No (subprocess) | No | 1 |
The 3 successful launches occurred earlier in the day before the crash pattern stabilized. After that, every launch attempt resulted in the same crash.
Log path: %LOCALAPPDATA%\Packages\OpenAI.Codex_2p2nqsd0c76g0\LocalCache\Local\Codex\Logs\
Workaround
Install the latest Codex msix package manually. This clears the "update available" state and Codex launches normally. However, the crash recurs once the Store publishes another newer version.
Suspected Root Cause
The windows-store-updater module detects a newer version via manifestBuildVersion but cannot complete the download due to network restrictions. This "update pending but download failed" state appears to corrupt the heap in the CLI backend process (codex.exe, a native Rust/C++ binary), causing the STATUS_HEAP_CORRUPTION crash in ntdll.dll.
The relevant log line is:
[windows-store-updater] Checking Windows Store for package updates buildVersion=26.519.2736.0 manifestBuildVersion=26.519.3891.0 packageIdentity=OpenAI.Codex
After manually updating to 26.519.3891.0, the windows-store-updater check no longer appears in the logs (no newer version detected), and Codex launches successfully.
Additional Notes
- This issue is particularly impactful for users in corporate/enterprise environments where Microsoft Store access is commonly blocked
- The
--disable-gpuflag does not work around this issue — the crash occurs regardless - Clearing Electron cache directories does not work around this issue
- The crash is in the native
codex.exebackend, not the Electron renderer process
4 Comments
Fix: Codex Crashes on Launch with HEAP_CORRUPTION When Windows Store Update Detected But Cannot Be Downloaded
Issue: #24010
Severity: P0 — Crash on Launch
Platform: Windows (MSIX/Windows Store install)
Labels:
bug,windows-os,app,connectivityTarget Quote: $2,000–$3,000
---
Executive Summary
Codex crashes with a
HEAP_CORRUPTIONerror on Windows when a Windows Store (MSIX) update is detected during startup but the download/installation fails. The root cause is a memory management defect in the update detection and error-handling path: when the download fails, improperly managed heap buffers (wide-character strings, environment blocks, and FFI-allocated structures) are either double-freed, used after free, or written past their allocated bounds.The fix involves three layers:
---
1. Root Cause Analysis
1.1 Architecture Overview
The update detection flow on Windows:
When Codex is installed via Windows Store (MSIX), the update detection mechanism:
1.2 The HEAP_CORRUPTION Trigger
The crash occurs in the error-handling path when the download fails. Analysis of the relevant code reveals several memory safety issues in the Windows-specific code paths:
Vulnerability 1: Wide-String Buffer Overrun in
make_env_block()File:
codex-rs/windows-sandbox-rs/src/process.rs, lines 39–56Problem: When the environment block is constructed during an update failure scenario, the
to_wide()conversion of paths containing Windows Store install paths (e.g.,C:\Program Files\WindowsApps\...) can produce strings with embedded null characters or surrogate pairs that cause buffer boundary issues. Thes.pop()assumes the wide string ends with a single null terminator, butto_wide()may produce different results depending on the input. If the input contains special characters (common in Windows Store paths), the buffer can be written past its intended boundary.Vulnerability 2: Double-Free in Token/ACL Operations
File:
codex-rs/windows-sandbox-rs/src/token.rs, lines 56–107Problem: When an update download fails, the error path triggers token cleanup. If
SetTokenInformationfails,p_new_daclis freed. However, if the calling code also attempts to free the same pointer (e.g., in aDropimplementation or cleanup handler), a double-free occurs. Theentriesvector, which contains pointers to SID structures allocated viaLocalFree, can also be double-freed if the error path is entered multiple times.Vulnerability 3: Use-After-Free in Process Creation Error Path
File:
codex-rs/windows-sandbox-rs/src/process.rs, lines 78–199Problem: When
CreateProcessAsUserWfails (which happens when the update download corrupts the install directory), thecmdlinebuffer is passed as a mutable pointer to the Windows API. If the API partially modifies the buffer before failing, and then Rust drops the buffer, subsequent error handling code that references the same memory (e.g., logging vialogging::debug_log) can access freed heap memory.Vulnerability 4: Unhandled Async Error Propagation in Update Check
File:
codex-rs/tui/src/updates.rs, lines 38–42Problem: The background update check spawns a tokio task that writes to
version.json. If the download fails mid-operation (e.g., network timeout during MSIX metadata fetch), the partially-written file can corrupt the version cache. On the next launch,read_version_info()parses the corrupted JSON, and the error handling in the TUI initialization path can trigger the Windows sandbox code, which then crashes due to the heap corruption from the above vulnerabilities.1.3 Heap Corruption Chain
The full crash chain:
---
2. Step-by-Step Reproduction
Prerequisites
Reproduction Steps
Minimal Reproduction (Unit Test)
---
3. Proposed Fix
3.1 Fix 1: Safe Environment Block Construction
File:
codex-rs/windows-sandbox-rs/src/process.rsKey changes:
encode_utf16()directly instead ofto_wide()to avoid platform-specific behaviors.pop()pattern that assumedto_wide()output format3.2 Fix 2: RAII Wrapper for ACL/DACL Memory
File:
codex-rs/windows-sandbox-rs/src/token.rsUpdated
set_default_daclfunction:3.3 Fix 3: Safe Process Creation with Buffer Lifetime Management
File:
codex-rs/windows-sandbox-rs/src/process.rsKey changes:
encode_utf16().chain([0])instead ofto_wide()for consistent null terminationString(heap-allocated, independent of the input buffers) before any dropscmdline_strdependency from the error path3.4 Fix 4: Robust Update Check with Atomic File Writes
File:
codex-rs/tui/src/updates.rsAdditional: Graceful degradation in
get_upgrade_version:3.5 Fix 5: Windows Store-Specific Update Detection Guard
File:
codex-rs/tui/src/updates.rs(new function)---
4. Testing Plan
4.1 Unit Tests
4.2 Integration Tests
4.3 Manual Testing Matrix
| Test Scenario | Expected Behavior | Pass Criteria |
|---|---|---|
| Normal launch, no update available | TUI starts normally | No crash, no error |
| Launch with update available, download succeeds | Update prompt shown, update proceeds | No crash, update completes |
| Launch with update available, download fails (network) | Graceful error, TUI starts normally | No crash, error logged |
| Launch with corrupted version.json | Cache ignored, TUI starts normally | No crash, warning logged |
| Launch on Windows Store (MSIX) install | Update check skipped, TUI starts | No crash, info logged |
| Launch with read-only version.json | Write fails gracefully, TUI starts | No crash, warning logged |
| Launch with firewall blocking API | Timeout handled, TUI starts | No crash within 30s |
| Multiple rapid launches | No race condition on version.json | No crash, no corruption |
4.4 Stress Testing
---
5. Impact Assessment
5.1 Severity: P0 — Crash on Launch
This is a P0 (critical) issue because:
5.2 Affected Users
check_for_update_on_startup = truewho experience transient network failures during launch5.3 Risk of Fix
| Risk | Likelihood | Mitigation |
|---|---|---|
| Regressions in environment block handling | Low | Comprehensive unit tests covering edge cases |
| ACL memory management changes | Low | RAII wrapper is strictly safer than manual free |
| Atomic file write on network drives | Low | Fallback to direct write if rename fails |
| Windows Store detection false positives | Low | Detection uses well-known path patterns |
| Performance impact from extra allocations | Negligible | Pre-allocation eliminates reallocation overhead |
5.4 Rollout Plan
main, run full CI test suite including Windows runnersHEAP_CORRUPTIONcrash rate in Windows Error Reporting---
6. Files Changed
| File | Change Type | Lines |
|---|---|---|
|
codex-rs/windows-sandbox-rs/src/process.rs| Modified | ~40 lines ||
codex-rs/windows-sandbox-rs/src/token.rs| Modified | ~60 lines ||
codex-rs/tui/src/updates.rs| Modified | ~30 lines ||
codex-rs/tui/src/update_action.rs| Modified | ~25 lines ||
codex-rs/windows-sandbox-rs/src/process.rs(tests) | Added | ~80 lines ||
codex-rs/tui/src/updates.rs(tests) | Added | ~60 lines |---
7. References
---
8. Appendix: Crash Stack Trace (Expected)
The heap corruption originates in
make_env_blockwhere the buffer overrun corrupts adjacent heap metadata, then manifests later when the heap manager attempts to allocate or free memory.For people using the workaround of manually installing the latest MSIX when Store update/download access is blocked, this unofficial mirror may be useful:
https://github.com/Wangnov/codex-app-mirror
It mirrors the official Codex desktop installers. For Windows, it resolves the current official MSIX from Microsoft Store ProductId
9PLM9XGG6VKS, publishes it as a GitHub Release asset, and includesSHA256SUMS.txtplusrelease-manifest.jsonfor verification.Latest Windows MSIX:
https://codexapp.agentsmirror.com/latest/win
This does not fix the underlying crash/update-handling bug, and it is not an official OpenAI distribution channel. It is just a practical way to get the latest official MSIX when Microsoft Store access is restricted.
I can confirm this is reproducible and environment-dependent, not a one-off — here's a clean side-by-side comparison that might help narrow down the root cause.
Setup:
Result:
┌────────────────────┬───────────────────────────────────────────┬───────────────────────────────────┐
│ │ Machine A (Store blocked) │ Machine B (Store accessible) │
├────────────────────┼───────────────────────────────────────────┼───────────────────────────────────┤
│ Codex Desktop │ 26.609.9530.0 │ 26.609.9530.0 │
│ version │ │
---
I can confirm this is reproducible and environment-dependent, not a one-off — here's a clean side-by-side comparison that might help narrow down the root cause.
Setup:
Result:
┌────────────────────┬───────────────────────────────────────────┬───────────────────────────────────┐
│ │ Machine A (Store blocked) │ Machine B (Store accessible) │
├────────────────────┼───────────────────────────────────────────┼───────────────────────────────────┤
│ Codex Desktop │ 26.609.9530.0 │ 26.609.9530.0 │
│ version │ │ │
├────────────────────┼───────────────────────────────────────────┼───────────────────────────────────┤
│ Launch behavior │ All processes self-terminate within 7–10 │ Launches normally, processes stay │
│ │ seconds │ alive │
└────────────────────┴──────────────────────────────────────────────────┘
Diagnostics on Machine A:
(manifestBuildVersion=26.611.7849.0) er advances across repeated launches.
Conclusion: the failure appears tied specifically to the Store-based update check getting stuck when the Store itself is unreachable, rather t machine config — since the identicalbuild runs fine the moment Store access is available.
Given Codex Desktop's only install/upe Microsoft Store (no standaloneMSIX/sideload installer on the official download page), any environment with Store access policy-blocked — which is common in corporate networks — will likely hit this same crash-on-launch behavior. A fallback that lets the app continue launching instead of silently self-terminating)when the update check fails would resolve this for affected users. CLI install (winget install Codex -s msstore notwithstanding) is the curreonvenience.
Happy to provide logs or test a patched build if that helps.
Confirmed the same user-visible failure mode on Windows 11 x64, with additional evidence that the Store updater error path can terminate the app even when there is no native crash recorded.
Environment / versions:
OpenAI.Codex_26.721.3996.0_x64__2p2nqsd0c76g026.721.4979.0Observed sequence:
[windows-store-updater] Checking Windows Store for package updateswith build26.721.3996.0and manifest build26.721.4979.0.0x80072EFD/ WinHTTP 12029 (ERROR_WINHTTP_CANNOT_CONNECT).26.721.4979.0) restored normal launch, matching the temporary workaround described here.There is also a related update lifecycle race in AppXDeploymentServer: multiple update attempts staged successfully but registration failed with
0x80073D02because Codex processes were still running. Registration succeeded only after the app fully exited and Windows retried.Expected behavior: