Skip to content

Commit 8d84ffd

Browse files
committed
Enable coredumps on Windows
This commit provides two pieces; first, it enables building libuv with `SIGQUIT` support on Windows (useful for [0]), and second it enables coredumping when exceptions are hit, after our exception handler has finished printing out a backtrace. This is useful for using WER to create dump files when we segfault, etc... This commit requires libuv PRs [1] and [2] to properly function. [0] #45864 [1] JuliaLang/libuv#30 [2] JuliaLang/libuv#31
1 parent 83592cf commit 8d84ffd

File tree

2 files changed

+18
-6
lines changed

2 files changed

+18
-6
lines changed

Make.inc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1300,7 +1300,7 @@ endif
13001300
ifeq ($(OS), WINNT)
13011301
HAVE_SSP := 1
13021302
OSLIBS += -Wl,--export-all-symbols -Wl,--version-script=$(JULIAHOME)/src/julia.expmap \
1303-
$(NO_WHOLE_ARCHIVE) -lpsapi -lkernel32 -lws2_32 -liphlpapi -lwinmm -ldbghelp -luserenv -lsecur32 -latomic
1303+
$(NO_WHOLE_ARCHIVE) -lpsapi -lkernel32 -lws2_32 -liphlpapi -lwinmm -ldbghelp -luserenv -lsecur32 -latomic -ldbghelp -lshell32 -lole32 -luuid
13041304
JLDFLAGS += -Wl,--stack,8388608
13051305
ifeq ($(ARCH),i686)
13061306
JLDFLAGS += -Wl,--large-address-aware

src/signals-win.c

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,19 @@ LONG WINAPI jl_exception_handler(struct _EXCEPTION_POINTERS *ExceptionInfo)
277277
break;
278278
}
279279
}
280+
static int thread0_exit_count = 0;
281+
SetUnhandledExceptionFilter(NULL);
282+
thread0_exit_count++;
283+
uv_tty_reset_mode();
284+
fflush(NULL);
285+
286+
if (thread0_exit_count > 1) {
287+
// This should not return
288+
RaiseFailFastException(ExceptionInfo->ExceptionRecord, ExceptionInfo->ContextRecord, 0);
289+
jl_safe_printf("Unexpected return from RaiseFailFastException()!\n");
290+
return EXCEPTION_CONTINUE_SEARCH;
291+
}
292+
280293
if (ExceptionInfo->ExceptionRecord->ExceptionCode == EXCEPTION_ILLEGAL_INSTRUCTION) {
281294
jl_safe_printf("\n");
282295
jl_show_sigill(ExceptionInfo->ContextRecord);
@@ -330,11 +343,10 @@ LONG WINAPI jl_exception_handler(struct _EXCEPTION_POINTERS *ExceptionInfo)
330343
jl_print_native_codeloc((uintptr_t)ExceptionInfo->ExceptionRecord->ExceptionAddress);
331344

332345
jl_critical_error(0, 0, ExceptionInfo->ContextRecord, ct);
333-
static int recursion = 0;
334-
if (recursion++)
335-
exit(1);
336-
else
337-
jl_exit(1);
346+
jl_atexit_hook(128);
347+
RaiseFailFastException(ExceptionInfo->ExceptionRecord, ExceptionInfo->ContextRecord, 0);
348+
jl_safe_printf("Unexpected return from RaiseFailFastException()!\n");
349+
return EXCEPTION_CONTINUE_SEARCH;
338350
}
339351

340352
JL_DLLEXPORT void jl_install_sigint_handler(void)

0 commit comments

Comments
 (0)