worker: set stack size for worker threads

This is so we can inform V8 about a known limit for the stack.

Otherwise, on some systems recursive functions may lead to
segmentation faults rather than “safe” failures.

PR-URL: https://github.com/nodejs/node/pull/26049
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
This commit is contained in:
Anna Henningsen 2019-02-05 21:51:28 +01:00
parent da0dc51e39
commit a80b29b38a
No known key found for this signature in database
GPG key ID: 9C63F3A6CD2AD8F9
3 changed files with 29 additions and 1 deletions

View file

@ -0,0 +1,11 @@
'use strict';
const common = require('../common');
const assert = require('assert');
const { Worker } = require('worker_threads');
const worker = new Worker('function f() { f(); } f();', { eval: true });
worker.on('error', common.mustCall((err) => {
assert.strictEqual(err.constructor, RangeError);
assert.strictEqual(err.message, 'Maximum call stack size exceeded');
}));