Repository navigation
fix(hy-check): reject moving may-share peers of non-owned bindings (fixes #75) - #80
Closed
rickymulya wants to merge 1 commit into
Closed
rickymulya wants to merge 1 commit into
rickymulya wants to merge 1 commit into
Conversation
…ixes limitlessprojects#75) In `check_non_owned_move`, if the binding's own origin and alias-root origin are `None`, check `st.share_group(name)` (and alias root) for any peer binding carrying a `non_owned_origin`. Shallow copies (structs, arrays, slices, projections) of parameters or closure captures retain aliasing in the caller, violating O5.1 and escaping HYB-E3004. - hy-check/src/freeze.rs: inspect sorted peers from `share_group` for `non_owned_origin`. - hy-check/src/lib.rs: add regression unit tests for struct parameter peer, array parameter peer, and positive control for purely local struct copy.
Owner
|
Your fix is on |
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.
Summary
Fixes #75.
Moving a may-share peer of a non-owned binding (e.g. shallow struct or array copy of a parameter:
h2 := h; task worker(move h2)) escaped the O5.1 non-owned check, causingfatal error: concurrent map writesat runtime.Root Cause & Fix
In
compiler/crates/hy-check/src/freeze.rs::check_non_owned_move, the check inspected only the binding's immediatenon_owned_originand its direct alias-root. Unlikefreeze_binding(which unions inst.share_group(&m)to capture shallow struct/array copies and slices),check_non_owned_movedid not consult the may-share graph.Fix:
When the binding's own origin and direct alias root have
non_owned_origin: None,check_non_owned_movenow inspects sorted peers inst.share_group(name)(andst.share_group(&root)). If any peer in the connected component originated from a non-owned source (parameter, closure capture, range variable), the move is rejected withHYB-E3004under O5.1 / O5.4.Tests
Added regression cases in
compiler/crates/hy-check/src/lib.rs::non_owned_param_capture_and_range_moves_reject_e3004:h2 := h; task worker(move h2)): rejected withHYB-E3004.a2 := a; task worker(move a2)): rejected withHYB-E3004.h := holder{...}; h2 := h; task worker(move h2)): accepted cleanly.