Repository navigation
Windows: fiber stack-overflow diagnostic + un-skip its test (#369) - #907
Merged
ehartford merged 1 commit intoSep 1, 2026
Merged
Conversation
ropoctl
force-pushed
the
fix-369-fiber-stack-overflow
branch
from
August 31, 2026 15:38
f512012 to
43e1d99
Compare
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.
ropoctl
force-pushed
the
fix-369-fiber-stack-overflow
branch
from
August 31, 2026 18:58
43e1d99 to
a86bed5
Compare
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.
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 ownmmap'd stack those fields are stale. Everything that consults them is then wrong on a fiber:__chkstkprobes (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.Changes
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 nosigaltstack; 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 reportsfiber stack overflowand exits 134.behav_async_fiber_large_frame.w(new) — a single frame larger than one page on a fiber, which forces__chkstkto probe against the fiber's stack bounds; returns normally on a correct backend. Portable and unremarkable off Windows.Both verified on a native Windows x64 host (overflow → exit 134 + diagnostic; large-frame → exit 0), and the large-frame test is also green natively on Linux.