Skip to content

Commit e472efb

Browse files
trop[bot]John Kleinschmidt
authored andcommitted
fix: correctly crash when there is no crashReporter (electron#20396)
* fix: correctly crash when there is no crashReporter * test: correctly crash when there is crashReporter
1 parent 886e636 commit e472efb

File tree

4 files changed

+29
-2
lines changed

4 files changed

+29
-2
lines changed

atom/common/crash_reporter/crash_reporter_win.cc

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,17 @@ namespace {
2828
#if defined(_WIN64)
2929
int CrashForException(EXCEPTION_POINTERS* info) {
3030
auto* reporter = crash_reporter::CrashReporterWin::GetInstance();
31-
if (reporter->IsInitialized())
31+
if (reporter->IsInitialized()) {
3232
reporter->GetCrashpadClient().DumpAndCrash(info);
33-
return EXCEPTION_CONTINUE_SEARCH;
33+
return EXCEPTION_CONTINUE_SEARCH;
34+
}
35+
36+
// When there is exception and we do not have crashReporter set up, we just
37+
// let the execution continue and crash, which is the default behavior.
38+
//
39+
// We must not return EXCEPTION_CONTINUE_SEARCH here, as it would end up with
40+
// busy loop when there is no exception handler in the program.
41+
return EXCEPTION_CONTINUE_EXECUTION;
3442
}
3543
#endif
3644

spec/api-crash-reporter-spec.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -373,6 +373,16 @@ describe('crashReporter module', () => {
373373
assert(!('hello' in crashReporter.getParameters()))
374374
})
375375
})
376+
377+
describe('when not started', () => {
378+
it('does not prevent process from crashing', (done) => {
379+
const appPath = path.join(fixtures, 'api', 'cookie-app')
380+
const appProcess = childProcess.spawn(process.execPath, [appPath])
381+
appProcess.once('close', () => {
382+
done()
383+
})
384+
})
385+
})
376386
})
377387

378388
const waitForCrashReport = () => {

spec/fixtures/crash-app/main.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
const { app } = require('electron')
2+
3+
app.on('ready', () => {
4+
process.crash()
5+
})

spec/fixtures/crash-app/package.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"name": "electron-crash-app",
3+
"main": "main.js"
4+
}

0 commit comments

Comments
 (0)