Skip to content

Commit

Permalink
Enable coredumps on Windows
Browse files Browse the repository at this point in the history
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
  • Loading branch information
staticfloat committed Nov 17, 2022
1 parent 83592cf commit 8d84ffd
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Make.inc
Original file line number Diff line number Diff line change
Expand Up @@ -1300,7 +1300,7 @@ endif
ifeq ($(OS), WINNT)
HAVE_SSP := 1
OSLIBS += -Wl,--export-all-symbols -Wl,--version-script=$(JULIAHOME)/src/julia.expmap \
$(NO_WHOLE_ARCHIVE) -lpsapi -lkernel32 -lws2_32 -liphlpapi -lwinmm -ldbghelp -luserenv -lsecur32 -latomic
$(NO_WHOLE_ARCHIVE) -lpsapi -lkernel32 -lws2_32 -liphlpapi -lwinmm -ldbghelp -luserenv -lsecur32 -latomic -ldbghelp -lshell32 -lole32 -luuid
JLDFLAGS += -Wl,--stack,8388608
ifeq ($(ARCH),i686)
JLDFLAGS += -Wl,--large-address-aware
Expand Down
22 changes: 17 additions & 5 deletions src/signals-win.c
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,19 @@ LONG WINAPI jl_exception_handler(struct _EXCEPTION_POINTERS *ExceptionInfo)
break;
}
}
static int thread0_exit_count = 0;
SetUnhandledExceptionFilter(NULL);
thread0_exit_count++;
uv_tty_reset_mode();
fflush(NULL);

if (thread0_exit_count > 1) {
// This should not return
RaiseFailFastException(ExceptionInfo->ExceptionRecord, ExceptionInfo->ContextRecord, 0);
jl_safe_printf("Unexpected return from RaiseFailFastException()!\n");
return EXCEPTION_CONTINUE_SEARCH;
}

if (ExceptionInfo->ExceptionRecord->ExceptionCode == EXCEPTION_ILLEGAL_INSTRUCTION) {
jl_safe_printf("\n");
jl_show_sigill(ExceptionInfo->ContextRecord);
Expand Down Expand Up @@ -330,11 +343,10 @@ LONG WINAPI jl_exception_handler(struct _EXCEPTION_POINTERS *ExceptionInfo)
jl_print_native_codeloc((uintptr_t)ExceptionInfo->ExceptionRecord->ExceptionAddress);

jl_critical_error(0, 0, ExceptionInfo->ContextRecord, ct);
static int recursion = 0;
if (recursion++)
exit(1);
else
jl_exit(1);
jl_atexit_hook(128);
RaiseFailFastException(ExceptionInfo->ExceptionRecord, ExceptionInfo->ContextRecord, 0);
jl_safe_printf("Unexpected return from RaiseFailFastException()!\n");
return EXCEPTION_CONTINUE_SEARCH;
}

JL_DLLEXPORT void jl_install_sigint_handler(void)
Expand Down

0 comments on commit 8d84ffd

Please sign in to comment.