-
Notifications
You must be signed in to change notification settings - Fork 29.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add test to crash on GC state access and update docs
- Loading branch information
Showing
9 changed files
with
153 additions
and
25 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
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,31 @@ | ||
'use strict'; | ||
|
||
if (process.argv[2] === 'child') { | ||
const common = require('../../common'); | ||
const test_finalizer = require(`./build/${common.buildType}/test_finalizer`); | ||
|
||
(() => { | ||
const obj = {}; | ||
test_finalizer.addFinalizerFailOnJS(obj); | ||
})(); | ||
|
||
// Collect garbage 10 times. At least one of those should throw the exception | ||
// and cause the whole process to bail with it, its text printed to stderr and | ||
// asserted by the parent process to match expectations. | ||
let gcCount = 10; | ||
(function gcLoop() { | ||
global.gc(); | ||
if (--gcCount > 0) { | ||
setImmediate(() => gcLoop()); | ||
} | ||
})(); | ||
return; | ||
} | ||
|
||
const assert = require('assert'); | ||
const { spawnSync } = require('child_process'); | ||
const child = spawnSync(process.execPath, [ | ||
'--expose-gc', __filename, 'child', | ||
]); | ||
assert.strictEqual(child.signal, null); | ||
assert.match(child.stderr.toString(), /Finalizer is calling a function that may affect GC state/); |
Oops, something went wrong.