! * \brief Install a signal handler to print callstack on the following signals: * SIGILL SIGSEGV SIGBUS SIGABRT * \param sig */
| 83 | * \param sig |
| 84 | */ |
| 85 | static void stackTraceHandler(int sig) |
| 86 | { |
| 87 | // reset to default handler |
| 88 | signal(sig, SIG_DFL); |
| 89 | qCCritical(logDPF, "Received signal %d (%s)\n", sig, strsignal(sig)); |
| 90 | |
| 91 | QString head; |
| 92 | head = QString("****************** %0 crashed backtrace ******************") |
| 93 | .arg(qApp->applicationName()); |
| 94 | QString end { head.size(), '*' }; |
| 95 | qCCritical(logDPF, "%s", head.toStdString().data()); |
| 96 | |
| 97 | // skip the top three signal handler related frames |
| 98 | printStack(3); |
| 99 | |
| 100 | qCCritical(logDPF, "%s", end.toStdString().data()); |
| 101 | |
| 102 | // Efforts to fix or suppress TSAN warnings "signal-unsafe call inside of |
| 103 | // a signal" have failed, so just warn the user about them. |
| 104 | #ifdef __SANITIZE_THREAD__ |
| 105 | fprintf(stderr, |
| 106 | "==> NOTE: any above warnings about \"signal-unsafe call\" are\n" |
| 107 | "==> ignorable, as they are expected when generating a stack\n" |
| 108 | "==> trace because of a signal under TSAN. Consider why the\n" |
| 109 | "==> signal was generated to begin with, and the stack trace\n" |
| 110 | "==> in the TSAN warning can be useful for that. (The stack\n" |
| 111 | "==> trace printed by the signal handler is likely obscured\n" |
| 112 | "==> by TSAN output.)\n"); |
| 113 | #endif |
| 114 | |
| 115 | // re-signal to default handler (so we still get core dump if needed...) |
| 116 | raise(sig); |
| 117 | } |
| 118 | |
| 119 | /*! |
| 120 | * \brief initbacktrace |
nothing calls this directly
no test coverage detected