Repository navigation
omega: give Windows console programs the stack their frames need - #6318
Merged
Merged
Conversation
…f crashing Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HqP8t5W646wL2ZiV2agFaj
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HqP8t5W646wL2ZiV2agFaj
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Requested by Jarod · project thread
A Windows program that writes to the console now gets a stack big enough for
its checked frames. Before, a windows_x86_64 program with a local record
holding a 2 MB array compiled cleanly and then crashed with
STATUS_STACK_OVERFLOW (0xC00000FD). A console write is a host import, so the
program runs on the loader's stack, and every image reserved exactly 1 MiB of
it. Nothing compared the checked frames against that supply. The PE writer now
sets
SizeOfStackReserveto the frames plus 64 KiB of headroom, rounded up to64 KiB and never below 1 MiB, so the repro reserves 2 MiB and runs. No build
setting is involved.
entry_roots.mdsays ordinary build files do not choosestack size, so the compiler sizes the reserve from the WCSU it has already
checked.
On macOS the main thread gets a fixed 8 MiB whatever the image holds, so a
larger frame there is refused at build time with its call path:
Linux programs make no host imports. They already run on an owned BSS stack
sized to their demand, and a 12 MB frame runs there today.
NativeTarget::loader_stack_supply_bytes(frame_bytes)gives the supply. ForWindows it computes the reserve, and for Linux and macOS it returns the fixed
8 MiB default.
plan_hosted_program_entry(stage 09) checks the frames againstthat supply when it picks
HostedEntryMode::LoaderStack. Image emission passesthe same reserve to
emit_pe_executable. A shared component keeps 1 MiB. The64 KiB headroom covers frames the checked demand cannot see: the loader's own,
the entry adapter, guard pages and the host imports'.
StackDemandnowrecords
peak_path, the internal calls whose frames set the ceiling. Theerror shows machine numbers, as other native diagnostics do, because the
native pipeline does not carry source names.
The new
loader_stack_supplytest builds a windows_x86_64 program with a 2 MBrecord and one with a 512 KB record. It checks that their images reserve 2 MiB
and 1 MiB. It also checks that a 9 MB record on macos_arm64 is refused with the
call-path message. A
native-stack-demandunit test checks the peak path.Gate: RC-NATIVE-MATRIX | hosted entries get a loader stack that fits their checked frames, or a refusal naming the call path
Spec: wiki/spec/build/entry_roots.md, wiki/spec/resources/storage.md#stack-demand-and-backing | the reserve comes from WCSU, not a build setting; insufficient fixed supply reports the call path
Proof:
mbx test -p omega --test loader_stack_supply2/2;-p native-stack-demand,-p entry-planning,-p target,-p image-pe,-p image-emissionpass; 30 of the application tests that build for Windows fail in the cloud container, and none of their failures mention the loader stack | the Windows repro builds with a 2 MiB reservembx xtask fmt --check --base origin/mainis clean.mbx clippy --all-targets --no-deps -- -D warningsis clean on the five changed crates and the new test.🤖 Generated with Claude Code
https://claude.ai/code/session_01HqP8t5W646wL2ZiV2agFaj
Agent: Claude Code | Model: claude-opus-5-5 | Effort: medium | Tokens: 129.58M in (128.75M cached), 256.1k out | Steps: 586 | Time: 2h46m | Steers: 0