void sigsegvHandler(int sig, siginfo_t *info, void *secret) { ucontext_t *uc = (ucontext_t*) secret; struct sigaction act; PREZ_NOTUSED(info); bugReportStart(); prezLog(PREZ_WARNING, " prez %s crashed by signal: %d", PREZ_VERSION, sig); prezLog(PREZ_WARNING, " Failed assertion: %s (%s:%d)", server.assert_failed, server.assert_file, server.assert_line); /* Log the stack trace */ prezLog(PREZ_WARNING, "--- STACK TRACE"); logStackTrace(uc); /* Log dump of processor registers */ logRegisters(uc); prezLog(PREZ_WARNING, "\n=== PREZ BUG REPORT END. Make sure to include from START to END. ===\n\n" ); /* free(messages); Don't call free() with possibly corrupted memory. */ if (server.daemonize) unlink(server.pidfile); /* Make sure we exit with the right signal at the end. So for instance * the core will be dumped if enabled. */ sigemptyset (&act.sa_mask); act.sa_flags = SA_NODEFER | SA_ONSTACK | SA_RESETHAND; act.sa_handler = SIG_DFL; sigaction (sig, &act, NULL); kill(getpid(),sig); }
/* * logFaultInfo */ static void logFaultInfo( ExceptDlgInfo *info ) { char *str; char buf[150]; char addr_buf[64]; char fname[ FNAME_BUFLEN ]; DWORD type; DWORD line; msg_id gptype; ProcStats stats; logStrPrintf( "\n" ); logPrintf( STR_OFFENDING_PROC_ULINE ); logPrintf( STR_OFFENDING_PROC_INFO ); logPrintf( STR_OFFENDING_PROC_ULINE ); while( !GetProcessInfo( info->procinfo->procid, &stats ) ) { Sleep( 100 ); RefreshInfo(); } logPrintf( STR_OFFENDING_PROC_X, stats.name, info->procinfo->procid ); type = info->dbinfo->u.Exception.ExceptionRecord.ExceptionCode; FormatException( buf, type ); MADCliAddrToString( info->init_ip, MADTypeDefault( MTK_ADDRESS, MAF_FULL, NULL, &( info->init_ip ) ), MLK_CODE, addr_buf, 63 ); logPrintf( STR_ERR_OCCURRED_AT_X_Y, buf, addr_buf ); if( type == EXCEPTION_ACCESS_VIOLATION ) { if( info->dbinfo->u.Exception.ExceptionRecord.ExceptionInformation[0] ) { gptype = STR_LOG_INV_WRITE_TO; } else { gptype = STR_LOG_INV_READ_FROM; } logPrintf( gptype, info->dbinfo->u.Exception.ExceptionRecord.ExceptionInformation[1] ); } str = SrchMsg( info->action, Actions, NULL ); if( str != NULL ) { logStrPrintf( "%s\n", str ); } logPrintf( STR_MODULES_LOADED ); logModules( info->procinfo->procid, INDENT ); logRegisters( info ); logPrintf( STR_SOURCE_INFORMATION ); if( info->got_dbginfo && GetLineNum( &info->init_ip, fname, FNAME_BUFLEN, &line ) ) { logPrintf( STR_LOG_LINE_X_OF_FILE, INDENT, "", line, fname ); } else { logPrintf( STR_LOG_N_A, INDENT, "" ); } logPrintf( STR_DISASSEMBLY ); logDisasm( info ); logStack( info ); #ifndef CHICAGO if( LogData.log_mem_manager ) { logMemManInfo( info->procinfo->procid ); } #endif if( LogData.log_mem_dmp ) { logMemDmp( info ); } }
void sigsegvHandler(int sig, siginfo_t *info, void *secret) { ucontext_t *uc = (ucontext_t*) secret; sds infostring, clients; struct sigaction act; UNUSED(info); bugReportStart(); serverLog(LL_WARNING, " Disque %s crashed by signal: %d", DISQUE_VERSION, sig); serverLog(LL_WARNING, " Failed assertion: %s (%s:%d)", server.assert_failed, server.assert_file, server.assert_line); /* Log the stack trace */ serverLog(LL_WARNING, "--- STACK TRACE"); logStackTrace(uc); /* Log INFO and CLIENT LIST */ serverLog(LL_WARNING, "--- INFO OUTPUT"); infostring = genDisqueInfoString("all"); infostring = sdscatprintf(infostring, "hash_init_value: %u\n", dictGetHashFunctionSeed()); serverLogRaw(LL_WARNING, infostring); serverLog(LL_WARNING, "--- CLIENT LIST OUTPUT"); clients = getAllClientsInfoString(); serverLogRaw(LL_WARNING, clients); sdsfree(infostring); sdsfree(clients); /* Log the current client */ logCurrentClient(); /* Log dump of processor registers */ logRegisters(uc); #if defined(HAVE_PROC_MAPS) /* Test memory */ serverLog(LL_WARNING, "--- FAST MEMORY TEST"); bioKillThreads(); if (memtest_test_linux_anonymous_maps()) { serverLog(LL_WARNING, "!!! MEMORY ERROR DETECTED! Check your memory ASAP !!!"); } else { serverLog(LL_WARNING, "Fast memory test PASSED, however your memory can still be broken. Please run a memory test for several hours if possible."); } #endif serverLog(LL_WARNING, "\n=== DISQUE BUG REPORT END. Make sure to include from START to END. ===\n\n" " Please report the crash by opening an issue on github:\n\n" " http://github.com/antirez/disque/issues\n\n" " Suspect RAM error? Use disque-server --test-memory to verify it.\n\n" ); /* free(messages); Don't call free() with possibly corrupted memory. */ if (server.daemonize) unlink(server.pidfile); /* Make sure we exit with the right signal at the end. So for instance * the core will be dumped if enabled. */ sigemptyset (&act.sa_mask); act.sa_flags = SA_NODEFER | SA_ONSTACK | SA_RESETHAND; act.sa_handler = SIG_DFL; sigaction (sig, &act, NULL); kill(getpid(),sig); }