Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build,test: increase stack size limit on Windows #43632

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions node.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,12 @@
'RandomizedBaseAddress': 2, # enable ASLR
'DataExecutionPrevention': 2, # enable DEP
'AllowIsolation': 'true',
# By default, the MSVC linker only reserves 1 MiB of stack memory for
# each thread, whereas other platforms typically allow much larger
# stack memory sections. We raise the limit to make it more consistent
# across platforms and to support the few use cases that require large
# amounts of stack memory, without having to modify the node binary.
'StackReserveSize': 0x800000,
},
},

Expand Down
26 changes: 26 additions & 0 deletions test/parallel/test-stack-size-limit.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
'use strict';

require('../common');

const assert = require('assert');
const { spawnSync } = require('child_process');

// The default --stack-size is 984, which is below Windows' default stack size
// limit of 1 MiB. However, even a slight increase would cause node to exceed
// the 1 MiB limit and thus to crash with the exit code STATUS_STACK_OVERFLOW.
// Newer versions of Node.js allow the stack size to grow to up to 8 MiB, which
// better aligns with default limits on other platforms and which is commonly
// used for browsers on Windows.
// See https://github.com/nodejs/node/issues/43630.

const { status, signal, stderr } = spawnSync(process.execPath, [
'--stack-size=2000',
'-e',
'(function explode() { return explode(); })()',
], {
encoding: 'utf8'
});

assert.strictEqual(status, 1);
assert.strictEqual(signal, null);
assert.match(stderr, /Maximum call stack size exceeded/);