Question: stack size on ARM systems

16 views
Skip to first unread message

James Addison

unread,
Mar 10, 2023, 10:00:38 AM3/10/23
to v8-...@googlegroups.com
Hi folks,

Debian bug #1030284[1] and the related NodeJS GitHub issue #41163[2]
report ARM-specific RangeError exceptions from the vendored V8 library
in NodeJS. The bug(s) are reproducible with v18.13 of NodeJS.

The cause of the difference-in-behaviour appears to be that V8 sets[3]
a lower stack size for ARM: 864K as compared to 984K.

Would it be safe to increase the stack size on ARM to 984K to restore
consistency with most other architectures?

(I've offered a patch to make that change, and others have confirmed
that it allows a provided repro case to pass; I'm worried about any
potential unsafe side-effects of the change, though)

Thank you,
James

[1] - https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1030284

[2] - https://github.com/nodejs/node/issues/41163

[3] - https://github.com/nodejs/node/blob/2bb4b59fa5529569ad38d3bf7d36666c926d8e47/deps/v8/src/common/globals.h#L74-L86

Jakob Kummerow

unread,
Mar 10, 2023, 3:51:22 PM3/10/23
to v8-...@googlegroups.com
It seems that on 32-bit ARM, the original reason for the lower limit has disappeared over time, and raising the stack limit there again to the same 984KB as on ia32/x64 might be worth a shot.

However, what Node/Debian cares about is arm64, and I see no reason to assume that anything has changed there since the limit was lowered. So I wouldn't be comfortable raising it.

Since (per crbug.com/v8/10575) the issue was specific to WebView, maybe the best path forward would be for Node to float a patch. V8 itself doesn't know what product it's getting embedded into.

FWIW, there is no guarantee that the same stack size allows the same recursion depth on different platforms. In particular, 32-bit platforms will allow significantly higher recursion depths than 64-bit platforms per kilobyte of stack space, because most spilled values are register-sized. There could also be platform-specific differences between different 64-bit architectures, in particular in optimized code. 

The "proper" fix is to design JS applications such that they don't even approach the stack limit. If 984 vs 864 makes a given app work or fail, then it's walking on very thin ice either way.


--
--
v8-dev mailing list
v8-...@googlegroups.com
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to v8-dev+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/v8-dev/CALDQ5NzeykWdpd79RcwDwJiWN-tYm%3DE1soUi8bxB1X%3DnjM5Z1g%40mail.gmail.com.

James Addison

unread,
Mar 11, 2023, 6:51:31 AM3/11/23
to v8-...@googlegroups.com
Thank you, Jakob - I've relayed those items of guidance to the Debian
and GitHub threads, and I think that probably completes my involvement
in the discussions.
> To view this discussion on the web visit https://groups.google.com/d/msgid/v8-dev/CAKSzg3Tnw06NZJhSoE7YzJww0rX5%3DZU%3DYb63Gocuy%3Dz-49hw0Q%40mail.gmail.com.
Reply all
Reply to author
Forward
0 new messages