Print a stack trace on unexpected term signal (e.g. SIGABRT)
For OSX and Linux, add a signal handler to SIGABRT, SGIFPE, SIGILL, SIGSEGV, and SIGBUS. When the program terminates unexpectedly the handler will print the current stack to the terminal to help determine the location of the failure. On OSX the output will look like: ``` Stack trace: 4 zstd 0x000000010927ed96 main + 16886 5 libdyld.dylib 0x00007fff767d1015 start + 1 6 ??? 0x0000000000000001 0x0 + 1 ``` On Linux the output will look like: ``` Stack trace: ./zstd() [0x4b8e1b] ./zstd() [0x4b928a] ./zstd() [0x403dc2] /lib64/libc.so.6(__libc_start_main+0xf5) [0x7f5e0fbb0445] ./zstd() [0x405754] ``` As is, the code does not function on WIN32. See also: https://oroboro.com/stack-trace-on-crash/
This commit is contained in:
+1
-1
@@ -157,7 +157,7 @@ static void clearHandler(void)
|
||||
}
|
||||
|
||||
|
||||
/* ************************************************************
|
||||
/*-************************************************************
|
||||
* Avoid fseek()'s 2GiB barrier with MSVC, macOS, *BSD, MinGW
|
||||
***************************************************************/
|
||||
#if defined(_MSC_VER) && _MSC_VER >= 1400
|
||||
|
||||
Reference in New Issue
Block a user