<div dir="ltr"><div dir="ltr"><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">Le mer. 15 févr. 2023 à 14:39, Thorsten Glaser <<a href="mailto:tg@debian.org">tg@debian.org</a>> a écrit :<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hi James,<br>
<br>
(you might wish to Cc <${<a href="mailto:bugnumber%7D-submitter@bugs.debian.org" target="_blank">bugnumber}-submitter@bugs.debian.org</a>> so they<br>
actually get the reply…)<br>
<br>
>Are you able to determine whether <a href="https://github.com/nodejs/node/issues/41163" rel="noreferrer" target="_blank">https://github.com/nodejs/node/issues/41163</a><br>
>(and/or any of the guidance within that thread) seems relevant to this bug?<br>
<br>
It appears so. I commented there, thank you for finding that link.<br>
<br>
I guess there is even a… quick patch… to make from this. I admit<br>
I’m very confused by that statement:<br>
<br>
“if you set it too high, you risk crashes”<br>
<br>
That can’t be right.<br>
<br>
Searching through the nodejs source for where this stack size is<br>
set, I see multiple time bombs for all architectures.<br>
<br>
deps/v8/src/common/globals.h does set the default stack size to<br>
864/984 KiB in order to achieve an about 1 MiB stack for JS plus<br>
C++ parts combined.<br>
<br>
I wonder if this shouldn’t be getrlimit(RLIMIT_STACK) - overhead,<br>
and then define the per-architecture overhead in a suitable way.<br>
<br>
That lower 1 MiB total limit seems to be for Windows. The lower<br>
arm64 limit is caused by “allocating MacroAssembler takes 120 [KiB]”<br>
but the total could still be raised I think… at least on unixoid<br>
platforms other than WebView-on-Android. Since the location of these<br>
defaults is in v8, it also applies for browsers and whatnot, but<br>
nodejs could indeed inspect the current ulimit and set a better<br>
default for at least nōn-Windows systems.<br>
<br>
I’m not, unfortunately, in the position to provide a quick patch,<br>
being a C developer, not CFrustFrust, and all that. I think that<br>
InitializeNodeWithArgs in src/node.cc, which already has a call<br>
to V8::SetFlagsFromString(NODE_V8_OPTIONS, …), is the likely place<br>
for adding code (suitably platform-ifdef’d) that does:<br>
<br>
- get the ulimit<br>
- subtract some arch-specific overhead target<br>
- check that that’s positive (or >= V8_DEFAULT_STACK_SIZE_KB even,<br>
  that might be a good idea)<br>
- if so, pass this as synthetic --stack-size (or --stack_size?) to<br>
  v8, overriding its default but allowing for a later option given<br>
  by the user’s argv[] to override _that_, again<br>
<br>
Might need to adjust some tests, too :~</blockquote><div><br></div><div>While waiting for the proper fix you describe, I propose to set higher constants</div><div>for V8_DEFAULT_STACK_SIZE_KB - especially for arm64.</div><div><br></div><div>Jérémy</div><div><br></div><div><br></div></div></div>