forked from nodejs/node
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
worker: reset
Isolate
stack limit after entering Locker
It turns out that using `v8::Locker` undoes the effects of passing an explicit stack limit as part of the `Isolate`’s resource constraints. Therefore, reset the stack limit manually after entering a Locker. Refs: nodejs#26049 (comment)
- Loading branch information
Showing
2 changed files
with
47 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
'use strict'; | ||
const common = require('../common'); | ||
const assert = require('assert'); | ||
const { once } = require('events'); | ||
const v8 = require('v8'); | ||
const { Worker } = require('worker_threads'); | ||
|
||
// Verify that Workers don't care about --stack-size, as they have their own | ||
// fixed and known stack sizes. | ||
|
||
async function runWorker() { | ||
const empiricalStackDepth = new Uint32Array(new SharedArrayBuffer(4)); | ||
const worker = new Worker(` | ||
const { workerData: { empiricalStackDepth } } = require('worker_threads'); | ||
function f() { | ||
empiricalStackDepth[0]++; | ||
f(); | ||
} | ||
f();`, { | ||
eval: true, | ||
workerData: { empiricalStackDepth } | ||
}); | ||
|
||
const [ error ] = await once(worker, 'error'); | ||
|
||
common.expectsError({ | ||
constructor: RangeError, | ||
message: 'Maximum call stack size exceeded' | ||
})(error); | ||
|
||
return empiricalStackDepth[0]; | ||
} | ||
|
||
(async function() { | ||
v8.setFlagsFromString('--stack-size=500'); | ||
const w1stack = await runWorker(); | ||
v8.setFlagsFromString('--stack-size=1000'); | ||
const w2stack = await runWorker(); | ||
assert.strictEqual(w1stack, w2stack); | ||
})().then(common.mustCall()); |