Skip to content

Commit

Permalink
DPL: improve crash reason message (#12404)
Browse files Browse the repository at this point in the history
  • Loading branch information
ktf authored Dec 6, 2023
1 parent 57e9e81 commit d4d2179
Showing 1 changed file with 8 additions and 17 deletions.
25 changes: 8 additions & 17 deletions Framework/Core/src/runDataProcessing.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -578,31 +578,22 @@ void handle_crash(int sig)
{
// dump demangled stack trace
void* array[1024];

int size = backtrace(array, 1024);

{
char const* msg = "*** Program crashed (Segmentation fault, FPE, BUS, ABRT, KILL, Unhandled Exception, ...)\nBacktrace by DPL:\n";
auto retVal = write(STDERR_FILENO, msg, strlen(msg));
msg = "UNKNOWN SIGNAL\n";
if (sig == SIGSEGV) {
msg = "SEGMENTATION FAULT\n";
} else if (sig == SIGABRT) {
msg = "ABRT\n";
} else if (sig == SIGBUS) {
msg = "BUS ERROR\n";
} else if (sig == SIGILL) {
msg = "ILLEGAL INSTRUCTION\n";
} else if (sig == SIGFPE) {
char buffer[1024];
char const* msg = "*** Program crashed (%s)\nBacktrace by DPL:\n";
snprintf(buffer, 1024, msg, strsignal(sig));
if (sig == SIGFPE) {
if (std::fetestexcept(FE_DIVBYZERO)) {
msg = "FLOATING POINT EXCEPTION (DIVISION BY ZERO)\n";
snprintf(buffer, 1024, msg, "FLOATING POINT EXCEPTION - DIVISION BY ZERO");
} else if (std::fetestexcept(FE_INVALID)) {
msg = "FLOATING POINT EXCEPTION (INVALID RESULT)\n";
snprintf(buffer, 1024, msg, "FLOATING POINT EXCEPTION - INVALID RESULT");
} else {
msg = "FLOATING POINT EXCEPTION (UNKNOWN REASON)\n";
snprintf(buffer, 1024, msg, "FLOATING POINT EXCEPTION - UNKNOWN REASON");
}
}
retVal = write(STDERR_FILENO, msg, strlen(msg));
auto retVal = write(STDERR_FILENO, buffer, strlen(buffer));
(void)retVal;
}
demangled_backtrace_symbols(array, size, STDERR_FILENO);
Expand Down

0 comments on commit d4d2179

Please sign in to comment.