Skip to content

A value past 2^24-1 live copies fail-stops with its own message, and WONTFIX names the cap - #1366

Merged
Lorenzobattistela merged 1 commit into
bendlang:mainfrom
nicolas-abril:issue-1267-share-cap-message
Oct 6, 2026
Merged

Lorenzobattistela merged 1 commit into
bendlang:mainfrom
nicolas-abril:issue-1267-share-cap-message

Conversation

@nicolas-abril

Copy link
Copy Markdown
Collaborator

Refs #1267. The cap stays: this makes it visible. Once this merges, #1267 should be closed as not planned, like the other RUNTIME entries.

Why

On the C lane, copies of a + value share it through one 24-bit count, so a value can have at most 2^24 − 1 live copies. Past that, the program fail-stops with the generic bend: runtime fail-stop, which doesn't say which limit was hit. JS keeps no count and runs on. The BendRT paper lists the cap among its limitations, but WONTFIX didn't, which is why #1267 looked like an undocumented Array.new limit.

The cap isn't specific to arrays. Array.new(T, d, x) makes 2^d copies of x, so it hits the cap at depth 24, but so does a list holding 2^24 copies of one computed string.

Change

  • Error message. The overflow now posts its own ERR_CNTS, both from rfc_bump and from blk_new's depth-24 check:
    bend: a value has more than 2^24-1 live copies: keep fewer alive at once, or build it again for some of them (each build counts its own copies)
    
    ERR_RFCS keeps its generic text for its other two uses, sharing a closure and span_fade's sealed-field check. Neither is a count overflow.
  • WONTFIX. The RUNTIME section has a new entry next to Type checking a large Nat literal overflows the host stack without identifying the literal #779. It states the cap and the JS difference, and gives the workaround: build the value again for each group of copies, for example an Array.new at depth 23 per build, joined with ANode.

Checked

On the C lane:

Program Before After
Array.new(String, 23n, F32.show(1.0)) 1n 1n
the same at depth 24 (and with F32.show(12.375)) runtime fail-stop the message above
a list of 2^23 copies of one computed string 1n 1n
a list of 2^24 copies runtime fail-stop the message above

JS prints the answer in every case, as before.

There's no new test: every lane must print the same #| lines, and here JS and C differ by design.

Gates: repo 50/50, test 1577/1577, perf PASS (120/124). ping was skipped: the site repo isn't checked out on this machine.

🤖 Generated with Claude Code

…WONTFIX names the cap (bendlang#1267)

The 24-bit count of a shared value overflowed into ERR_RFCS, whose text
is the generic "runtime fail-stop". The overflow now posts ERR_CNTS:
"a value has more than 2^24-1 live copies: keep fewer alive at once, or
build it again for some of them (each build counts its own copies)",
from rfc_bump and from blk_new's depth-24 check alike. ERR_RFCS stays
for sharing a closure and for span_fade's sealed-field check.

WONTFIX's RUNTIME section names the cap beside bendlang#779: the C lane stops,
JS keeps no count, Array.new of a computed value stops at depth 24, and
building the value again per group of copies goes past it.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@Lorenzobattistela
Lorenzobattistela merged commit fa4ba63 into bendlang:main Oct 6, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants