Repository navigation
-mm=own: a Shared<T> parameter the body assigns is a counted local of its own - #675
Merged
Merged
Conversation
… its own Own steps aside for Shared handles, so it accepted `p = new Shared(..)` on a parameter, but the parameter's slot only borrowed the new handle: assigned in a loop, on a branch, in a try or before a closure captured it, the handle was released at the end of the block that made it and a later `p.value` read freed memory (fuzzer finding O4). Such a parameter is now copied into a local of the same name, as rc and own's string parameters already are. Test own_shared_param_assigned under gc, none, rc and own (+ --verify-ownership). 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.
What
Under
-mm=own, aShared<T>parameter the body assigns is now copied into a counted local of the same name, as rc does for every assigned parameter and own already did for string parameters.Why
Own steps aside for
Sharedhandles, so it acceptedp = new Shared(..)on a parameter, but the parameter's slot only borrowed the new handle. Assigned in a loop, on one branch, in a try, or before a closure captured it, the handle was released at the end of the block that made it, and a laterp.valueread freed memory. This was fuzzer finding O4: own crashed (exit 139/134 on Linux withMALLOC_PERTURB_, and a segfault on Windows for the loop form) while gc and rc printed the right value.Tests
own_shared_param_assignedcovers the loop, branch (taken and not taken), try and closure forms, plus the caller handle's count. It runs under gc, none, rc and own, and under--verify-ownershipfor rc and own. Without the fix it fails under own with "assigned in a loop".🤖 Generated with Claude Code