Skip to content

Commit e9ee7e4

Browse files
tniessentargos
authored andcommitted
build,test: increase stack size limit on Windows
Fixes: #43630 PR-URL: #43632 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Jiawen Geng <technicalcute@gmail.com>
1 parent e6d4837 commit e9ee7e4

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

node.gyp

+6
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,12 @@
172172
'RandomizedBaseAddress': 2, # enable ASLR
173173
'DataExecutionPrevention': 2, # enable DEP
174174
'AllowIsolation': 'true',
175+
# By default, the MSVC linker only reserves 1 MiB of stack memory for
176+
# each thread, whereas other platforms typically allow much larger
177+
# stack memory sections. We raise the limit to make it more consistent
178+
# across platforms and to support the few use cases that require large
179+
# amounts of stack memory, without having to modify the node binary.
180+
'StackReserveSize': 0x800000,
175181
},
176182
},
177183

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
'use strict';
2+
3+
require('../common');
4+
5+
const assert = require('assert');
6+
const { 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+
16+
const { status, signal, stderr } = spawnSync(process.execPath, [
17+
'--stack-size=2000',
18+
'-e',
19+
'(function explode() { return explode(); })()',
20+
], {
21+
encoding: 'utf8'
22+
});
23+
24+
assert.strictEqual(status, 1);
25+
assert.strictEqual(signal, null);
26+
assert.match(stderr, /Maximum call stack size exceeded/);

0 commit comments

Comments
 (0)