Merge pull request #3343 from atom/fix-crash-of-crash-reporter
win: Guard against failure of RtlAddFunctionTable
This commit is contained in:
commit
5b0ea5bd46
1 changed files with 10 additions and 8 deletions
|
@ -80,7 +80,7 @@ struct ExceptionHandlerRecord {
|
||||||
unsigned char thunk[12];
|
unsigned char thunk[12];
|
||||||
};
|
};
|
||||||
|
|
||||||
void RegisterNonABICompliantCodeRange(void* start, size_t size_in_bytes) {
|
bool RegisterNonABICompliantCodeRange(void* start, size_t size_in_bytes) {
|
||||||
ExceptionHandlerRecord* record =
|
ExceptionHandlerRecord* record =
|
||||||
reinterpret_cast<ExceptionHandlerRecord*>(start);
|
reinterpret_cast<ExceptionHandlerRecord*>(start);
|
||||||
|
|
||||||
|
@ -117,17 +117,17 @@ void RegisterNonABICompliantCodeRange(void* start, size_t size_in_bytes) {
|
||||||
|
|
||||||
// Protect reserved page against modifications.
|
// Protect reserved page against modifications.
|
||||||
DWORD old_protect;
|
DWORD old_protect;
|
||||||
CHECK(VirtualProtect(
|
return VirtualProtect(start, sizeof(ExceptionHandlerRecord),
|
||||||
start, sizeof(ExceptionHandlerRecord), PAGE_EXECUTE_READ, &old_protect));
|
PAGE_EXECUTE_READ, &old_protect) &&
|
||||||
CHECK(RtlAddFunctionTable(
|
RtlAddFunctionTable(&record->runtime_function, 1,
|
||||||
&record->runtime_function, 1, reinterpret_cast<DWORD64>(start)));
|
reinterpret_cast<DWORD64>(start));
|
||||||
}
|
}
|
||||||
|
|
||||||
void UnregisterNonABICompliantCodeRange(void* start) {
|
void UnregisterNonABICompliantCodeRange(void* start) {
|
||||||
ExceptionHandlerRecord* record =
|
ExceptionHandlerRecord* record =
|
||||||
reinterpret_cast<ExceptionHandlerRecord*>(start);
|
reinterpret_cast<ExceptionHandlerRecord*>(start);
|
||||||
|
|
||||||
CHECK(RtlDeleteFunctionTable(&record->runtime_function));
|
RtlDeleteFunctionTable(&record->runtime_function);
|
||||||
}
|
}
|
||||||
#endif // _WIN64
|
#endif // _WIN64
|
||||||
|
|
||||||
|
@ -184,6 +184,7 @@ void CrashReporterWin::InitBreakpad(const std::string& product_name,
|
||||||
LOG(ERROR) << "Cannot initialize out-of-process crash handler";
|
LOG(ERROR) << "Cannot initialize out-of-process crash handler";
|
||||||
|
|
||||||
#ifdef _WIN64
|
#ifdef _WIN64
|
||||||
|
bool registered = false;
|
||||||
// Hook up V8 to breakpad.
|
// Hook up V8 to breakpad.
|
||||||
{
|
{
|
||||||
// gin::Debug::SetCodeRangeCreatedCallback only runs the callback when
|
// gin::Debug::SetCodeRangeCreatedCallback only runs the callback when
|
||||||
|
@ -192,9 +193,10 @@ void CrashReporterWin::InitBreakpad(const std::string& product_name,
|
||||||
size_t size = 0;
|
size_t size = 0;
|
||||||
v8::Isolate::GetCurrent()->GetCodeRange(&code_range, &size);
|
v8::Isolate::GetCurrent()->GetCodeRange(&code_range, &size);
|
||||||
if (code_range && size)
|
if (code_range && size)
|
||||||
RegisterNonABICompliantCodeRange(code_range, size);
|
registered = RegisterNonABICompliantCodeRange(code_range, size);
|
||||||
}
|
}
|
||||||
gin::Debug::SetCodeRangeDeletedCallback(UnregisterNonABICompliantCodeRange);
|
if (registered)
|
||||||
|
gin::Debug::SetCodeRangeDeletedCallback(UnregisterNonABICompliantCodeRange);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue