Repository navigation
Windows: fiber stack-overflow diagnostic via VEH; un-skip #369 - #850
Merged
Merged
Conversation
…er (withlang-dev#369) The POSIX fiber core catches guard-page stack overflow with a SIGSEGV handler on a sigaltstack. Windows has no POSIX signals, so a guard-page fault surfaces as a Structured Exception. Bridge it: - allocate_stack_region arms the guard page with PAGE_GUARD via VirtualProtect. PAGE_GUARD raises STATUS_GUARD_PAGE_VIOLATION on first touch and auto-commits the page, giving the handler stack room — the Windows analogue of the POSIX sigaltstack. - rt_fiber_install_signal_handlers registers a vectored exception handler (AddVectoredExceptionHandler). with_fiber_veh reads EXCEPTION_POINTERS, matches STATUS_GUARD_PAGE_VIOLATION / access-violation against the current fiber's guard region, prints 'fatal: fiber stack overflow (fiber #N)' and exits 134 — matching the POSIX diagnostic and the unified panic-exit convention. Un-skips test/behavior/behav_async_stack_overflow.w on Windows.
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.
Implements the Windows side of the fiber stack-overflow diagnostic and un-skips
test/behavior/behav_async_stack_overflow.w.Problem
The POSIX fiber core (
rt/fiber_core_darwin.w) catches guard-page stack overflow with a SIGSEGV handler on a sigaltstack. Windows has no POSIX signals, so a guard-page fault surfaces as a Structured Exception — the existingrt_fiber_install_signal_handlerswas a no-op stub and the guard page was never armed, so an overflowing fiber just crashed without the diagnostic. That is why #369 wasskip-windows.Fix (
rt/windows_x86_64.w,rt/fiber_core_windows.w)allocate_stack_regionnow callsVirtualProtect(region, page, PAGE_READWRITE | PAGE_GUARD).PAGE_GUARDraisesSTATUS_GUARD_PAGE_VIOLATIONon first touch and auto-commits the page, giving the handler real stack to run on — the Windows analogue of the POSIX sigaltstack.rt_fiber_install_signal_handlerscallsAddVectoredExceptionHandler.with_fiber_vehreadsEXCEPTION_POINTERS, matchesSTATUS_GUARD_PAGE_VIOLATION/ access-violation against the current fiber's guard region, printsfatal: fiber stack overflow (fiber #N)and exits 134 — matching the POSIX diagnostic text and the unified panic-exit convention (Valid program with passing asserts can abort with exit 134 while printf-based equivalent exits 0 #59).Verification
Windows CI builds stage1→stage3 from source (the stage compilers embed this runtime) and runs
build :testwith the test un-skipped:behav_async_stack_overflow.wrecurses on a 16 KiB fiber stack and assertsexpect-exit: 134/expect-stderr: fiber stack overflow.Closes #369.