// what to do on a critical error static void jl_critical_error(int sig, bt_context_t context, ptrint_t *bt_data, size_t *bt_size) { size_t n = *bt_size; if (sig) jl_safe_printf("\nsignal (%d): %s\n", sig, strsignal(sig)); jl_safe_printf("while loading %s, in expression starting on line %d\n", jl_filename, jl_lineno); if (context) *bt_size = n = rec_backtrace_ctx(bt_data, JL_MAX_BT_SIZE, context); for(size_t i=0; i < n; i++) gdblookup(bt_data[i]); gc_debug_print_status(); }
static LONG WINAPI _exception_handler(struct _EXCEPTION_POINTERS *ExceptionInfo, int in_ctx) { if (ExceptionInfo->ExceptionRecord->ExceptionFlags == 0) { switch (ExceptionInfo->ExceptionRecord->ExceptionCode) { case EXCEPTION_INT_DIVIDE_BY_ZERO: fpreset(); jl_throw_in_ctx(jl_diverror_exception, ExceptionInfo->ContextRecord,in_ctx); return EXCEPTION_CONTINUE_EXECUTION; case EXCEPTION_STACK_OVERFLOW: jl_throw_in_ctx(jl_stackovf_exception, ExceptionInfo->ContextRecord,in_ctx&&pSetThreadStackGuarantee); return EXCEPTION_CONTINUE_EXECUTION; } jl_safe_printf("\nPlease submit a bug report with steps to reproduce this fault, and any error messages that follow (in their entirety). Thanks.\nException: "); switch (ExceptionInfo->ExceptionRecord->ExceptionCode) { case EXCEPTION_ACCESS_VIOLATION: jl_safe_printf("EXCEPTION_ACCESS_VIOLATION"); break; case EXCEPTION_ARRAY_BOUNDS_EXCEEDED: jl_safe_printf("EXCEPTION_ARRAY_BOUNDS_EXCEEDED"); break; case EXCEPTION_BREAKPOINT: jl_safe_printf("EXCEPTION_BREAKPOINT"); break; case EXCEPTION_DATATYPE_MISALIGNMENT: jl_safe_printf("EXCEPTION_DATATYPE_MISALIGNMENT"); break; case EXCEPTION_FLT_DENORMAL_OPERAND: jl_safe_printf("EXCEPTION_FLT_DENORMAL_OPERAND"); break; case EXCEPTION_FLT_DIVIDE_BY_ZERO: jl_safe_printf("EXCEPTION_FLT_DIVIDE_BY_ZERO"); break; case EXCEPTION_FLT_INEXACT_RESULT: jl_safe_printf("EXCEPTION_FLT_INEXACT_RESULT"); break; case EXCEPTION_FLT_INVALID_OPERATION: jl_safe_printf("EXCEPTION_FLT_INVALID_OPERATION"); break; case EXCEPTION_FLT_OVERFLOW: jl_safe_printf("EXCEPTION_FLT_OVERFLOW"); break; case EXCEPTION_FLT_STACK_CHECK: jl_safe_printf("EXCEPTION_FLT_STACK_CHECK"); break; case EXCEPTION_FLT_UNDERFLOW: jl_safe_printf("EXCEPTION_FLT_UNDERFLOW"); break; case EXCEPTION_ILLEGAL_INSTRUCTION: jl_safe_printf("EXCEPTION_ILLEGAL_INSTRUCTION"); break; case EXCEPTION_IN_PAGE_ERROR: jl_safe_printf("EXCEPTION_IN_PAGE_ERROR"); break; case EXCEPTION_INT_DIVIDE_BY_ZERO: jl_safe_printf("EXCEPTION_INT_DIVIDE_BY_ZERO"); break; case EXCEPTION_INT_OVERFLOW: jl_safe_printf("EXCEPTION_INT_OVERFLOW"); break; case EXCEPTION_INVALID_DISPOSITION: jl_safe_printf("EXCEPTION_INVALID_DISPOSITION"); break; case EXCEPTION_NONCONTINUABLE_EXCEPTION: jl_safe_printf("EXCEPTION_NONCONTINUABLE_EXCEPTION"); break; case EXCEPTION_PRIV_INSTRUCTION: jl_safe_printf("EXCEPTION_PRIV_INSTRUCTION"); break; case EXCEPTION_SINGLE_STEP: jl_safe_printf("EXCEPTION_SINGLE_STEP"); break; case EXCEPTION_STACK_OVERFLOW: jl_safe_printf("EXCEPTION_STACK_OVERFLOW"); break; default: jl_safe_printf("UNKNOWN"); break; } jl_safe_printf(" at 0x%Ix -- ", (size_t)ExceptionInfo->ExceptionRecord->ExceptionAddress); gdblookup((ptrint_t)ExceptionInfo->ExceptionRecord->ExceptionAddress); bt_size = rec_backtrace_ctx(bt_data, MAX_BT_SIZE, ExceptionInfo->ContextRecord); jlbacktrace(); static int recursion = 0; if (recursion++) exit(1); else jl_exit(1); } return EXCEPTION_CONTINUE_SEARCH; }
static LONG WINAPI exception_handler(struct _EXCEPTION_POINTERS *ExceptionInfo) { if (ExceptionInfo->ExceptionRecord->ExceptionFlags == 0) { switch (ExceptionInfo->ExceptionRecord->ExceptionCode) { case EXCEPTION_STACK_OVERFLOW: #if defined(_CPU_X86_64_) ExceptionInfo->ContextRecord->Rip = (DWORD64)&win_raise_exception; ExceptionInfo->ContextRecord->Rcx = (DWORD64)jl_stackovf_exception; ExceptionInfo->ContextRecord->Rsp &= (DWORD64)-16; ExceptionInfo->ContextRecord->Rsp -= 8; //fix up the stack pointer -- this seems to be correct by observation #elif defined(_CPU_X86_) ExceptionInfo->ContextRecord->Eip = (DWORD)&win_raise_exception; ExceptionInfo->ContextRecord->Ecx = (DWORD)jl_stackovf_exception; ExceptionInfo->ContextRecord->Esp &= (DWORD)-16; ExceptionInfo->ContextRecord->Esp -= 4; //fix up the stack pointer #else #error WIN16 not supported :P #endif return EXCEPTION_CONTINUE_EXECUTION; default: ios_puts("Please submit a bug report with steps to reproduce this fault, and any error messages that follow (in their entirety). Thanks.\nException: ", ios_stderr); switch (ExceptionInfo->ExceptionRecord->ExceptionCode) { case EXCEPTION_ACCESS_VIOLATION: ios_puts("EXCEPTION_ACCESS_VIOLATION", ios_stderr); break; case EXCEPTION_ARRAY_BOUNDS_EXCEEDED: ios_puts("EXCEPTION_ARRAY_BOUNDS_EXCEEDED", ios_stderr); break; case EXCEPTION_BREAKPOINT: ios_puts("EXCEPTION_BREAKPOINT", ios_stderr); break; case EXCEPTION_DATATYPE_MISALIGNMENT: ios_puts("EXCEPTION_DATATYPE_MISALIGNMENT", ios_stderr); break; case EXCEPTION_FLT_DENORMAL_OPERAND: ios_puts("EXCEPTION_FLT_DENORMAL_OPERAND", ios_stderr); break; case EXCEPTION_FLT_DIVIDE_BY_ZERO: ios_puts("EXCEPTION_FLT_DIVIDE_BY_ZERO", ios_stderr); break; case EXCEPTION_FLT_INEXACT_RESULT: ios_puts("EXCEPTION_FLT_INEXACT_RESULT", ios_stderr); break; case EXCEPTION_FLT_INVALID_OPERATION: ios_puts("EXCEPTION_FLT_INVALID_OPERATION", ios_stderr); break; case EXCEPTION_FLT_OVERFLOW: ios_puts("EXCEPTION_FLT_OVERFLOW", ios_stderr); break; case EXCEPTION_FLT_STACK_CHECK: ios_puts("EXCEPTION_FLT_STACK_CHECK", ios_stderr); break; case EXCEPTION_FLT_UNDERFLOW: ios_puts("EXCEPTION_FLT_UNDERFLOW", ios_stderr); break; case EXCEPTION_ILLEGAL_INSTRUCTION: ios_puts("EXCEPTION_ILLEGAL_INSTRUCTION", ios_stderr); break; case EXCEPTION_IN_PAGE_ERROR: ios_puts("EXCEPTION_IN_PAGE_ERROR", ios_stderr); break; case EXCEPTION_INT_DIVIDE_BY_ZERO: ios_puts("EXCEPTION_INT_DIVIDE_BY_ZERO", ios_stderr); break; case EXCEPTION_INT_OVERFLOW: ios_puts("EXCEPTION_INT_OVERFLOW", ios_stderr); break; case EXCEPTION_INVALID_DISPOSITION: ios_puts("EXCEPTION_INVALID_DISPOSITION", ios_stderr); break; case EXCEPTION_NONCONTINUABLE_EXCEPTION: ios_puts("EXCEPTION_NONCONTINUABLE_EXCEPTION", ios_stderr); break; case EXCEPTION_PRIV_INSTRUCTION: ios_puts("EXCEPTION_PRIV_INSTRUCTION", ios_stderr); break; case EXCEPTION_SINGLE_STEP: ios_puts("EXCEPTION_SINGLE_STEP", ios_stderr); break; case EXCEPTION_STACK_OVERFLOW: ios_puts("EXCEPTION_STACK_OVERFLOW", ios_stderr); break; default: ios_puts("UNKNOWN", ios_stderr); break; } ios_printf(ios_stderr," at 0x%Ix -- ", (size_t)ExceptionInfo->ExceptionRecord->ExceptionAddress); gdblookup((ptrint_t)ExceptionInfo->ExceptionRecord->ExceptionAddress); bt_size = rec_backtrace_ctx(bt_data, MAX_BT_SIZE, ExceptionInfo->ContextRecord); jlbacktrace(); break; } } return EXCEPTION_CONTINUE_SEARCH; }
static LONG WINAPI exception_handler(struct _EXCEPTION_POINTERS *ExceptionInfo) { if (ExceptionInfo->ExceptionRecord->ExceptionFlags == 0) { switch (ExceptionInfo->ExceptionRecord->ExceptionCode) { case EXCEPTION_STACK_OVERFLOW: jl_throw_in_ctx(jl_stackovf_exception, ExceptionInfo->ContextRecord, 0); return EXCEPTION_CONTINUE_EXECUTION; default: ios_puts("Please submit a bug report with steps to reproduce this fault, and any error messages that follow (in their entirety). Thanks.\nException: ", ios_stderr); switch (ExceptionInfo->ExceptionRecord->ExceptionCode) { case EXCEPTION_ACCESS_VIOLATION: ios_puts("EXCEPTION_ACCESS_VIOLATION", ios_stderr); break; case EXCEPTION_ARRAY_BOUNDS_EXCEEDED: ios_puts("EXCEPTION_ARRAY_BOUNDS_EXCEEDED", ios_stderr); break; case EXCEPTION_BREAKPOINT: ios_puts("EXCEPTION_BREAKPOINT", ios_stderr); break; case EXCEPTION_DATATYPE_MISALIGNMENT: ios_puts("EXCEPTION_DATATYPE_MISALIGNMENT", ios_stderr); break; case EXCEPTION_FLT_DENORMAL_OPERAND: ios_puts("EXCEPTION_FLT_DENORMAL_OPERAND", ios_stderr); break; case EXCEPTION_FLT_DIVIDE_BY_ZERO: ios_puts("EXCEPTION_FLT_DIVIDE_BY_ZERO", ios_stderr); break; case EXCEPTION_FLT_INEXACT_RESULT: ios_puts("EXCEPTION_FLT_INEXACT_RESULT", ios_stderr); break; case EXCEPTION_FLT_INVALID_OPERATION: ios_puts("EXCEPTION_FLT_INVALID_OPERATION", ios_stderr); break; case EXCEPTION_FLT_OVERFLOW: ios_puts("EXCEPTION_FLT_OVERFLOW", ios_stderr); break; case EXCEPTION_FLT_STACK_CHECK: ios_puts("EXCEPTION_FLT_STACK_CHECK", ios_stderr); break; case EXCEPTION_FLT_UNDERFLOW: ios_puts("EXCEPTION_FLT_UNDERFLOW", ios_stderr); break; case EXCEPTION_ILLEGAL_INSTRUCTION: ios_puts("EXCEPTION_ILLEGAL_INSTRUCTION", ios_stderr); break; case EXCEPTION_IN_PAGE_ERROR: ios_puts("EXCEPTION_IN_PAGE_ERROR", ios_stderr); break; case EXCEPTION_INT_DIVIDE_BY_ZERO: ios_puts("EXCEPTION_INT_DIVIDE_BY_ZERO", ios_stderr); break; case EXCEPTION_INT_OVERFLOW: ios_puts("EXCEPTION_INT_OVERFLOW", ios_stderr); break; case EXCEPTION_INVALID_DISPOSITION: ios_puts("EXCEPTION_INVALID_DISPOSITION", ios_stderr); break; case EXCEPTION_NONCONTINUABLE_EXCEPTION: ios_puts("EXCEPTION_NONCONTINUABLE_EXCEPTION", ios_stderr); break; case EXCEPTION_PRIV_INSTRUCTION: ios_puts("EXCEPTION_PRIV_INSTRUCTION", ios_stderr); break; case EXCEPTION_SINGLE_STEP: ios_puts("EXCEPTION_SINGLE_STEP", ios_stderr); break; case EXCEPTION_STACK_OVERFLOW: ios_puts("EXCEPTION_STACK_OVERFLOW", ios_stderr); break; default: ios_puts("UNKNOWN", ios_stderr); break; } ios_printf(ios_stderr," at 0x%Ix -- ", (size_t)ExceptionInfo->ExceptionRecord->ExceptionAddress); gdblookup((ptrint_t)ExceptionInfo->ExceptionRecord->ExceptionAddress); bt_size = rec_backtrace_ctx(bt_data, MAX_BT_SIZE, ExceptionInfo->ContextRecord); jlbacktrace(); break; } } return EXCEPTION_CONTINUE_SEARCH; }