unsigned char thunk[12];
};
-void RegisterNonABICompliantCodeRange(void* start, size_t size_in_bytes) {
+bool RegisterNonABICompliantCodeRange(void* start, size_t size_in_bytes) {
ExceptionHandlerRecord* record =
reinterpret_cast<ExceptionHandlerRecord*>(start);
// Protect reserved page against modifications.
DWORD old_protect;
- CHECK(VirtualProtect(
- start, sizeof(ExceptionHandlerRecord), PAGE_EXECUTE_READ, &old_protect));
- CHECK(RtlAddFunctionTable(
- &record->runtime_function, 1, reinterpret_cast<DWORD64>(start)));
+ return VirtualProtect(start, sizeof(ExceptionHandlerRecord),
+ PAGE_EXECUTE_READ, &old_protect) &&
+ RtlAddFunctionTable(&record->runtime_function, 1,
+ reinterpret_cast<DWORD64>(start));
}
void UnregisterNonABICompliantCodeRange(void* start) {
ExceptionHandlerRecord* record =
reinterpret_cast<ExceptionHandlerRecord*>(start);
- CHECK(RtlDeleteFunctionTable(&record->runtime_function));
+ RtlDeleteFunctionTable(&record->runtime_function);
}
#endif // _WIN64
LOG(ERROR) << "Cannot initialize out-of-process crash handler";
#ifdef _WIN64
+ bool registered = false;
// Hook up V8 to breakpad.
{
// gin::Debug::SetCodeRangeCreatedCallback only runs the callback when
size_t size = 0;
v8::Isolate::GetCurrent()->GetCodeRange(&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
}