Skip to content

fix(runtime): count nested array fields in shared records - #2198

Merged
nicolas-abril merged 1 commit into
bendlang:mainfrom
sebastian-griego:fix/nested-array-reference-counts
Nov 18, 2026
Merged

nicolas-abril merged 1 commit into
bendlang:mainfrom
sebastian-griego:fix/nested-array-reference-counts

Conversation

@sebastian-griego

Copy link
Copy Markdown
Contributor

The native runtime stops when both handles from Array.fork match a record that contains nested arrays. This also fails with one CPU worker. The added regression stops with bend: runtime fail-stop on main. With this fix it prints 4, 4, and 8, as the JS runtime does.

rfc_seal gives constructor fields reference counts before a record can be shared. It skips array and buffer handles, so span_fade rejects those fields when it opens the shared record. Include TAG_ARR and TAG_BUF when BLK_SHR is enabled. This follows the stated Array.fork contract for affine elements. Maintainer comment

The regression covers nested Array<U32> and Array<String>, a recursive record, and replacement through Array.set.

Validation on macOS with Apple clang 21

  • 50 related programs passed the normal run, generated JS, and native C with one and eight workers. All 200 run checks passed.
  • The regression passed with AddressSanitizer, UndefinedBehaviorSanitizer, and BEND_POISON.
  • A copy of the regression with twice! passed with +RTS --gpu on on Metal.
  • All 17 runtime benchmarks produced identical optimized CPU assembly before and after the fix.
  • The repository gate passed 56/56. comp.ts is 65,995 tokens.

The full cluster suite and CUDA were not run.

@nicolas-abril
nicolas-abril merged commit 016137a into bendlang:main Nov 18, 2026
1 check passed
nicolas-abril added a commit to nicolas-abril/bend that referenced this pull request Nov 22, 2026
, bendlang#2198, bendlang#2203, bendlang#2205 and others)

Conflicts:
- comp.ts, nat_mul: bendlang#2174's draft against bendlang#2205 on main (the same test
  without its two != 0); main's text taken.
- bendlang#2173 landed on main in another form (base.bend: Nat.div / Nat.mod drop
  the other half of Nat.divmod as a Nat) from the draft merged here
  (comp.ts OPERATIONS entries Nat.div / Nat.mod, native C). Both auto-merged
  and computed the same thing; the draft's comp.ts entries are removed so
  the branch carries bendlang#2173 as merged, and tests/run/nat_div_native.bend
  (add/add) is main's.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
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