Skip to content

A 24 KB string literal overflows the stack in both emitters, while the check and the interpreter pass #1127

Closed as not planned

Description

@nicolas-abril

What you did

python3 gen.py > big.bend    # a 24 KB string literal
bend big.bend                # prints 24000
bend big.bend -o big.c
bend big.bend -o big.js

What happened

Error: the machine stack overflowed (a deep recursion, or a literal too large to expand)

Both emitters overflow; the check and the interpreter pass. WONTFIX (#993) covers the checker's recursion, but here the checker is fine and only emission fails. A string literal expands to one nested SCon chain, so its depth is its length; the fuzzer met this building its own Base table as one literal and splits it into a list of line literals instead.

The file

gen.py:

print("import Base\n\ndef main() -> U32:\n  U32.from_nat(String.length(\"" + "ab" * 12000 + "\"))")

bend --version

Bend 2.0.32 (main d2066a52); also on 2.0.31 (af569d48)

uname -sm

Darwin arm64

clang --version (the first line)

Apple clang version 17.0.0 (clang-1700.6.4.2)

Found by the bend2 differential fuzzer.

Activity

  1. added
    bug
    on Sep 27, 2026
  2. changed the title [-]`Array.set(..);` in an inline match arm is read as the write statement and swallows the next row[/-] [+]A 24 KB string literal overflows the stack in both emitters, while the check and the interpreter pass[/+] on Sep 27, 2026
  3. nicolas-abril commented on Sep 27, 2026

    @nicolas-abril
    CollaboratorAuthor

    Closing under WONTFIX: "The checker is not optimal: some terms are exponential or overflow (#993)". The emitters recurse on the machine stack the same way, so a literal this large is the same class.

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

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions