Very low syntactic nesting limit: 29 nested function expressions (or 70 nested array literals) fail to compile with "InternalError: too much recursion"
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 48/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- c, wasm
- Lĩnh vực
- backend, performance
Hướng nghiên cứu
Start by reading cmake/compile-flags.cmake and runtime/engine.cpp, which the report identifies as unchanged on main; then check how the WASI stack limit and SpiderMonkey’s native stack quota are configured. Reproduce the failure with the nested IIFE generator or test262’s language/statements/function/S13.2.1_A1_T1.js. Done means the reported nesting compiles and runs without weakening runtime recursion protection.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Summary
StarlingMonkey fails to compile scripts with modest syntactic nesting. 29 nested function expressions, or 70 nested
array literals, make the whole script fail with InternalError: too much recursion and no source location. The same
code compiles in SpiderMonkey's own shell. test262's language/statements/function/S13.2.1_A1_T1.js (32 nested
function expressions) fails for this reason.
Environment
- StarlingMonkey v0.4.0 release
starling.wasm, wasmtime 50.0.1,--legacy-script. cmake/compile-flags.cmakeandruntime/engine.cppare unchanged onmain(54b3329b).- Checked on 2026-11-03. Reference: SpiderMonkey jsshell 147.0.4 (the SpiderMonkey version StarlingMonkey v0.4.0 embeds).
Reproduction
Generate N nested IIFEs:
// node gen.js 29 > nested.js
const d = +process.argv[2];
console.log("(function(){".repeat(d) + "console.log('ok');" + "})()".repeat(d) + ";");
| input | StarlingMonkey | jsshell 147.0.4 |
|---|---|---|
| 28 nested IIFEs | ok |
ok |
| 29 nested IIFEs | InternalError: too much recursion |
ok |
69 nested array literals [[[…]]] |
ok | ok |
| 70 nested array literals | InternalError: too much recursion |
ok |
the 29-level code inside if (false) { … } (never executed) |
InternalError: too much recursion |
ok |
The last row shows that the limit is hit while compiling (parser / bytecode emitter), not while running. Runtime
recursion is fine (function f(n){return n?1+f(n-1):0} f(50000) works). Through indirect eval inside try the
error is catchable, so it is a regular over-recursion check, not a crash.
Why it matters
ECMA-262 allows implementation limits, but 29 nested functions is easily reached by real code: bundler output (module
wrapper, UMD wrapper, nested callbacks), generated parsers, and deeply nested inline callback chains. Such a script
currently fails as a whole, with no location.
Likely cause
cmake/compile-flags.cmake links with -Wl,-z,stack-size=1048576 -Wl,--stack-first, a 1 MiB stack, and no native
stack quota is configured for the context. SpiderMonkey's recursive-descent parser and BytecodeEmitter use a lot of
stack per nesting level, so the recursion check trips after a few dozen levels. (I have not confirmed where the
effective limit for the WASI build is computed; maintainers will know better.)
Suggested fix (sketch)
Raise the stack size (for example to 8 MiB, the usual native default) and set a matching quota after context creation
(JS_SetNativeStackQuota(cx, stack_size - safety_margin)), or make the stack size a build option so embedders can
trade memory for depth. A regression test can be the generator above or test262's S13.2.1_A1_T1.js.
Related
- #298 (silent failure when the runtime call-stack limit is exceeded in async handlers; different symptom).
- bytecodealliance/ComponentizeJS#206 (minimum stack size for AOT builds).
- Ngôn ngữ chính
- C
- Star
- 297
- Fork
- 64
- Merge trung bình
- 2 ngày 2 giờ
- Pull request đã merge (30 ngày)
- 19
Chuẩn bị môi trường
Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của bytecodealliance/StarlingMonkey
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
bytecodealliance/StarlingMonkey#359 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
bytecodealliance/StarlingMonkey#355 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 4/5 1-2 ngày Mức phù hợp với người mới 68/100
bytecodealliance/StarlingMonkey#358 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 55/100
bytecodealliance/StarlingMonkey#356 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 44/100
bytecodealliance/StarlingMonkey#354 ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của bytecodealliance/StarlingMonkey
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
JustAResearcher/gpu-unlock-ada#145 · 1 reaction ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[Success Image Report]: GXDE OSĐang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 62/100
-
`PiecewiseChebyshevGate` produces incorrect target rotations outside the supplied breakpointsĐang mởbug mod: circuit
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
Maintainer thường phản hồi trong vòng 1 ngày
-
area:tools type:bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Offline trigger silently replaces an existing /system-update link from another tool (dnf5 offline)Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
PackageKit/PackageKit#1040 ·
Maintainer thường phản hồi trong vòng 1 ngày