exec-server: preserve fs helper CoreFoundation env#25118
Merged
Conversation
bolinfest
approved these changes
May 29, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
__CF_USER_TEXT_ENCODINGwhen launching the sandboxed fs helperHOMEDiagnosis
The sandboxed fs helper is not launched like a normal child process. Exec-server rebuilds its environment from an allowlist, then calls
env_clear()before re-execing Codex with--codex-run-as-fs-helper. That helper dispatches before the normal Codex startup path and only needs to boot a small Tokio runtime, read one JSON request from stdin, perform the direct filesystem operation, and write one JSON response.The reported macOS hang sampled the helper before Rust main, in CoreFoundation initialization while resolving the default text encoding:
_CFStringGetUserDefaultEncoding -> getpwuid_r -> notify_register_check -> bootstrap_look_up3 -> mach_msg2_trap. The fs-helper allowlist keptPATHand temp vars for runtime needs, but it dropped macOS__CF_USER_TEXT_ENCODING. Other Codex subprocess launchers that intentionally build a minimal Unix baseline, such as MCP stdio, already preserve that variable.My read is that stripping
__CF_USER_TEXT_ENCODINGforced this internal helper down CoreFoundation's fallback user-lookup path, and that lookup intermittently wedged on the affected machine before the helper could read stdin or touch the target file. Preserving only this macOS startup variable avoids that fallback without broadening the fs-helper environment to shell-like vars such asHOME,USER, locale settings, terminal settings, or proxy credentials.Internal Slack thread omitted from the public PR body.
Validation
cd codex-rs && just fmtgit diff --check