提交 510cc9bd 编写于 作者: E Enrico Giordani

Replaced AddVectoredExceptionHandler with SetUnhandledExceptionFilter

for unhandled exception handling.
Added log warning if the maxmemory flag is not set.
上级 4993487b
......@@ -663,6 +663,7 @@ LONG CALLBACK VectoredHeapMapper(PEXCEPTION_POINTERS info) {
// QFork API
StartupStatus QForkStartup(int argc, char** argv) {
bool foundSlaveFlag = false;
bool foundSentinelMode = checkForSentinelMode(argc, argv);
HANDLE QForkConrolMemoryMapHandle = NULL;
DWORD PPID = 0;
__int64 maxheapBytes = -1;
......@@ -735,10 +736,12 @@ StartupStatus QForkStartup(int argc, char** argv) {
int64_t maxMemoryPlusHalf = (3 * maxmemoryBytes) / 2;
if( maxmemoryBytes != -1 ) {
maxheapBytes = (maxheapBytes > maxMemoryPlusHalf) ? maxheapBytes : maxMemoryPlusHalf;
} else if (!foundSlaveFlag && !foundSentinelMode) {
redisLog(REDIS_WARNING, "Warning: The maxmemory flag was not set, this can cause redis-server to crash if an out of memory exeception happens. It is strongly racommanded to set the maxmemory flag.");
}
if( maxheapBytes == -1 )
{
if (checkForSentinelMode(argc, argv)) {
if (foundSentinelMode) {
// Sentinel mode does not need a large heap. This conserves disk space and page file reservation requirements.
maxheapBytes = cSentinelHeapSize;
} else {
......
......@@ -147,7 +147,29 @@ void LogStackTrace() {
void LogStackTrace() {}
#endif
LONG CALLBACK VectoredSegFaultHandler(PEXCEPTION_POINTERS info) {
void StackTraceInfo() {
if (symbolsInitialized) {
redisLog(REDIS_WARNING, "--- STACK TRACE");
LogStackTrace();
}
}
void ServerInfo() {
redisLog(REDIS_WARNING, "--- INFO OUTPUT");
// Call antirez routine to log the info output
redisLogRaw(REDIS_WARNING | REDIS_LOG_RAW, genRedisInfoString("all"));
}
void BugReportEnd(){
redisLogRaw(REDIS_WARNING,
"\n=== REDIS 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/MSOpenTech/redis/issues\n\n"
" Suspect RAM error? Use redis-server --test-memory to verify it.\n\n"
);
}
LONG WINAPI UnhandledExceptiontHandler(PEXCEPTION_POINTERS info) {
if (!processingException) {
processingException = true;
if (info->ExceptionRecord == NULL || info->ExceptionRecord->ExceptionCode == NULL) {
......@@ -163,21 +185,10 @@ LONG CALLBACK VectoredSegFaultHandler(PEXCEPTION_POINTERS info) {
// Call antirez routine to log the start of the bug report (for asserts in antirez code, the start has already been logged)
bugReportStart();
redisLog(REDIS_WARNING, "Unhandled Exception: %s", exDescription);
if (symbolsInitialized) {
redisLog(REDIS_WARNING, "--- STACK TRACE");
LogStackTrace();
}
redisLog(REDIS_WARNING, "--- INFO OUTPUT");
// Call antirez routine to log the info output
redisLogRaw(REDIS_WARNING | REDIS_LOG_RAW, genRedisInfoString("all"));
redisLogRaw(REDIS_WARNING,
"\n=== REDIS 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/MSOpenTech/redis/issues\n\n"
" Suspect RAM error? Use redis-server --test-memory to verify it.\n\n"
);
redisLog(REDIS_WARNING, "--- %s", exDescription);
StackTraceInfo();
ServerInfo();
BugReportEnd();
processingException = false;
}
return EXCEPTION_CONTINUE_SEARCH;
......@@ -185,8 +196,10 @@ LONG CALLBACK VectoredSegFaultHandler(PEXCEPTION_POINTERS info) {
/* Handler to trap dlmalloc abort calls */
extern "C" void AbortHandler(int signal_number) {
printf( "********** Abort was called **********\n");
LogStackTrace();
bugReportStart();
redisLog(REDIS_WARNING, "--- ABORT WAS CALLED");
StackTraceInfo();
BugReportEnd();
}
void InitSymbols() {
......@@ -204,6 +217,6 @@ void InitSymbols() {
void StackTraceInit(void) {
process = GetCurrentProcess();
InitSymbols();
LPVOID exceptionHandler = AddVectoredExceptionHandler(1, VectoredSegFaultHandler);
SetUnhandledExceptionFilter(UnhandledExceptiontHandler);
signal(SIGABRT, &AbortHandler);
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册