Repository navigation
fix(hy-check): track scope depth in pre_moved and LX14 loop jumps on back-edge (fixes #739) - #740
Open
c-viper-work wants to merge 1 commit into
Conversation
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.
Closes #739
Summary
Fixes three soundness bypasses in
Checker::check_loop_backedge(compiler/crates/hy-check/src/freeze.rs,compiler/crates/hy-check/src/lib.rs, andcompiler/crates/hy-check/src/closures.rs) where loop-carried ownership moves (O5.1/O5.2/O13/SPEC LX14) passedhyb checkwith 0 diagnostics and triggered realgo run -racedata races (exit code 66) at runtime:Scope-depth identity for
pre_movedandreported_backedge(lib.rs,closures.rs,freeze.rs):pre_movedandreported_backedgefromHashSet<String>toHashSet<(usize, String)>using theFnState::lookup_depthconvention (0forst.env,i + 1forst.scopes[i]).m(e.g. at depth0) from masking a loop-carried move of a fresh shadowing bindingm(at depthd + 1 <= outer_depth) inside an enclosing block (if,{ ... }, outer loop, or closure), and prevents a back-edge diagnostic on one binding from suppressing diagnostics on a distinct shadowed binding of the same name.SPEC LX14
continue loopreachability across nested finiteforloops (freeze.rs):unlabeled_continue_reachandlabeled_continue_reachinLoopFlowand updatesstmt_has_continue_for_loop,stmt_can_reach_backedge, andstmt_move_can_reach_backedge.continue loop(Stmt::Continue { label: Some(_) }) skips enclosing finiteforloops (ForKind::Range,ForKind::Iterate,ForKind::While) and jumps to the nearest enclosingloop(ForKind::Infinite), while leaving a finiteforwhen that finiteforitself is the loop under check.SPEC LX14
break loopreachability across nested finiteforloops andselect(freeze.rs):unlabeled_break_reachandlabeled_break_reachinLoopFlowsobreak loop(Stmt::Break { label: Some(_) }) inside a nested finitefororselectbinds to the nearest enclosingloop(ForKind::Infinite), accurately modeling exits from an innerloopto a path that reaches the outerloopback-edge.move_span_can_reach_backedgewhentrailing_exitholds so a move on an exiting path before a trailingbreak/returndoes not falsely appear loop-carried alongside an earlier move that reachedcontinue.Verification
Verdict::RejectwithHYB-E3003) and negative (Verdict::Accept) unit tests incompiler/crates/hy-check/src/freeze.rscovering both top-level function and closure-boundary paths../compiler/target/debug/hyb check(HYB-E3003emitted).cargo test --manifest-path compiler/Cargo.toml -p hy-check(1,146 passed, 0 failed)cargo test --manifest-path compiler/Cargo.toml --workspace(1,544 passed, 0 failed)Payout Wallet
0x3018577736ebcdd3ddca916Bef44e7dC6E27e33E