-
Notifications
You must be signed in to change notification settings - Fork 30k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
src: reset SIGSEGV handler before crashing
Without this, we would re-enter the signal handler immediately after re-raising the signal, leading to an infinite loop. PR-URL: #27775 Refs: #27246 Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Rich Trott <[email protected]>
- Loading branch information
Showing
3 changed files
with
36 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
'use strict'; | ||
const common = require('../common'); | ||
if (common.isWindows) | ||
common.skip('No signals on Window'); | ||
|
||
const assert = require('assert'); | ||
const { spawnSync } = require('child_process'); | ||
|
||
// Test that a hard crash does not cause an endless loop. | ||
|
||
if (process.argv[2] === 'child') { | ||
const { internalBinding } = require('internal/test/binding'); | ||
const { causeSegfault } = internalBinding('process_methods'); | ||
|
||
causeSegfault(); | ||
} else { | ||
const child = spawnSync(process.execPath, | ||
['--expose-internals', __filename, 'child'], | ||
{ stdio: 'inherit' }); | ||
// FreeBSD and macOS use SIGILL for the kind of crash we're causing here. | ||
assert(child.signal === 'SIGSEGV' || child.signal === 'SIGILL', | ||
`child.signal = ${child.signal}`); | ||
} |