Repository navigation
rc: a const bound method with a declared type holds its object - #662
Merged
Merged
Conversation
`const c: () => number = G.items[0].get`: the declared type casts the bound method to a hybrid function, and viewedValue did not look through that cast, so processConstRef saw no bound method over a read of a field, an element, a global or a local. The const was folded with no count, and `G = mk()` freed the object `c()` still ran on. viewedValue now strips casts first. Fuzzer (#646), 80194. 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.
Fixes fuzzer repro 80194 (#646), found in a fresh range (80001). It fails on main.
Why
Under rc, a const made over a read of a field, an element, a global or a local holds a count of its own (
processConstRef,needsIdentityStorage). That includes an interface or a bound method made over such a read, which #644 covered.viewedValuefinds the value a bound method is made over, but it didn't look through casts. A declared type (const c: () => number = ...) casts the bound method to a hybrid function, so no read was seen. The const was then folded, with no count.Fix
viewedValuestrips casts before it looks for the interface or the bound method. Its callers already handle what it returns.Tests
tests/00const_bound_method_declared_type.tshas a declared-type bound method over each of:Each case fails on its own under rc on Linux without the fix. The object's
xis its first field, so the bytes glibc writes into a freed block overwrite it. The test runs compiled, under JIT, and in the rc/none corpus.Verification
ctest -C Release: Windows 5316/5316, measured before An element is stored into once the value is ready #658 was merged in (that merge had no conflicts).🤖 Generated with Claude Code