3
0
Fork 0
mirror of https://github.com/JulianGro/overte.git synced 2025-04-30 10:43:12 +02:00

Add special handler for heap corruption

This commit is contained in:
Atlante45 2018-04-17 15:09:10 -07:00
parent bd59ff1573
commit a626e9f6f3

View file

@ -31,10 +31,40 @@ using namespace crashpad;
static const std::string BACKTRACE_URL { CMAKE_BACKTRACE_URL };
static const std::string BACKTRACE_TOKEN { CMAKE_BACKTRACE_TOKEN };
static std::wstring gIPCPipe;
extern QString qAppFileName();
// crashpad::AnnotationList* crashpadAnnotations { nullptr };
#include <Windows.h>
LONG WINAPI vectoredExceptionHandler(PEXCEPTION_POINTERS pExceptionInfo) {
if (pExceptionInfo->ExceptionRecord->ExceptionCode == 0xe06d7363) { // external exception
return EXCEPTION_CONTINUE_SEARCH;
}
if (pExceptionInfo->ExceptionRecord->ExceptionCode == 0xc0000374) { // heap corruption
qCritical() << "VectoredExceptionHandler";
qCritical() << QString::number(pExceptionInfo->ExceptionRecord->ExceptionCode, 16);
qCritical() << "Heap corruption!";
CrashpadClient client;
if (gIPCPipe.length()) {
bool rc = client.SetHandlerIPCPipe(gIPCPipe);
qCritical() << "SetHandlerIPCPipe = " << rc;
} else {
qCritical() << "No IPC Pipe was previously defined for crash handler.";
}
qCritical() << "Calling DumpAndCrash()";
client.DumpAndCrash(pExceptionInfo);
return EXCEPTION_CONTINUE_SEARCH;
}
return EXCEPTION_CONTINUE_SEARCH;
}
bool startCrashHandler() {
if (BACKTRACE_URL.empty() || BACKTRACE_TOKEN.empty()) {
return false;
@ -76,7 +106,12 @@ bool startCrashHandler() {
// Enable automated uploads.
database->GetSettings()->SetUploadsEnabled(true);
return client.StartHandler(handler, db, db, BACKTRACE_URL, annotations, arguments, true, true);
bool result = client.StartHandler(handler, db, db, BACKTRACE_URL, annotations, arguments, true, true);
gIPCPipe = client.GetHandlerIPCPipe();
AddVectoredExceptionHandler(0, vectoredExceptionHandler);
return result;
}
void setCrashAnnotation(std::string name, std::string value) {