Description
What version of Codex are you using?
Reproduced from upstream commit 042534ec1ab2f79c2997e779347d5383832ecb2e (Release 0.154.0-alpha.1). The same local-stdio implementation is still present on current main at the time of filing.
Platform
Windows 11 x64.
Summary
On Windows, every quiet local STDIO MCP client can occupy two workers in Tokio's shared blocking pool indefinitely: one pending read for child stdout and one for child stderr. Codex uses Tokio's default blocking-thread limit (512), so enough retained/per-thread MCP clients can prevent unrelated spawn_blocking work from ever starting and stall the entire app-server even though async network I/O can continue.
This is a separate low-level failure mode underneath the already reported MCP process/session multiplication issues. Explicit shutdown helps only after an owner is actually disposed; it does not make hundreds of simultaneously retained local STDIO transports safe on Windows.
Confirmed mechanism
Codex currently does the following:
codex-rs/arg0/src/lib.rs::build_runtime()creates a multi-thread Tokio runtime without settingmax_blocking_threads(Tokio default: 512).codex-rs/rmcp-client/src/local_child.rsstarts every local MCP child with piped stdin/stdout/stderr.- The rmcp transport continuously reads stdout.
codex-rs/rmcp-client/src/stdio_server_launcher.rsstarts a second continuousBufReader::lines()drain for stderr.- Tokio 1.52.3 represents Windows
ChildStdout/ChildStderrasio::blocking::Blocking<ArcFile>, so each pending read consumes a shared blocking worker.
Tokio documents the exact generic failure in tokio-rs/tokio#5777:
on Windows, reading a pipe is a blocking read and will take away a blocking thread forever
and:
spawn_blockingjust hangs forever, because all your blocking threads are waiting on a pair of idle pipes (stdout and stderr of a child process, in our case)
Tokio PR tokio-rs/tokio#4824 explains why Windows child stdio was moved to the blocking pool.
Minimal deterministic reproduction
I added a Windows-only codex-rmcp-client integration test with a deliberately small blocking pool:
#[test]
fn idle_mcp_stdio_does_not_exhaust_tokio_blocking_pool() -> anyhow::Result<()> {
let runtime = tokio::runtime::Builder::new_multi_thread()
.worker_threads(2)
.max_blocking_threads(8)
.enable_all()
.build()?;
let sentinel_completed = runtime.block_on(async {
let launcher = Arc::new(LocalStdioServerLauncher::new(std::env::current_dir()?));
let mut clients = Vec::new();
// Alternate Legacy and V20260728 transports. Each initialized server then
// waits quietly on stdout while Codex independently drains quiet stderr.
for index in 0..4 {
let mode = if index % 2 == 0 {
McpProtocolMode::Legacy
} else {
McpProtocolMode::V20260728
};
let env = (mode == McpProtocolMode::V20260728).then(|| HashMap::from([(
OsString::from("CODEX_MCP_PROTOCOL_VERSION"),
OsString::from("2026-07-28"),
)]));
let client = Arc::new(RmcpClient::new_stdio_client_with_protocol_mode(
stdio_server_bin()?.into(), vec![], env, &[], None,
launcher.clone(), mode,
).await?);
client.initialize(init_params(), Some(Duration::from_secs(5)), no_elicitation()).await?;
clients.push(client);
}
tokio::time::sleep(Duration::from_millis(250)).await;
let sentinel = tokio::task::spawn_blocking(|| ());
let completed = tokio::time::timeout(Duration::from_secs(1), sentinel).await.is_ok();
// Release the pipe reads before returning so even the pre-fix runtime exits.
for client in clients { client.shutdown().await; }
Ok::<_, anyhow::Error>(completed)
})?;
assert!(sentinel_completed, "idle MCP stdio exhausted Tokio's blocking pool");
Ok(())
}Reproduction result
On exact upstream 042534ec1ab2:
TRY 1 FAIL [1.313s] idle_mcp_stdio_does_not_exhaust_tokio_blocking_pool
TRY 2 FAIL [1.325s] idle_mcp_stdio_does_not_exhaust_tokio_blocking_pool
idle MCP stdout/stderr reads exhausted Tokio's blocking pool
The same test also failed on a direct child of that release before changing the MCP code. There is no diff in the runtime/local-stdio files between those two revisions.
Proof-of-fix result
I prototyped a Windows-only transport replacement:
- create three unique byte-mode named-pipe pairs per local MCP child;
- keep parent endpoints as Tokio
NamedPipeServerhandles opened withFILE_FLAG_OVERLAPPED(IOCP); - pass synchronous client endpoints to the child as stdin/stdout/stderr;
- retain existing Job Object containment and shutdown behavior;
- leave Unix/macOS unchanged.
With that change, the identical test passes:
PASS [0.299s] idle_mcp_stdio_does_not_exhaust_tokio_blocking_pool
The existing local STDIO tests also pass for both legacy and modern protocol modes, including the Windows Job Object descendant-cleanup test.
Expected behavior
Idle local STDIO MCP servers must not consume the finite shared blocking pool. Long-running app-server operation should preserve capacity for unrelated blocking operations regardless of how many retained MCP sessions exist.
Actual behavior
Approximately two permanently pending blocking reads are created per quiet local STDIO MCP client. With enough retained clients, later spawn_blocking tasks queue indefinitely. At the default limit this is reachable around 256 local clients, or earlier because the pool is shared with other blocking work.
Why raising max_blocking_threads is not sufficient
Increasing the limit only moves the failure threshold, permits more OS threads, and leaves an unbounded resource relationship. Disabling stderr capture frees only one slot per server and can deadlock verbose children on a full stderr pipe.
Related Codex issues/PRs
- [Windows] Completed subagents leave STDIO MCP Node.js processes running (245 processes / 18 GB) #34658 — completed subagents retain large per-subagent STDIO MCP fleets
- [Windows Desktop 26.810.7004] Thread-scoped STDIO MCP processes and local-proxy CLOSE_WAIT sockets accumulate #38981 — per-thread STDIO MCP process sets accumulate in long-lived Windows Desktop sessions
- [Windows Codex app] Local stdio MCP servers are repeatedly spawned and not reaped within a single task #38754 / Windows/WSL2: Desktop retains one eager MCP stack per opened chat and replays history during navigation #32154 — repeated per-thread/turn MCP generations
- Codex Desktop should use a project-scoped MCP process pool instead of starting MCP per session #20883 — proposal to share/pool MCP servers
- Terminate stdio MCP servers on shutdown to avoid process leaks #19753 — explicit MCP shutdown at selected lifecycle boundaries (partial mitigation, not protection for many still-live transports)
I searched open and closed Codex issues/PRs for blocking pool, spawn_blocking, max_blocking_threads, ChildStdout, ChildStderr, and 512 threads; I did not find an existing Codex report for this specific mechanism.
Suggested fix
Use IOCP-compatible parent pipe endpoints on Windows (overlapped named pipes are one practical approach), plus retain deterministic process-tree shutdown. Independently, lazy MCP startup/shared bounded connection ownership would reduce process and memory amplification, but it should not be the only protection against exhausting a global runtime resource.
Activity
argszero commentedon Sep 4, 2026
This is a very well-researched report — thank you for the failing regression test and the proof-of-fix. I independently verified the mechanism against the current code and it holds:
In codex-rs/arg0/src/lib.rs, build_runtime() (lines 290-295) builds a multi-thread Tokio runtime using enable_all() and thread_stack_size(...) but does NOT call max_blocking_threads(...), so Tokio uses its default of 512. Confirmed.
In codex-rs/rmcp-client/src/local_child.rs (lines 23-25), every local MCP child is spawned with piped stdin/stdout/stderr.
In codex-rs/rmcp-client/src/stdio_server_launcher.rs (lines 354-360), a tokio::spawn wraps stderr in BufReader::lines() and loops. On Windows, ChildStderr/ChildStdout are io::blocking::Blocking, so the pending read pins a shared blocking worker for the lifetime of the pipe.
codex-rs/Cargo.lock pins tokio to 1.52.3 (confirmed), so the Windows child-stdio-on-blocking-pool behavior you reference (max_blocking_threads documentation should perhaps indicate that Tokio internally uses those too tokio-rs/tokio#5777, Fix wayland image paste error #4824) applies.
So the two-pending-reads-per-quiet-client model is accurate: roughly two blocking workers consumed per retained local STDIO MCP server, and at the default 512 limit this becomes reachable — or can starve unrelated spawn_blocking work well before that when the pool is shared.
On the fix, your IOCP-compatible parent pipe endpoints (overlapped named pipes with FILE_FLAG_OVERLAPPED) are the correct low-level approach: it removes the child stdio from the blocking pool entirely rather than just raising the threshold. I agree with your note that raising max_blocking_threads only moves the failure point and leaves the unbounded resource relationship in place; and that disabling stderr capture is not safe (it can deadlock verbose children on a full pipe).
One thing worth flagging for the fix review: the change is Windows-only (cfg(windows)), so the regression test needs to remain Windows-gated too, and the existing local-stdio tests (Legacy + V20260728 protocol modes, and the Windows Job Object descendant-cleanup test you mentioned) must still pass. The deterministic shutdown-before-return in the test is a nice touch to avoid the pre-fix runtime hanging.
This deserves maintainer attention — it is a real shared-runtime-resource exhaustion, and the report is reproducible and has a concrete fix. Happy to help review the PR or validate the cross-platform-safe guard once opened.
kevinwwillis commentedon Sep 27, 2026
Adding a field data point that matches this exactly (Codex CLI 0.156.0,
codex app-serveron Windows 11, used as a long-running server for a local chat client).The app-server stopped answering
thread/startandturn/start(reads such asthread/loaded/listkept working) twice, on two separate server processes. Each time it had 256-257 direct children: 126-128node_repl.exeplus the same number of CUAnode.execompanions, with 136-143 loaded threads.On a second, isolated instance we loaded sessions one at a time: with 127 helper pairs
thread/startanswered in 243 ms; with 128 pairs everythread/startandturn/starttimed out (~30 s). 2 helpers x 2 pipes x 128 = 512, the defaultmax_blocking_threads. Minidumps of both the stalled test instance and a stalled production process show 511-512 Tokio blocking workers waiting inNtWaitForSingleObject.So on Windows the practical ceiling is about 128 loaded sessions when each session starts two local STDIO MCP servers. The overlapped-pipe fix proposed here would remove it; an explicit unload (#21889) or pooled MCP processes (#20883) would also keep long-running app-servers away from it.
4Liberty commentedon Oct 8, 2026
Additional source-level reproduction and a private prototype against public commit
9b738582b:spawn_blockingsentinel times out.The protocol and child-lifecycle checks are kept separate from the pool reproduction. This is a private source prototype, not a shipped desktop fix. Increasing the blocking-pool limit would only raise the saturation threshold; the underlying quiet pipe reads need to stop occupying that pool.
No external code PR is being opened, in accordance with the repository's current contribution policy.
CrispyW0nton commentedon Oct 12, 2026
Additional measured Windows evidence on the newer bundled backend
codex-cli 0.162.0-alpha.17.2(Desktop package26.1007.2314.0, internal app26.1007.21434). The local OS probe reports Windows 10 Pro x64,10.0.19045.I investigated this with Codex assistance. In an isolated diagnostic home with 270 configured minimal MCP servers, the direct-stdio case reached 567 backend threads and 516 Windows UserRequest waits.
config/readtimed out at 8,125 ms andconfigRequirements/readat 8,062 ms. Those are probe deadlines/lower bounds, not completed request latencies.With the diagnostic servers accessed through authenticated literal-loopback Streamable HTTP, the backend had 73 threads and four UserRequest waits; both reads completed in 16 ms. The gateway retained a separate native stdio child per session. This moved pipe-reader pressure out of the Codex backend; it did not pool native session state or eliminate process multiplication.
Backend private memory was 130.6 MiB in the stdio sample versus 149 MiB in the HTTP sample. These are backend-only snapshots, so I am not claiming reduced total memory use.
A separate actual-server test used 12 isolated ephemeral contexts � 21 custom MCP servers = 252 live sessions. It recorded zero transport errors, 67 backend threads, three UserRequest waits, config/read median 19.1 ms / p95 29.9 ms / max 30.4 ms, and 12 successful fixed native status reads. Owner exit left zero test sessions. No inference or native asset writes were performed. The 21 Desktop catalogs retained their original 427 tool definitions and filters.
I also found that a companion host used the same
codex-mcp-clientidentity. Explicit authenticated owner attribution was needed so Desktop exit did not remove the companion host's sessions. The gateway keeps DELETE/owner cleanup, bounded idle cleanup with pending-request protection, authentication and request/session limits.The measurements support the local transport-pressure finding in this issue. I have not established that all workspace-routing/remote-compaction errors or long-running rendered UI stalls have this cause.
Sanitized report, test outline and result data: https://gist.github.com/CrispyW0nton/ec298528829397c5389dd49fba193578
This is additional field evidence and a local workaround, not an upstream fix or a claim of faster model generation. The bundle does not include a turnkey harness or modified Desktop binaries.
K0enna commentedon Oct 17, 2026
Windows Desktop confirmation
On Desktop 26.1013.4894.0 with bundled codex-cli 0.163.0-alpha.10.2, several open chats repeatedly led to
thread/read,config/readand tool-discovery timeouts while CPU and disk activity stayed low. Restarting helped temporarily.One backend reached 556 OS threads, including 500 Windows
UserRequestwaits. These counts support resource-pressure investigation but do not identify individual pipe-reader stacks.Reproduction
The adjacent public source reproduces this at the real
RmcpClient/LocalStdioServerLauncherboundary:spawn_blockingtask misses its one-second deadline. With overlapped parent pipes, all four clients and the task complete.The reduced pool accelerates the failure; four clients is not the normal product limit. The default blocking-pool limit is 512.
Retention amplifies the pressure
A separate control against the unchanged installed backend confirmed that an inactive, successfully unsubscribed context retained its quiet MCP process for 1,800.016 seconds before both were retired. That confirms 30-minute retention, rather than a permanent leak. Attribution to individual Desktop helper contexts remains unproven.
Scoping plugins and running tool-free reviews in isolated CLI processes reduced added MCP pressure, but shared Desktop timeouts later returned. A separate browser CDP timeout was also observed; this investigation does not attribute every stall to the stdio issue.
Fix
A local overlapped-pipe repair is implemented and tested. Implementation, verification and deployment limits are in a separate comment. The installed Desktop has not yet been switched to the candidate.
K0enna commentedon Oct 18, 2026
Local Windows fix implemented
The local source fix replaces Windows MCP parent stdio with overlapped named pipes. Quiet stdout/stderr reads no longer occupy Tokio's shared blocking workers. Children still receive synchronous standard handles through the existing suspended-spawn and Job Object launcher.
What changed
Verification
At the real
RmcpClientboundary, three clients completed echo calls before a fourth quiet child exhausted an eight-worker blocking pool. An unrelated blocking task then missed its one-second deadline. With the fix, all four clients and that task completed.Fifteen focused checks passed, including protocol behavior, pipe security, EOF, cancellation, failed spawn and Job Object containment. Sixteen isolated cleanup repetitions left the process handle count unchanged. A P2 review found a test-isolation issue; it was fixed without changing the production implementation.
The complete Windows CLI builds. Its 452 exported JSON schema files match the installed backend byte-for-byte. Both binaries passed isolated initialization, config read and harmless command execution. The candidate also opened copies of the existing runtime databases without changing their schemas or migration histories.
Deployment status and limits
Active locally. The complete private bundle now runs in Desktop. After correcting the omitted companion executables, it passed an isolated test through the actual code host and command tool. The running app-server and code-host paths/hashes and selectors are verified; real shell execution and native chat reads pass. A bounded fresh-log check found no transport timeouts. Backups and selector rollback are retained.
This is a local candidate based on public commit
cd643519fb56011557d09b41053a3a4c0e013e1f(0.163.0-alpha.10), adjacent to installed0.163.0-alpha.10.2. Verification used Windows and Rust 1.99 rather than the repository-pinned 1.95. Sustained multi-chat recovery, restricted sandbox behavior and other platforms remain unverified.No signed application file has been modified.
PNWGMR commentedon Oct 18, 2026
Two amplifiers on Desktop 26.1013.4894.0 / codex-cli 0.163.0-alpha.10.2
I reproduced the mechanism in this issue on a private
codex app-server(0.163.0-alpha.10.2, scratchCODEX_HOME, one ephemeral thread, K copies of one small stdio MCP server):config/readprobes (1/s)thread/loaded/listprobesTwo code paths make the pool fill sooner and explain why unrelated requests stall together, then flush together. I didn't see either in this thread yet:
mcpServerStatus/listcold-starts every configured server. WhenserverNameis absent, even with athreadId,list_mcp_server_status_responsecallscollect_mcp_server_status_snapshot_with_detail(codex-mcp/src/mcp/mod.rs). That builds a freshMcpConnectionSetwithMcpStartupPolicy::Eagerfor all effective servers, then cancels it. Each such call temporarily adds a full extra set of stdio pipe pairs on top of the per-thread sets. On a pool that is nearly full, one status poll is enough to tip it. For example, with 1 thread and 6 concurrent unscoped calls, I counted 63 server processes: 7 copies of a 9-server set.spawn_blocking.refresh_application_network_policy()(app-server/src/application_network.rs) holdsnetwork_policy_reload, aSemaphore::new(1)(config_manager.rs). It holds it while reading local policy and the cloud-config cache, and the cache read usesspawn_blocking(cloud-config/src/cache.rs). Once the pool is full, the permit holder can't finish. Soconfig/read,configRequirements/read,getAuthStatus,model/listand unscopedmcpServerStatus/listall queue behind it. On the live desktop that produced a 632 sconfig/readand a 465 sgetAuthStatus, while 631 concurrentthread/readcalls answered in under 0.2 s.Suggested mitigations in addition to the named-pipe fix:
mcpServerStatus/listthat has athreadIdfrom the thread's live connections, not from a cold start.max_blocking_threadsexplicitly until stdio no longer uses the blocking pool.K0enna commentedon Oct 18, 2026
Local Windows observation after the pipe repair — 18 October 2026
The repaired backend answered every check during 125 minutes of normal-use observation (08:24–10:30 UTC), with the same process and no restart. Four scheduled checks, two extra checks and the baseline were completed.
Auth requiredwarnings continued and were classified separately.Emulation.setFocusEmulationEnabledtimeout followed by 30 frame-not-found errors. The affected chat continued command work; recovery of that specific browser operation was not verified.The loaded segment included seven responding chats (six active turns and one completing during the sample); a concurrent backup was reported running. Later sampled turns completed and load subsided. Two source-preparation workers also contributed workload; compilation and synthetic load were excluded during the observation.
This is normal-use evidence, not a controlled A/B benchmark or proof of permanent recovery. Log reads were bounded; retained tails covered their requested windows. Restricted-sandbox behavior remains unverified. Connection-reuse and policy-reload follow-ups are separate drafts and have not been activated. The bounded watch is now paused.
K0enna commentedon Oct 18, 2026
Fix: An unfiltered
mcpServerStatus/listwith athreadIdreuses matching live connections. Changed registrations still use current configuration.Measured results — Windows,
0.163.0-alpha.10with the pipe and status-reuse patches:Recommendation: retain the repair and investigate memory growth separately. The observation supports stability under this workload; it does not establish permanent recovery or a matched latency improvement.
Damso74 commentedon Oct 22, 2026
Additional Windows measurements on exact 0.163.0-alpha.10.2: scoped IOCP patch and later Desktop queue recurrence
Adding a separate local qualification of the IOCP approach already described above, including an important limitation observed later. This is a locally built workaround, not an upstream release or a claim that all Desktop freezes are fixed.
Environment: Windows Desktop 26.1013.4894.0; native CLI 0.163.0-alpha.10.2. Source base: tag
rust-v0.163.0-alpha.10.2, commit4ebc485ca321243727539187169425fcf972f2c4.Scoped change: keep the existing child launch/job lifecycle, but use Tokio named-pipe servers for the parent's stdin/stdout/stderr endpoints. The child's endpoints remain synchronous handles. Pipe names use random UUIDs, first-instance enforcement, remote-client rejection, and a protected DACL granting the current user and SYSTEM access. Non-Windows spawning and the MCP framing limit are preserved. The diff excludes local launcher changes and workspace-version churn; it is a candidate for review, not a complete Windows/security qualification.
Native before/after observations — 21 October 2026 UTC
These were separate runs, not a controlled latency benchmark. Both full-engine fixtures used 260 minimal stdio MCP servers and made no model or business/provider calls.
config/readA corrected-process stack capture unwound 54 threads without errors; the largest identical single-object wait group was 2. The original 512-waiter signature was absent in that capture. Owned fixture processes were closed after the runs.
A separate reduced-pool probe used four blocking workers: ordinary pipes with 32 children hit the deadline, while IOCP with 260 children / 520 quiet reads allowed an unrelated blocking sentinel to finish in 45 microseconds. Echo, stdin/stdout, stderr, EOF and cleanup checks passed in the IOCP run. These child counts differ; this is a starvation probe, not a matched throughput comparison. The probe source is included below; its arguments are an absolute Python executable path, child count, and optional
legacymode.Bounded Desktop observation and later recurrence
A 30-minute observation (03:14–03:44 UTC, 60 samples) recorded 55–92 native threads and no queue-rejection/routing-timeout markers in that window. Two existing-chat command exchanges also completed. This does not establish long-term stability.
Later the same day, Desktop admission failures still occurred with the IOCP engine: between 11:32 and 12:25 UTC, logs recorded 990 queue rejections (57 queued expirations and 933 capacity refusals). Of the capacity refusals, 844 concerned
mcpServer/tool/callat a 20-pending-per-ephemeral-context boundary. We did not obtain an in-freeze stack proving the original 512-waiter mechanism during this recurrence, so we cannot assign every later stall to the same cause.An offline scheduler reproduction, not a live fix, completed 23/100 synthetic requests with 77 rejections under a same-context burst; bounding concurrency to two completed 100/100 without rejection. No renderer/scheduler change or global queue-limit increase was activated. This suggests a separate admission-pressure path to investigate, rather than evidence that the native transport patch solves it. Ambiguous business calls should not be replayed on that basis.
These are dated local results, not tests of current upstream main. Private paths, session/account identifiers, dumps and application data have been omitted. No production imports or provider actions were used as test fixtures.
Scoped transport patch and reduced-pool probe, against the source commit above
collab532 commentedon Oct 25, 2026
Current Windows Desktop recurrence and local IOCP qualification — 24–25 October 2026 UTC
Adding current-version evidence to this existing Windows blocking-pool report rather than opening a duplicate. The user continues to experience tools appearing active while useful progress stops, across multiple chats. The observations below distinguish the native transport workaround from other unresolved Desktop/CUA failures; they do not establish one cause for every freeze.
Environment: Windows x64, approximately 32 GB RAM; Desktop MSIX package
26.1021.3705.0; locally built CLI0.164.0-alpha.11.1, based on public commit6905ecede7816e91373e9eabda3f6b0368fc747b. The tests below concern a local patched binary and a compatibility-checkedCODEX_CLI_PATHlauncher, not an official fixed release or a test of current upstream main.User-visible stalls and resource use
21:16:51.824Zto21:17:21.870Z(30.046 seconds) and returnedjs execution timed out; kernel reset, rerun your request. Its underlying browser-operation cause was not established; this exact result was not an automatic-approval deadline error.Scoped native transport workaround
The local Windows-only change uses overlapped named pipes / Tokio IOCP for the parent's stdin/stdout/stderr endpoints; child endpoints remain synchronous. Existing framing, process containment and shutdown behavior are retained. Pipes use unpredictable UUID names, first-instance checks, remote-client rejection, and a protected current-user/SYSTEM DACL. Non-Windows behavior is unchanged. This follows the transport approach already discussed in this issue.
Completed tests on the current local build
config/read15–32 mswin32, CUAgetState, and a normal managed workspace terminal echo all passed in an existing chat, without reset/retry in that final runThe isolated integration fixtures used no model inference, production tools, credentials, or copied chat history. Wire-level MCP cancellation notification/ack was not verified; configured timeout/recovery was verified.
An initial local rebuild could not open existing state because its embedded SQLx migration checksums differed. Converting only the 77 migration SQL inputs from LF to the matching Windows CRLF byte representation and rebuilding restored compatibility: the new executable's scratch-database migration metadata matched the existing state (61) and other exercised databases (8). Lazy history migrations were checked at source level only. No production DB, checksum metadata or history was edited. This is a local build compatibility observation, not a proposed production DB repair.
Remaining CUA failures and attribution limits
Before the final normal restart, two actual CUA
getStateattempts failed after approximately 0.92 / 0.97 seconds with:One supported
js_resetsucceeded but the nextgetStatestill failed. A later instrumented reset/getState and the final post-restart three-tool check succeeded under the same permission settings. The two exit-22 causes remain unknown.There is an important local confound: Desktop's managed Node environment can re-inject
CODEX_CLI_PATHpointing at the wrapper, and the wrapper has a compatibility guard. Its status-recording failure can itself produce exit 22 and mask an earlier check failure. We did not capture enough evidence to attribute either failed kernel to that guard, the sandbox launcher, or upstream CUA. A capped process sampler skipped processes; successful sampled guards exiting 0 do not explain the earlier failures. No speculative guard bypass was applied.After the normal restart, two short Desktop-tree samples decreased from 351 to 295 processes, 8.34 to 7.38 GiB aggregate private memory, and 56 to 52 native backend threads. These are short post-restart observations, not a matched before/after benchmark, a leak fix, or a long-duration stability result.
thread_unload_delay_secs=300was configured, but its effective runtime value was not independently observed and it is not a hard memory bound for still-subscribed chats.Requested upstream resolution
These unsigned local builds are not a permanent distributable solution. Smart App Control had already been disabled on the host; this qualification does not demonstrate operation with it enabled. We are requesting a fix that preserves normal sandbox, approval, Windows security and application-update behavior. The final production permission context remained
on-request/auto_review/workspace-writewith network restricted; a permission-mode change is not claimed as the fix.Only sanitized technical observations are included. No raw transcripts, account/session identifiers, private paths, customer data, credentials or dumps are attached. Please split or redirect the residual CUA symptom if it belongs in a separate supported channel.
BlackBadHope commentedon Oct 26, 2026
Windows Desktop recurrence: 543 backend threads, 253 direct children, global routing stalls
Additional measured evidence for this existing report, collected on 26 October 2026. I am adding it here rather than opening another duplicate.
Environment
26.1021.3705.0.codex-cli 0.164.0-alpha.11.1. Local-patch provenance has not been established, so I am not presenting this as a verified pristine upstream build.Observed failure
The user reports a third episode within 24 hours in which all local chats stopped with
workspace routing discovery timed out; the UI exhausted reconnect attempts through 5/5.Read-only OS measurements during the affected process lifetime:
The remaining direct children were two PowerShell processes, one console host, and one code-mode host. Other independently running CLI processes had roughly 21–27 threads. Samples are separate observations, not a synchronized performance trace.
The native Desktop tool host still answered
tools/listimmediately. Requests to read/list chats did not finish within bounded 16–30 second diagnostic limits. The usage-limit API also answered and explicitly allowed ordinary usage, so subscription exhaustion did not explain this episode.A separate local memory integration recorded a current-head read failure before sending its provider operation. That establishes a secondary integration failure, not that the integration caused the Desktop routing error.
Interpretation and limitations
The approximately 543-thread plateau, 253 retained children, and mostly waiting threads strongly match the blocking-pool mechanism described in this issue. We did not capture native worker stacks, and do not claim that every child or every timeout has been individually attributed.
A previous forced power-off was followed by loss of chat/project associations and lengthy recovery. That is an owner-reported recovery consequence; it does not prove the pool stall corrupted project state. We preserved valid global-state files and made an online SQLite backup before any further restart. Related persistence reports: #52713 and #56897.
Related same-version symptom report: #57063.
Recovery check, 26 October 2026
After a normal app exit and restart, the main backend had 71 OS threads instead of 543. The installed local current-head reader returned successfully in 0.407 seconds, with its worker reaped. All pre-restart chat/project associations were retained.
The installed CLI accepted
thread_unload_delay_secs = 300and rejected an invalid value type in an isolated configuration check. We applied the setting and added bounded process cleanup to the local Native bridge. Idle retention only applies to inactive, unsubscribed sessions; many subscribed transports can still accumulate.These checks establish immediate recovery. Long-term recurrence and the upstream parent-pipe fix remain open.
Is there a released Windows parent-pipe/IOCP fix or a supported way to cap retained transports for this Desktop backend generation?
WonderBug88 commentedon Oct 27, 2026
Additional independent Windows source qualification of the IOCP approach already described here, on public tag
rust-v0.164.0-alpha.11.1, commit6905ecede7816e91373e9eabda3f6b0368fc747b:spawn_blockingsentinel misses its one-second deadline. The reduced pool accelerates the mechanism; four helpers is not the normal Desktop limit.cargo check -p codex-rmcp-clientpasses on Windows GNU with Rust 1.99.1. The complete Desktop backend executable has not been built or deployed in this qualification.The candidate retains the existing parser and process-containment paths and is Windows-gated. It does not raise the blocking-worker limit or suppress stderr. We have source/test evidence ready, but this does not prove this mechanism explains every historical Desktop stall. There is no proof of an Android-app or Playwright-specific cause.
Deployment limitation: the installed Desktop package is 26.1021.3705.0. Its implemented
CODEX_CLI_PATHoverride also opts out of app-contained-core startup and removes registered-core/package-family environment markers from the child. We have not activated it or demonstrated equivalent containment for an unsigned custom build. No signed files, security controls, credentials, conversations or production databases were modified or copied for these tests.Is there a supported signed release or maintainer integration path for this Windows parent-pipe repair that preserves the packaged runtime and normal updates? If a source handoff is wanted, we can provide the scoped patch and portable fake-helper regression fixtures. We will not open an unsolicited code PR or work around Windows controls.
No raw logs, private paths, user/session identifiers, credentials, conversation contents or memory dumps are included in this comment.
kltyton commentedon Oct 30, 2026
A reusable Windows x64 repair package is available at https://github.com/kltyton/windows-mcp-runtime-repair, with installation instructions and a formal tool release: https://github.com/kltyton/windows-mcp-runtime-repair/releases/tag/v0.1.0.
The source patch uses overlapped named pipes / IOCP for parent-side local MCP stdio while retaining synchronous child standard handles and process lifecycle behavior. MCP capabilities and concurrency settings are preserved. Matching backend payloads are published for 0.165.0-alpha.1.2 and 0.163.0-alpha.10.2.
The desktop keeps its original entry. An internal version selector matches the launching application's backend, and a deployment-triggered task prepares supported updates from the runtime catalog. Helper programs and plugins come from the locally installed matching application package; Store binaries and user configuration are not redistributed.
BlackBadHope commentedon Oct 31, 2026
Follow-up to my 26.10 measurements: a working fix for the stdio MCP thread-pool exhaustion on Windows, running locally since 27.10.
What changed
Windows stdio reads for MCP servers no longer occupy a Tokio blocking-pool thread. The child's stdout/stderr pipes are opened for overlapped I/O, and reads complete through IOCP. A quiet MCP server now holds only a pending overlapped read, not a worker thread, so N idle servers can no longer starve
spawn_blocking.utils/pty/src/windows_async_stdio.rs(new): overlapped pipe pair (unique per-process name, DACL limited to the current user's token SID), async reader/writer adaptersutils/pty/src/child_command.rs,lib.rs,Cargo.toml: wire the overlapped pipes into child spawn on Windows (uuid,windows-sysfeatures)rmcp-client/src/{local_stdio_transport,bounded_stdio_transport,stdio_server_launcher}.rs: use the async stdio on Windows; non-Windows paths are unchangedutils/pty/examples/windows_async_stdio_probe.rs: standalone probe used for the tests belowBase:
6905ecede7816e91373e9eabda3f6b0368fc747b(rust-v0.164.0-alpha.11.1). 8 files, +331/−25.Test results (Windows, isolated bench)
Live use
Running in Codex Desktop
26.1021.3705.0since 27.10, using a self-built CLI from this patch and selected withCODEX_CLI_PATH. The Desktop install itself is unmodified, and unsetting the variable rolls back. An earlier build from 26.10 had a CRLF line-parsing bug on startup and was rolled back. That bug is fixed in this version.Limitations
mainhas changedrmcp-clientheavily (local_stdio_transport.rs,stdio_server_launcher.rs,bounded_stdio_transport.rs), so it does not apply tomainas-is. I don't see an IOCP/overlapped path onmainyet. I'm happy to rebase it into a PR if maintainers want this approach.iocp-fix.patch
fork: settle a delegated thread as soon as its task ends
fork: settle a delegated thread as soon as its task ends
fork: settle a delegated thread as soon as its task ends
fork: settle a delegated thread as soon as its task ends