Merge pull request #6618 from electron/code-range-registration

Only register code range in Windows crash reporter once
This commit is contained in:
Cheng Zhao 2016-07-27 09:52:18 +09:00 committed by GitHub
commit 7994f087fb
3 changed files with 24 additions and 7 deletions

View file

@ -138,7 +138,8 @@ void UnregisterNonABICompliantCodeRange(void* start) {
} // namespace
CrashReporterWin::CrashReporterWin()
: skip_system_crash_handler_(false) {
: skip_system_crash_handler_(false),
code_range_registered_(false) {
}
CrashReporterWin::~CrashReporterWin() {
@ -189,19 +190,20 @@ void CrashReporterWin::InitBreakpad(const std::string& product_name,
LOG(ERROR) << "Cannot initialize out-of-process crash handler";
#ifdef _WIN64
bool registered = false;
// Hook up V8 to breakpad.
{
if (!code_range_registered_) {
code_range_registered_ = true;
// gin::Debug::SetCodeRangeCreatedCallback only runs the callback when
// Isolate is just created, so we have to manually run following code here.
void* code_range = nullptr;
size_t size = 0;
v8::Isolate::GetCurrent()->GetCodeRange(&code_range, &size);
if (code_range && size)
registered = RegisterNonABICompliantCodeRange(code_range, size);
if (code_range && size &&
RegisterNonABICompliantCodeRange(code_range, size)) {
gin::Debug::SetCodeRangeDeletedCallback(
UnregisterNonABICompliantCodeRange);
}
}
if (registered)
gin::Debug::SetCodeRangeDeletedCallback(UnregisterNonABICompliantCodeRange);
#endif
}

View file

@ -62,6 +62,7 @@ class CrashReporterWin : public CrashReporter {
google_breakpad::CustomClientInfo custom_info_;
bool skip_system_crash_handler_;
bool code_range_registered_;
std::unique_ptr<google_breakpad::ExceptionHandler> breakpad_;
DISALLOW_COPY_AND_ASSIGN(CrashReporterWin);

View file

@ -88,5 +88,19 @@ describe('crash-reporter module', function () {
})
}, /companyName is a required option to crashReporter\.start/)
})
it('can be called multiple times', function () {
assert.doesNotThrow(function () {
crashReporter.start({
companyName: 'Umbrella Corporation',
submitURL: 'http://127.0.0.1/crashes'
})
crashReporter.start({
companyName: 'Umbrella Corporation 2',
submitURL: 'http://127.0.0.1/more-crashes'
})
})
})
})
})