Windows Desktop: shell_command can fail globally with 0xC0000142 due to helper materialization/fallback
Open 💬 1 comment Opened Apr 1, 2026 by jojonax
Summary
On Windows Desktop App sessions, shell_command may suddenly fail immediately for all commands with exit code -1073741502 (0xC0000142).
Observed behavior
- Any simple command fails immediately (
Get-Date,echo hi, etc.) - Integrated terminal UI can still open and show PowerShell prompt
- Failure is in Desktop execution chain, not project code
Repro (Windows Desktop)
- Start a Desktop session.
- Run
shell_commandwithGet-Date. - Observe immediate failure with
0xC0000142. - Repeat with other commands (
echo hi), same immediate failure.
Root cause (code-level)
The issue is in Windows sandbox helper materialization/resolution reliability for packaged (WindowsApps) installs:
- In
windows-sandbox-rs, helper freshness usedsize + mtimeonly, which can miss content drift. - Fallback resolution could use package-adjacent sibling/legacy helper paths near
current_exe. - Under protected
WindowsAppslayouts, those helper paths are not a stable execution source.
Relevant files:
codex-rs/windows-sandbox-rs/src/helper_materialization.rscodex-rs/windows-sandbox-rs/src/setup_orchestrator.rs
Proposed fix (implemented in fork)
- Add setup helper into materialization path (
codex-windows-sandbox-setup.exe). - Harden freshness check from
size+mtimetosize+mtime+content comparison. - Avoid WindowsApps sibling fallback behavior.
- Resolve setup helper from materialized
.sandbox-bincopy. - Exclude WindowsApps exe parent from helper read roots.
- Add regression tests for:
- same-size/same-mtime content drift
- WindowsApps helper fallback/read-root behavior
Validation performed
cargo clippy --fix --tests --allow-dirty -p codex-windows-sandboxcargo fmt -- --config imports_granularity=Itemcargo test -p codex-windows-sandbox(46 passed)
Branch / patch reference
- Commit:
707d8842f02f630b6c58b462558817e6bd953153 - Branch:
jojonax:codex/windows-desktop-helper-materialization-fix - Compare URL (PR-ready):
Note on PR creation
Direct PR creation currently fails for this account with:GraphQL: jojonax does not have the correct permissions to execute CreatePullRequest.
So I am filing this issue with the complete patch link attached.
This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗