Skip to content

Commit

Permalink
win: move stack_overflow_warning to the backtrace fiber (#55640)
Browse files Browse the repository at this point in the history
There is not enough stack space remaining after a stack overflow on
Windows to allocate the 4k page used by `write` to call the WriteFile
syscall. This causes it to hard-crash. But we can simply run this on the
altstack implementation, where there is plenty of space.
  • Loading branch information
vtjnash authored Sep 3, 2024
1 parent 34b81fb commit eebc1e4
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/signals-win.c
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,8 @@ static jl_ptls_t stkerror_ptls;
static int have_backtrace_fiber;
static void JL_NORETURN start_backtrace_fiber(void)
{
// print the warning (this mysteriously needs a lot of stack for the WriteFile syscall)
stack_overflow_warning();
// collect the backtrace
stkerror_ptls->bt_size =
rec_backtrace_ctx(stkerror_ptls->bt_data, JL_MAX_BT_SIZE, stkerror_ctx,
Expand Down Expand Up @@ -244,7 +246,6 @@ LONG WINAPI jl_exception_handler(struct _EXCEPTION_POINTERS *ExceptionInfo)
case EXCEPTION_STACK_OVERFLOW:
if (ct->eh != NULL) {
ptls->needs_resetstkoflw = 1;
stack_overflow_warning();
jl_throw_in_ctx(ct, jl_stackovf_exception, ExceptionInfo->ContextRecord);
return EXCEPTION_CONTINUE_EXECUTION;
}
Expand Down

0 comments on commit eebc1e4

Please sign in to comment.