-
Notifications
You must be signed in to change notification settings - Fork 30.3k
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
Increase thread stack size limit on Windows #43630
Comments
cc @nodejs/build-files @nodejs/platform-windows |
Can you please point to where it is hard-coded in the repo? |
@targos I think the MSVC linker always embeds a hard-coded value and we just don't override the default of 1 MiB. After looking into this more, it seems like it's as simple as adding |
Fixes: nodejs/node#43630 PR-URL: nodejs/node#43632 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Jiawen Geng <technicalcute@gmail.com>
What is the problem this feature will solve?
Node.js uses a hard-coded default stack size limit on Windows, which is 1 MiB:
On other platforms, the limit is usually around 8 or 10 MiB and can be changed using
ulimit -s
.V8 stack size
The default V8 stack size limit on 64-bit systems is 984 kBytes, which is below the thread stack size limit on all supported operating systems. On Linux, the V8 stack size can usually be increased almost arbitrarily by passing
--stack-size=...
if needed, and the maximum thread stack size can usually be changed without modifying thenode
executable (ulimit -s
). On Windows, however, raising V8's stack size beyond the hard-coded thread stack size limit of 1 MiB will crash the process:Raising the hard-coded thread stack size limit will allow greater manual adjustments through
--stack-size=...
beyond the default value.Native addons
Native addons are not necessarily limited by the V8 stack size limit, but they are limited by the hard-coded thread stack size limit (unless they create new threads or fibers). While the stack size limit of 1 MiB is often sufficient, some libraries perform stack allocations exceeding the limit. Such libraries work just fine when using Node.js on Linux but overflow the stack on Windows.
Raising the hard-coded thread stack size limit will simplify creating portable native addons that rely on large stack allocations (however questionable large stack allocations might be).
What is the feature you are proposing to solve the problem?
Increase the thread stack size limit beyond the default value of 1 MiB. See
/STACK
.Only increase the reserve size, not the commit size, to avoid an increase in the actual memory usage.
For comparison, Chrome, Edge, and Firefox all use a hard-coded thread stack size limit of 8 MiB.
What alternatives have you considered?
node-mceliece-nist
andnode-pqclean
switch to a WebAssembly module instead of a native addon on Windows, to support cryptographic implementations that rely on large stack allocations (which are mapped to heap memory in WebAssembly).editbin.exe
can be used to change the hard-coded stack size ofnode.exe
:The text was updated successfully, but these errors were encountered: