Skip to content

A RangeError that is not a stack overflow is reported as one #2120

Closed

Description

@nicolas-abril

book_err (bend2/main.ts:1121) reports every RangeError as a stack overflow:

if (e instanceof RangeError) {
  return "Error: the machine stack overflowed (a deep recursion, or a"
    + " literal too large to expand)";
}

JSC throws RangeError for more than a full stack: Out of memory (a failed string or array allocation), Invalid array length, Maximum BigInt size exceeded, an out-of-range toFixed or String.prototype.repeat, and others. All of these print as "the machine stack overflowed", and the original message is lost.

This hid the cause in #2076's second comment. Bend 2.0.40 failed on Entangle's tools/verify-mesh-window.bend with this message under the release's Bun 1.3.14, and passed under 1.4.4. That build ran under 2.0.40's memory blowup (8.4 GB on glam-in-bend's kernel.bend, the same under Bun 1.3.14 and 1.4.0), so an Out of memory RangeError is as likely as a deep recursion. The message doesn't say which it was. On macOS, 1.3.14 also recurses as deep as 1.4.0 (about 59K plain frames against 53K), so a smaller stack isn't an obvious explanation.

Expected: only a stack overflow (Maximum call stack size exceeded) prints the stack message. Any other RangeError prints its own message, for example Error: RangeError: Out of memory.

Activity

  1. added
    bug
    CLI
    on Nov 10, 2026
  2. nicolas-abril commented on Nov 10, 2026

    @nicolas-abril
    CollaboratorAuthor

    Confirmed on the case from #2076. Bend 2.0.40 printed "the machine stack overflowed" on Entangle's tools/verify-mesh-window.bend. The actual error, printed through a patched book_err, was:

    RangeError: Out of memory
        at memo (bend2/comp.ts:1694:7)
    

    It was Map.set on the FL.ground cache. Bun 1.3.14 caps a Map at 25,165,824 entries (Bun 1.4.0 at 50,331,648), and 2.0.40 never cleared that cache. The stack message sent the report after stack sizes, which could not help.

    The fix proposed above would have printed Error: RangeError: Out of memory, and that points straight at the cache. The case itself is fixed on main (#2107). This issue is only about the message.

  3. added a commit that references this issue on Nov 12, 2026
    8ec4c88
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    CLIbug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions