Skip to content

Commit 641748b

Browse files
vtjnashKristofferC
authored andcommitted
win: move stack_overflow_warning to the backtrace fiber (#55640)
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.
1 parent 722657d commit 641748b

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/signals-win.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,8 @@ static jl_ptls_t stkerror_ptls;
109109
static int have_backtrace_fiber;
110110
static void JL_NORETURN start_backtrace_fiber(void)
111111
{
112+
// print the warning (this mysteriously needs a lot of stack for the WriteFile syscall)
113+
stack_overflow_warning();
112114
// collect the backtrace
113115
stkerror_ptls->bt_size =
114116
rec_backtrace_ctx(stkerror_ptls->bt_data, JL_MAX_BT_SIZE, stkerror_ctx,
@@ -244,7 +246,6 @@ LONG WINAPI jl_exception_handler(struct _EXCEPTION_POINTERS *ExceptionInfo)
244246
case EXCEPTION_STACK_OVERFLOW:
245247
if (ct->eh != NULL) {
246248
ptls->needs_resetstkoflw = 1;
247-
stack_overflow_warning();
248249
jl_throw_in_ctx(ct, jl_stackovf_exception, ExceptionInfo->ContextRecord);
249250
return EXCEPTION_CONTINUE_EXECUTION;
250251
}

0 commit comments

Comments
 (0)