app-server: box request dispatch future to reduce stack pressure#12421
Merged
charley-oai merged 1 commit intomainfrom Feb 23, 2026
Merged
app-server: box request dispatch future to reduce stack pressure#12421charley-oai merged 1 commit intomainfrom
charley-oai merged 1 commit intomainfrom
Conversation
Collaborator
Author
|
@codex review this |
Contributor
|
Codex Review: Didn't find any major issues. Delightful! ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
Contributor
|
Security review completed. No security issues were found in this pull request. ℹ️ About Codex security reviews in GitHubThis is an experimental Codex feature. Security reviews are triggered when:
Once complete, Codex will leave suggestions, or a comment if no findings are found. |
jif-oai
approved these changes
Feb 23, 2026
Collaborator
jif-oai
left a comment
There was a problem hiding this comment.
TLDR: you move the implicit chain from stack to heap. LGTM
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
CodexMessageProcessor::process_request(...)future insideMessageProcessor::process_request#11786Root Cause (high confidence)
I bisected
mainusing a deterministic low-stack repro and found the first bad commit:1f54496c48ffb9678095cc91d40556faa57c99fb—app-server: expose loaded thread status via read/list and notifications (#11786)Why that commit can trigger overflows:
MessageProcessor::process_requestis a largeasync fnthat sometimes delegates to the even largerCodexMessageProcessor::process_request.MessageProcessor::process_requestfuture type include the full delegated future state machine.#11786significantly grew the delegated future (new thread-status tracking + additional async work), which increased stack usage for the wrapper future enough to cross the threshold on smaller Tokio worker stacks.message_processor.rsand explains why even initialization-only paths became more stack-sensitive.Why This Fix
This is a small, behavior-preserving stack-footprint reduction at the source:
.boxed().await) in theother =>branch.CodexMessageProcessor::process_requestfuture state machine.This complements (but does not replace) the runtime worker stack-size mitigation already added in
codex-arg0.Validation
Local targeted tests (current branch)
just fmtcargo test -p codex-app-server --test all suite::user_agent::get_user_agent_returns_current_codex_user_agent -- --nocapturecargo test -p codex-app-server --test all suite::v2::review::review_start_with_detached_delivery_returns_new_thread_id -- --nocaptureDeterministic before/after repro on the culprit commit (
1f54496c48)I validated the patch directly against the bisected culprit commit in a throwaway worktree.
CARGO_TARGET_DIR=/tmp/codex-bisect-target RUST_MIN_STACK=2031616 cargo test -q -p codex-app-server --test all suite::v2::review::review_start_with_detached_delivery_returns_new_thread_id -- --nocapturetokio-runtime-workerstack overflow (fatal runtime error: stack overflow)ok)1f54496c48:codex-app-serverwith a minimalinitializerequest andRUST_MIN_STACK=294912tokio-runtime-workerstack overflowBisect result
git bisect(good=e00080cea, bad=d87cf7794) identified:1f54496c48ffb9678095cc91d40556faa57c99fbRisk
Low:
Codex author
codex resume 019c7e1f-4cd9-72b3-aa74-826e9d38c218