Repository navigation
Two fuzz rounds: own keeper literal elements, own parameters given a local's value, rc arguments read through a parameter's object - #752
Merged
Conversation
… a local's value A round of mm_fuzz.py (400 programs, seeds 70000-70399) found 10 own failures and no rc ones. Two causes: - A keeper (an append-only array global) makes what is pushed onto it immortal, and reads of its elements own nothing. `const GA: N[] = [mk(5)]` was taken for one, but the elements its literal is made with were never made immortal, so a local given `GA[0]` freed it when its block ended (9 of the 10). An array literal of anything but constants makes no keeper now. - `p = n` with `p` a parameter stored `n`'s value in a slot that owns nothing, with no retain for own to judge, so `n = mk()` then freed what `p` read. Own reported an assigned parameter only while explaining a retain; a store of a value that owns a block into a parameter's slot is reported now, unless the value is another parameter's, which the caller holds for the whole call. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…a call that writes a global A second fuzz round (600 programs, seeds 71000-71599, on main with #751 and this branch) found no own failures in 1101 checked programs, and one rc crash: `g(p.n)` where `p` was a global's object (`f(HG)`) and `g` did `HG.n = mk(5)`. The argument was borrowed with no count, so the store freed it while `g` still read it, or after `g` gave it back. An argument read out of a global itself was already held across such a call (#647). An argument read out of a field or an element of an object a parameter names is now held too, when the callee may give any global a new value. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A round of
tslang/test/fuzz/mm_fuzz.pyfound 10-mm=ownfailures (400 programs, seeds 70000-70399, 732 checked): 8 crashes and 2 wrong values. rc had none. They come from two causes.Elements of a keeper's array literal were freed (9 of the 10)
A keeper is an append-only array global. Own makes everything pushed onto it immortal, so a read of one of its elements owns nothing and every release skips it. But
const GA: N[] = [mk(5)]was also taken for a keeper, and the elements its literal is made with were never made immortal. So{ let n = GA[0]; }freedGA[0]when the block ended.Now an array literal makes a keeper only when every element is a constant. Elements of other literals are borrowed like any array's, and own rejects storing one into another array or a global.
A parameter given a local's value was accepted
In
p = n; n = mk(9); return p.x,p = nstoredn's object into a parameter's slot. That slot owns nothing, so there was no retain. Own reports "is a parameter and cannot be assigned" only while explaining a retain it could not place, so nothing was reported. Thenn = mk(9)freed the objectpstill read.A store of a value that owns a block into a parameter's slot is now reported in
collectOwnershipOps. One exception: a value read from another parameter (iter = other, asown_for_of_borrowed_iterator.tsdoes) is still allowed, because the caller holds both for the whole call. Without--dithe message reads "a parameter cannot be assigned under -mm=own yet", since no parameter name is known.A second round: an argument read through a parameter's object (rc)
A second round (600 programs, seeds 71000-71599, on main with #751 and this branch) found no own failures in 1101 checked programs. It found one rc crash:
g(p.n)wherepwas a global's object (f(HG)), andgdidHG.n = mk(5). The argument was borrowed with no count, so the store freed it whilegstill read it, or afterggave it back.An argument read out of a global itself was already held across such a call (#647). Now, in
holdGlobalArguments, an argument read out of a field or an element of an object a parameter names is held too, whenever the callee may give any global a new value.00call_arg_param_field_global.tscovers this under gc, rc and none; own rejects it.Tests
own/own_keeper_literal_elements.tsruns under own, gc and rc, in JIT and AOT.own/own_err_param_assigned_local.tschecks the new error.src/lib.ts) still compiles under own and rc.🤖 Generated with Claude Code