-
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.
Raising SIGABRT is handled in the CRT in windows, calling _exit() with ambiguous code "3" by default. This adjustment to the abort behavior gives a more sane exit code on abort, by calling _exit directly with code 134. PR-URL: #13947 Fixes: #12271 Refs: https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/abort Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Timothy Gu <timothygu99@gmail.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
- Loading branch information
Showing
7 changed files
with
33 additions
and
7 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
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
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,24 @@ | ||
'use strict'; | ||
const common = require('../common'); | ||
|
||
// This test ensures that an out of memory error exits with code 134 on Windows | ||
|
||
if (!common.isWindows) return common.skip('Windows-only'); | ||
|
||
const assert = require('assert'); | ||
const { exec } = require('child_process'); | ||
|
||
if (process.argv[2] === 'heapBomb') { | ||
// heap bomb, imitates a memory leak quickly | ||
const fn = (nM) => [...Array(nM)].map((i) => fn(nM ** 2)); | ||
fn(2); | ||
} | ||
|
||
// --max-old-space-size=3 is the min 'old space' in V8, explodes fast | ||
const cmd = `"${process.execPath}" --max-old-space-size=3 "${__filename}"`; | ||
exec(`${cmd} heapBomb`, common.mustCall((err) => { | ||
const msg = `Wrong exit code of ${err.code}! Expected 134 for abort`; | ||
// Note: common.nodeProcessAborted() is not asserted here because it | ||
// returns true on 134 as well as 0xC0000005 (V8's base::OS::Abort) | ||
assert.strictEqual(err.code, 134, msg); | ||
})); |