Repository navigation
fix(hy-check): enforce freeze and loan windows across defer and call-arg moves (fixes #98) - #513
Closed
gelismarvel wants to merge 1 commit into
Closed
gelismarvel wants to merge 1 commit into
gelismarvel wants to merge 1 commit into
Conversation
Contributor
Author
|
Closing this PR. On review, its changes substantially duplicate the earlier PR #99 by @sonson0910, so it should not have been submitted as separate work. Withdrawing it (and any bounty claim attached to it) in favor of the original. Apologies for the noise. |
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 #98
Closes the
Stmt::Deferand call-argumentmovesoundness bypasses where deferred calls andmovearguments in ordinary calls escapedA1b/A7freeze andA2/A3loan windows (HYB-E3003,HYB-E3004,HYB-E3101,HYB-E3102):Stmt::Deferexecution-at-exit freeze (freeze.rs,model.rs,loans.rs,lib.rs,closures.rs):Stmt::Defer { call, .. }inFnState::deferred_usespaired with their(scope_depth, name)connected storage group (scoped_binding_groupviastorage_component).moveor consuming API call (mark_move) transfers ownership of a binding in that storage group before function exit, emitHYB-E3003(A1b/A7) for the deferred use that will execute at function exit after the transfer.transfer_deferred_uses_before_sever).Stmt::Deferloan window extension (walk.rs,loans.rs,lib.rs):last_useof bindings referenced inStmt::Defertofn_end(flatten_with_results) and passSome(fn_end)asloop_endwhen processing calls insideStmt::Defer, so handle borrow loans (A2/A7) and&m[k]map-slot loans (A3) insidedeferremain live until function exit.movetransfers (lib.rs,freeze.rs,loans.rs):moveoperands inside call arguments andStmt::Deferviaprocess_expr_moves/process_defer_movessoeat(move m)andm2 := id(move m)freezem(HYB-E3003), validate non-owned moves (HYB-E3004), and propagatenon_owned_origin.Verification
compiler/crates/hy-check/src/lib.rs(defer_use_before_move_rejects_a1b_e3003,defer_alias_use_before_move_rejects_a1b_e3003,defer_use_before_consume_rejects_a7_e3003,defer_extends_map_slot_and_handle_borrow_loans_to_fn_exit,defer_move_freezes_binding_and_validates_non_owned,call_arg_move_freezes_binding_and_propagates_non_owned).cargo test --manifest-path compiler/Cargo.toml -p hy-checkpasses (143/143unit tests + all integration tests,0warnings).