You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
push onto an array parameter is lost to the caller (stale length/data under gc; crash under rc) #453
A push inside a function onto an array it was given is not seen by the caller. The callee pushes onto its own copy of the array (its pointer and length), so the caller keeps the old length, and reads through the old data pointer after the callee may have reallocated it.
Actual, tslang --emit=jit --no-default-lib, main 8b9d631:
model
output
gc
inside 3, then after 1 0. The length is stale, and list[0] reads 0, not 7
none
the same as gc for the one-push version: len 0
rc
exits with 127 and prints nothing after the callee (the old data block is freed by the reallocation)
The same happens with let list and with the default library under gc (len 0 for a single keepOne(1, list) push).
Found while writing Shared<T> tests (own phase 8): own_shared_count.ts keeps its handles in a class field instead of an array parameter because of this.
Activity
-mm=own phase 8: Shared<T> (spec 23) (#463)
Lowering: one helper knows the array layout (#453 step 1) (#478)
An array is a reference to a header that never moves (#453, #477) (#480)
Arrays grow by doubling (#453 step 3) (#482)