Repository navigation
rc: a store through an interface hands the count over, as a store into the field does - #434
Merged
Merged
Conversation
…o the field does Under -mm=rc, `i.o = x` (an interface's field) neither retained x nor released what the field held: isOwningSlot did not know an InterfaceSymbolRefOp's reference. The replaced value leaked (a loop doing it grew ~100 bytes an iteration), and the stored one kept no reference of its own, so a `new` stored that way was freed at the end of the storing function while the field still pointed at it - read back later, it gave whatever was allocated over it. A field reached through an interface belongs to the object behind it - a class instance releases it, a literal's box retained it when boxed - so isOwningSlot now answers yes for it (isOwnedInterfaceFieldSlot). 00owned_interfaces.ts gains both shapes (class instance, boxed literal); they allocate over freed blocks with fillers kept alive, as churn()'s freed-at-once fillers reused one block and missed it. Both fail without the fix. 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.
Problem
Under
-mm=rc, a store through an interface,i.o = x, neither retainedxnor released the value the field held, becauseisOwningSlotdidn't recognise the reference anInterfaceSymbolRefOpgives. That caused two failures:newstored this way was freed at the end of the storing function while the field still pointed at it. Read back later, it returned whatever had been allocated over it:999instead of31.Fix
A field reached through an interface belongs to the object behind it. A class instance releases it through its release routine, and a literal's box retained it when the literal was boxed (
castTupleToInterface). SoisOwningSlotnow answers yes for such a field (isOwnedInterfaceFieldSlot), andi.o = xretains and releases exactly asobj.o = xdoes.Tests
00owned_interfaces.tsgains both shapes: a store into a class instance and a store into a boxed literal, each read back in another function.churn()frees each filler at once, so it kept reusing one block and missed this bug.-mm=own.🤖 Generated with Claude Code