Repository navigation
Windows: fiber stack-overflow diagnostic + un-skip its test (#369) - #917
Merged
Merged
Conversation
On Windows x64 a running fiber must own the thread's stack description. The NT_TIB fields in the TEB (StackBase, StackLimit, DeallocationStack, FiberData) describe the OS thread stack; while a fiber runs on its own mmap'd stack they are stale. Everything that consults them is then wrong on a fiber: __chkstk probes (any frame over one page), and SEH/VEH dispatch. A guard-page fault on the fiber stack degraded to an unhandled access violation before the vectored handler could attribute it, so the "fiber stack overflow" diagnostic never printed. runtime/fiber_asm_windows_x86_64.s: the context switch now saves the four NT_TIB stack fields into the outgoing context and installs the incoming context's fields into the TEB, so the OS sees the fiber's real bounds. Initial-context setup seeds those fields for the first switch in. rt/fiber_core_windows.w: reserve committed headroom below the guard page. Windows has no sigaltstack; the vectored handler runs on the faulting fiber stack, so it needs room beneath the guard to produce the diagnostic and exit 134. Tests: - behav_async_stack_overflow.w: un-skipped on Windows; deep recursion on a small fiber stack now reports "fiber stack overflow" and exits 134. - behav_async_fiber_large_frame.w (new): a single >1-page frame on a fiber, which forces __chkstk to probe against the fiber's stack bounds; returns normally on a correct backend. Portable; unremarkable off Windows. Both verified on a native Windows x64 host.
ehartford
approved these changes
Sep 1, 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 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.
Re-lands the #369 Windows fiber stack-overflow diagnostic on current
main.The original PR #907 was merged into the interim stacking base branch
fix-compiler-main-source-budget(now stale — based on pre-rfc4648 main), so the change never reachedmain. This is the same commit rebased onto currentmain(31f77937); the interim CRLF-budget fix commit drops out by patch-id (already in main via #910).Windows-x86_64 only: adds VEH-based headroom below the fiber guard page so a stack overflow on a small fiber stack raises the
fiber stack overflowdiagnostic (exit 134), plus a large-frame regression test, and un-skipsbehav_async_stack_overflow.