1'use strict';
2
3require('../common');
4
5const assert = require('assert');
6const { spawnSync } = require('child_process');
7
8// The default --stack-size is 984, which is below Windows' default stack size
9// limit of 1 MiB. However, even a slight increase would cause node to exceed
10// the 1 MiB limit and thus to crash with the exit code STATUS_STACK_OVERFLOW.
11// Newer versions of Node.js allow the stack size to grow to up to 8 MiB, which
12// better aligns with default limits on other platforms and which is commonly
13// used for browsers on Windows.
14// See https://github.com/nodejs/node/issues/43630.
15
16const { status, signal, stderr } = spawnSync(process.execPath, [
17  '--stack-size=2000',
18  '-e',
19  '(function explode() { return explode(); })()',
20], {
21  encoding: 'utf8'
22});
23
24assert.strictEqual(status, 1);
25assert.strictEqual(signal, null);
26assert.match(stderr, /Maximum call stack size exceeded/);
27