Windows: Add additional crash diagnostic information.
authorRay Molenkamp <github@lazydodo.com>
Tue, 7 Nov 2017 14:57:59 +0000 (07:57 -0700)
committerRay Molenkamp <github@lazydodo.com>
Tue, 7 Nov 2017 14:57:59 +0000 (07:57 -0700)
To help diagnose issues like T53259, it is useful to know the module causing the issue (is it us, or some opengl icd, or python module?) and while we cannot do stackdumps on release builds on windows, it is possible to display the faulting module. This commit changes the exception handler to output the following information:

Error   : EXCEPTION_ACCESS_VIOLATION (Type of exception , this we had before)
Address : 0x0000000140193726 (Address of the exception, new)
Module  : k:\BlenderGit\build_windows_Full_noge_x64_vc15_Release\bin\Release\blender.exe (module of the exception, new)

source/creator/creator_signals.c

index 80aba76..81e6178 100644 (file)
@@ -188,67 +188,67 @@ LONG WINAPI windows_exception_handler(EXCEPTION_POINTERS *ExceptionInfo)
 {
        switch (ExceptionInfo->ExceptionRecord->ExceptionCode) {
                case EXCEPTION_ACCESS_VIOLATION:
-                       fputs("Error: EXCEPTION_ACCESS_VIOLATION\n", stderr);
+                       fputs("Error   : EXCEPTION_ACCESS_VIOLATION\n", stderr);
                        break;
                case EXCEPTION_ARRAY_BOUNDS_EXCEEDED:
-                       fputs("Error: EXCEPTION_ARRAY_BOUNDS_EXCEEDED\n", stderr);
+                       fputs("Error   : EXCEPTION_ARRAY_BOUNDS_EXCEEDED\n", stderr);
                        break;
                case EXCEPTION_BREAKPOINT:
-                       fputs("Error: EXCEPTION_BREAKPOINT\n", stderr);
+                       fputs("Error   : EXCEPTION_BREAKPOINT\n", stderr);
                        break;
                case EXCEPTION_DATATYPE_MISALIGNMENT:
-                       fputs("Error: EXCEPTION_DATATYPE_MISALIGNMENT\n", stderr);
+                       fputs("Error   : EXCEPTION_DATATYPE_MISALIGNMENT\n", stderr);
                        break;
                case EXCEPTION_FLT_DENORMAL_OPERAND:
-                       fputs("Error: EXCEPTION_FLT_DENORMAL_OPERAND\n", stderr);
+                       fputs("Error   : EXCEPTION_FLT_DENORMAL_OPERAND\n", stderr);
                        break;
                case EXCEPTION_FLT_DIVIDE_BY_ZERO:
-                       fputs("Error: EXCEPTION_FLT_DIVIDE_BY_ZERO\n", stderr);
+                       fputs("Error   : EXCEPTION_FLT_DIVIDE_BY_ZERO\n", stderr);
                        break;
                case EXCEPTION_FLT_INEXACT_RESULT:
-                       fputs("Error: EXCEPTION_FLT_INEXACT_RESULT\n", stderr);
+                       fputs("Error   : EXCEPTION_FLT_INEXACT_RESULT\n", stderr);
                        break;
                case EXCEPTION_FLT_INVALID_OPERATION:
-                       fputs("Error: EXCEPTION_FLT_INVALID_OPERATION\n", stderr);
+                       fputs("Error   : EXCEPTION_FLT_INVALID_OPERATION\n", stderr);
                        break;
                case EXCEPTION_FLT_OVERFLOW:
-                       fputs("Error: EXCEPTION_FLT_OVERFLOW\n", stderr);
+                       fputs("Error   : EXCEPTION_FLT_OVERFLOW\n", stderr);
                        break;
                case EXCEPTION_FLT_STACK_CHECK:
-                       fputs("Error: EXCEPTION_FLT_STACK_CHECK\n", stderr);
+                       fputs("Error   : EXCEPTION_FLT_STACK_CHECK\n", stderr);
                        break;
                case EXCEPTION_FLT_UNDERFLOW:
-                       fputs("Error: EXCEPTION_FLT_UNDERFLOW\n", stderr);
+                       fputs("Error   : EXCEPTION_FLT_UNDERFLOW\n", stderr);
                        break;
                case EXCEPTION_ILLEGAL_INSTRUCTION:
-                       fputs("Error: EXCEPTION_ILLEGAL_INSTRUCTION\n", stderr);
+                       fputs("Error   : EXCEPTION_ILLEGAL_INSTRUCTION\n", stderr);
                        break;
                case EXCEPTION_IN_PAGE_ERROR:
-                       fputs("Error: EXCEPTION_IN_PAGE_ERROR\n", stderr);
+                       fputs("Error   : EXCEPTION_IN_PAGE_ERROR\n", stderr);
                        break;
                case EXCEPTION_INT_DIVIDE_BY_ZERO:
-                       fputs("Error: EXCEPTION_INT_DIVIDE_BY_ZERO\n", stderr);
+                       fputs("Error   : EXCEPTION_INT_DIVIDE_BY_ZERO\n", stderr);
                        break;
                case EXCEPTION_INT_OVERFLOW:
-                       fputs("Error: EXCEPTION_INT_OVERFLOW\n", stderr);
+                       fputs("Error   : EXCEPTION_INT_OVERFLOW\n", stderr);
                        break;
                case EXCEPTION_INVALID_DISPOSITION:
-                       fputs("Error: EXCEPTION_INVALID_DISPOSITION\n", stderr);
+                       fputs("Error   : EXCEPTION_INVALID_DISPOSITION\n", stderr);
                        break;
                case EXCEPTION_NONCONTINUABLE_EXCEPTION:
-                       fputs("Error: EXCEPTION_NONCONTINUABLE_EXCEPTION\n", stderr);
+                       fputs("Error   : EXCEPTION_NONCONTINUABLE_EXCEPTION\n", stderr);
                        break;
                case EXCEPTION_PRIV_INSTRUCTION:
-                       fputs("Error: EXCEPTION_PRIV_INSTRUCTION\n", stderr);
+                       fputs("Error   : EXCEPTION_PRIV_INSTRUCTION\n", stderr);
                        break;
                case EXCEPTION_SINGLE_STEP:
-                       fputs("Error: EXCEPTION_SINGLE_STEP\n", stderr);
+                       fputs("Error   : EXCEPTION_SINGLE_STEP\n", stderr);
                        break;
                case EXCEPTION_STACK_OVERFLOW:
-                       fputs("Error: EXCEPTION_STACK_OVERFLOW\n", stderr);
+                       fputs("Error   : EXCEPTION_STACK_OVERFLOW\n", stderr);
                        break;
                default:
-                       fputs("Error: Unrecognized Exception\n", stderr);
+                       fputs("Error   : Unrecognized Exception\n", stderr);
                        break;
        }
 
@@ -257,6 +257,19 @@ LONG WINAPI windows_exception_handler(EXCEPTION_POINTERS *ExceptionInfo)
        /* If this is a stack overflow then we can't walk the stack, so just show
         * where the error happened */
        if (EXCEPTION_STACK_OVERFLOW != ExceptionInfo->ExceptionRecord->ExceptionCode) {
+               HMODULE mod;
+               CHAR modulename[MAX_PATH];
+               LPVOID address = ExceptionInfo->ExceptionRecord->ExceptionAddress;
+
+               fprintf(stderr, "Address : 0x%p\n", address);
+               if (GetModuleHandleEx(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS, address, &mod)) {
+                       if (GetModuleFileName(mod, modulename, MAX_PATH)) {
+                               fprintf(stderr, "Module  : %s\n", modulename);
+                       }
+               }
+
+               fflush(stderr);
+
 #ifdef NDEBUG
                TerminateProcess(GetCurrentProcess(), SIGSEGV);
 #else