提交 fdbf5328 编写于 作者: E Enrico Giordani

MapViewOfFileEx() error handling, UnhandledExceptiontHandler fixes.

[log] Improved error message if MapViewOfFileEx() fails.
[fix] Child process call exist(1) if MapViewOfFileEx() fails.
[new] GetForkOperationStatus() now detects if the child process is not anymore running.
[fix] Error reporting in UnhandledExceptiontHandler() for "UNKNOWN EXCEPTION".
[new] UnhandledExceptiontHandler() now calls the default C++ unhandled exceptiont handler.
[log] Changed the closing statement of the BUG REPORT.
[comment] Removed commented out code in Win32_dlmalloc.c.
上级 05b20f0e
......@@ -644,15 +644,24 @@ LONG CALLBACK VectoredHeapMapper(PEXCEPTION_POINTERS info) {
else
{
DWORD err = GetLastError();
::redisLog(REDIS_WARNING, "MapViewOfFileEx failed with error 0x%08X.\n", err);
::redisLog(REDIS_WARNING, "\n\n=== REDIS BUG REPORT START: Cut & paste starting from here ===");
::redisLog(REDIS_WARNING, "--- FATAL ERROR MAPPING VIEW OF MAP FILE");
::redisLog(REDIS_WARNING, "\t MapViewOfFileEx failed with error 0x%08X.", err);
::redisLog(REDIS_WARNING, "\t startOfMapping 0x%p", startOfMapping);
::redisLog(REDIS_WARNING, "\t heapStart 0x%p\n", heapStart);
::redisLog(REDIS_WARNING, "\t heapEnd 0x%p\n", heapEnd);
::redisLog(REDIS_WARNING, "\t failing access location 0x%p\n", failingMemoryAddress);
::redisLog(REDIS_WARNING, "\t offset into mmf to start mapping 0x%p\n", mmfOffset);
::redisLog(REDIS_WARNING, "\t start of new mapping 0x%p\n", startOfMapping);
::redisLog(REDIS_WARNING, "\t heapStart 0x%p", heapStart);
::redisLog(REDIS_WARNING, "\t heapEnd 0x%p", heapEnd);
::redisLog(REDIS_WARNING, "\t failing access location 0x%p", failingMemoryAddress);
::redisLog(REDIS_WARNING, "\t offset into mmf to start mapping 0x%p", mmfOffset);
::redisLog(REDIS_WARNING, "\t start of new mapping 0x%p", startOfMapping);
::redisLog(REDIS_WARNING, "\t bytes to map 0x%p\n", bytesToMap);
::redisLog(REDIS_WARNING, "\t continuing exception handler search\n");
if (err == 0x000005AF) {
::redisLog(REDIS_WARNING, "The system paging file is too small for this operation to complete.");
::redisLog(REDIS_WARNING, "See https://github.com/MSOpenTech/redis/wiki/Memory-Configuration");
::redisLog(REDIS_WARNING, "for more information on configuring the system paging file for Redis.");
}
::redisLog(REDIS_WARNING, "\n=== REDIS BUG REPORT END. Make sure to include from START to END. ===\n\n");
// Call exit to avoid executing the Unhandled Exceptiont Handler since we don't need a call stack
exit(1);
}
}
}
......@@ -1022,7 +1031,19 @@ OperationStatus GetForkOperationStatus() {
}
if (WaitForSingleObject(g_pQForkControl->forkedProcessReady, 0) == WAIT_OBJECT_0) {
return OperationStatus::osINPROGRESS;
// Verify if the child process is still running
if (WaitForSingleObject(g_hForkedProcess, 0) == WAIT_OBJECT_0) {
// The child process is not running, close the handle and report the status
// setting the operationFailed event
g_hForkedProcess = 0;
CloseHandle(g_hForkedProcess);
if (g_pQForkControl->operationFailed != NULL) {
SetEvent(g_pQForkControl->operationFailed);
}
return OperationStatus::osFAILED;
} else {
return OperationStatus::osINPROGRESS;
}
}
return OperationStatus::osUNSTARTED;
......
......@@ -31,6 +31,7 @@ static IMAGEHLP_LINE64 line;
static BOOLEAN processingException = FALSE;
static CHAR modulePath[MAX_PATH];
static BOOL symbolsInitialized = FALSE;
static LPTOP_LEVEL_EXCEPTION_FILTER defaultTopLevelExceptionHandler = NULL;
static const char* exceptionDescription(const DWORD& code)
{
......@@ -163,9 +164,9 @@ void ServerInfo() {
void BugReportEnd(){
redisLogRaw(REDIS_WARNING,
"\n=== REDIS BUG REPORT END. Make sure to include from START to END. ===\n\n"
" Please report the bug following the instructions on:\n\n"
" http://github.com/MSOpenTech/redis/wiki/Submit-Bug\n\n"
" Suspect RAM error? Use redis-server --test-memory to verify it.\n\n"
" Please report this bug by following the instructions at:\n\n"
" http://github.com/MSOpenTech/redis/wiki/Submitting-an-Issue\n\n"
" Suspect RAM error? Use redis-server --test-memory to verify it.\n\n"
);
}
......@@ -175,11 +176,6 @@ LONG WINAPI UnhandledExceptiontHandler(PEXCEPTION_POINTERS info) {
processingException = true;
if (info->ExceptionRecord != NULL && info->ExceptionRecord->ExceptionCode != NULL) {
exDescription = exceptionDescription(info->ExceptionRecord->ExceptionCode);
// If it's an application exception don't process it, here we don't want to catch
// exceptions like the one thrown by the code that processes the command arguments
if (strcmp(exDescription, "UNKNOWN EXCEPTION") == 0) {
return EXCEPTION_CONTINUE_SEARCH;
}
}
// Call antirez routine to log the start of the bug report
......@@ -190,6 +186,11 @@ LONG WINAPI UnhandledExceptiontHandler(PEXCEPTION_POINTERS info) {
BugReportEnd();
processingException = false;
}
if (defaultTopLevelExceptionHandler != NULL) {
defaultTopLevelExceptionHandler(info);
}
return EXCEPTION_CONTINUE_SEARCH;
}
......@@ -216,7 +217,7 @@ void InitSymbols() {
void StackTraceInit(void) {
InitSymbols();
// Global handler for unhandled exceptions
SetUnhandledExceptionFilter(UnhandledExceptiontHandler);
defaultTopLevelExceptionHandler = SetUnhandledExceptionFilter(UnhandledExceptiontHandler);
// Handler for abort()
signal(SIGABRT, &AbortHandler);
}
......@@ -1702,11 +1702,6 @@ static FORCEINLINE void* win32mmap(size_t size) {
#else
void* ptr = VirtualAlloc(0, size, MEM_RESERVE|MEM_COMMIT, PAGE_READWRITE);
#endif
// Avoid printing on the std out
//if( ptr == NULL )
//{
// printf( "VirtualAlloc/COWAlloc fail!\n");
//}
return (ptr != 0)? ptr: MFAIL;
}
......@@ -1717,11 +1712,6 @@ static FORCEINLINE void* win32direct_mmap(size_t size) {
#else
void* ptr = VirtualAlloc(0, size, MEM_RESERVE|MEM_COMMIT|MEM_TOP_DOWN, PAGE_READWRITE);
#endif
// Avoid printing on the std out
//if( ptr == NULL )
//{
// printf( "VirtualAlloc/COWAlloc fail!\n");
//}
return (ptr != 0)? ptr: MFAIL;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册