You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
JS effect marshaller overflows the host stack when recursion is nested under Array #1346
Run the program below on the JS lane, then build and run it on the native lane:
bend main.bend
bend main.bend -o main && ./main
What happened
On the JS lane, a depth of 5,000 prints ok, but 10,000 fails with:
bend: memory fault (machine stack overflow?)
The native lane prints ok at depth 20,000. A control with the same 10,000-deep
recursive ADT but a direct next: Tree field also prints ok on JS. The failure
appears only when the recursive occurrence is under Array.
The generated marshaller makes a direct recursive field iterative, but the
wrapped occurrence remains a host call inside the array converter:
This looks distinct from the JS non-tail-call limitation in WONTFIX.txt
(#798/#802): grow is tail-recursive and completes, while the host stack grows
only in compiler-generated marshalling at the effect boundary. Direct recursive
marshaller paths are already emitted as a loop, and #1304 tested a 50,000-deep
recursive Nat round trip; nesting that path under Array bypasses the loop.
Reproduced on current main at 565d7fdec289b1f2f5f5037bb58b5afb6738ff1d.
Activity