| 2023 | } |
| 2024 | |
| 2025 | void sigsegvHandler(int sig, siginfo_t *info, void *secret) { |
| 2026 | UNUSED(secret); |
| 2027 | UNUSED(info); |
| 2028 | g_fInCrash = true; |
| 2029 | |
| 2030 | bugReportStart(); |
| 2031 | serverLog(LL_WARNING, |
| 2032 | "KeyDB %s crashed by signal: %d, si_code: %d", KEYDB_REAL_VERSION, sig, info->si_code); |
| 2033 | if (sig == SIGSEGV || sig == SIGBUS) { |
| 2034 | serverLog(LL_WARNING, |
| 2035 | "Accessing address: %p", (void*)info->si_addr); |
| 2036 | } |
| 2037 | if (info->si_code <= SI_USER && info->si_pid != -1) { |
| 2038 | serverLog(LL_WARNING, "Killed by PID: %ld, UID: %d", (long) info->si_pid, info->si_uid); |
| 2039 | } |
| 2040 | |
| 2041 | #ifdef HAVE_BACKTRACE |
| 2042 | ucontext_t *uc = (ucontext_t*) secret; |
| 2043 | void *eip = getMcontextEip(uc); |
| 2044 | if (eip != NULL) { |
| 2045 | serverLog(LL_WARNING, |
| 2046 | "Crashed running the instruction at: %p", eip); |
| 2047 | } |
| 2048 | |
| 2049 | logStackTrace(getMcontextEip(uc), 1); |
| 2050 | |
| 2051 | logRegisters(uc); |
| 2052 | #endif |
| 2053 | #ifdef UNW_LOCAL_ONLY |
| 2054 | logStackTrace(NULL, 1); |
| 2055 | #endif |
| 2056 | |
| 2057 | printCrashReport(); |
| 2058 | |
| 2059 | #ifdef HAVE_BACKTRACE |
| 2060 | if (eip != NULL) |
| 2061 | dumpCodeAroundEIP(eip); |
| 2062 | #endif |
| 2063 | |
| 2064 | bugReportEnd(1, sig); |
| 2065 | } |
| 2066 | |
| 2067 | void printCrashReport(void) { |
| 2068 | g_fInCrash = true; |
nothing calls this directly
no test coverage detected