Skip to content

rc: a global lent through a view is held from its read - #648

Merged
ASDAlexander77 merged 1 commit into
mainfrom
fix-rc-global-arg-view
Oct 23, 2026
Merged

ASDAlexander77 merged 1 commit into
mainfrom
fix-rc-global-arg-view

Conversation

@ASDAlexander77

Copy link
Copy Markdown
Owner

Follow-up to #647. This fixes the rc failures left in the fuzzer run there: A1's view variant.

A global, or a global's field, can be given to a call as a view: an interface parameter, a base-class parameter, or an object literal that holds it. If a later argument of the same call gives the global a new value, the block was freed before the call ran:

s += f1(G, (G = mk(6), mk(1)));            // f1(p: IX, ..): wrong value
s += f1(HG.n, (HG.n = mk(6), mk(1)));      // wrong value
s += f1({ v: G.v }, (G = mk(6), mk(1)));   // SIGSEGV
s += f1({ v: G.items[0] }, (G = mk(6), mk(1)));

Why

A view is made at the call, after every argument has been evaluated. holdGlobalArguments didn't see through views:

  • globalOf stopped at ts.NewInterface, so nothing was held.
  • An object literal holds what it was given with no count until it is boxed for the interface, and that boxing also happens at the call.

Fix (rc only; own is unchanged)

The hold now keeps the value behind the view and retains it where it is read, as #647 does for a plain argument:

  • Cast or interface: the object it is made over.
  • Object literal: each value stored into the literal's slot, whether it is passed boxed for an interface or as a record.

Tests

tests/00global_argument_view.ts covers:

  • an interface over a global and over a global's field
  • a global passed as its base class
  • an object literal holding a global or a global's field, passed as an interface and as a record
  • the same shapes in a loop
  • a later argument that throws inside a try

It runs compiled, under JIT, and in the rc/none corpus. It fails under rc on main on Linux.

Verification

  • ctest -C Release: Windows 4976/4976, WSL Linux 4958/4958.
  • mm_fuzz.py --jobs 10 run --count 500 --seed 1 (the run from rc: hold a global argument from its read, and give a const read of a global a count #647) on Linux: 0 rc failures, down from 7. The 3 own failures (R1, O4) are unchanged.
  • --count 1000 --seed 2: 9 failures, all of which also fail on main. The 5 rc ones are A1 with a local or a parameter, not a global: f(n, (n = mk(), n)). That's a separate bug.

🤖 Generated with Claude Code

A global, or a global's field, given to a call as a view - an interface,
a base class, an object literal holding it - and given a new value by a
later argument of the same call (`f(G, (G = mk(), x))` with an interface
parameter, `f({ v: G.v }, (G = mk(), x))`) was freed before the call ran.

The view is made at the call, after every argument is evaluated, and
holdGlobalArguments did not see through it: `globalOf` stopped at
`ts.NewInterface`, and an object literal holds what it was given with no
count until it is boxed for the interface, at the call too. Under rc the
hold now keeps the value behind the view - the object a cast or an
interface is made over, or each value stored into the literal's slot -
retained where it is read (#647). The fuzzer (#646) found these as A1's
view variant; they failed on #633 as well.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ASDAlexander77
ASDAlexander77 merged commit 787b4ce into main Oct 23, 2026
2 checks passed
@ASDAlexander77
ASDAlexander77 deleted the fix-rc-global-arg-view branch October 23, 2026 03:51
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.

1 participant