-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Fix MIR lowering evaluation order and soundness bug #65608
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
r? @estebank (rust_highfive has picked a reviewer for you, use r? to override) |
ce395ab
to
232f060
Compare
This comment has been minimized.
This comment has been minimized.
232f060
to
0d3a777
Compare
This comment has been minimized.
This comment has been minimized.
0d3a777
to
94b1389
Compare
94b1389
to
683d113
Compare
len: Operand::Move(len), | ||
index: Operand::Copy(Place::from(index)), | ||
}; | ||
// assert!(lt, "...") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// assert!(lt, "...") | |
// assert!(lt, "...") -> bb_success |
@bors try @rust-timer queue |
Awaiting bors try build completion |
Fix MIR lowering evaluation order and soundness bug * Fixes a soundness issue with built-in index operations * Ensures correct evaluation order of assignment expressions where the RHS is a FRU or is a use of a local of reference type. * Removes an unnecessary symbol to string conversion
☀️ Try build successful - checks-azure |
Queued 5c1eaf2 with parent 89e645a, future comparison URL. |
Finished benchmarking try commit 5c1eaf2, comparison URL. |
r? @pnkfelix cc @nikomatsakis (MIR building / soundness changes seem pretty important) |
cc @rust-lang/compiler just to make sure everyone sees it. |
I've skimmed over the changes. I want another chance to go over them more carefully (hopefully Monday), especially 683d113 where it uses |
(also, are there separate issues filed for the bugs being fixed here? It might be useful to have a separate place to track that...) |
683d113
to
4c0cd34
Compare
Ping from triage. Thank you! |
// the index changing later: Nothing will ever change this temporary. | ||
// The "retagging" transformation (for Stacked Borrows) relies on this. | ||
let idx = unpack!(block = this.as_temp( | ||
this.lower_index_expression( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This commit contains a number of refactorings (such as the rewrite of the match
expression above, and the out-of-lining of the expression into its own method here).
I like refactorings, and think these ones make sense, given the state of the code.
But I also think my review would have been much easier (and perhaps would have had a quicker turn around time) if the refactorings were isolated into their own commit that was tagged as a refactoring with no expected semantic effect).
It’s not something that I’m going to demand of this Pull Request. It’s more of a note for the future: I think that isolating refactorings into their own commit(s) is a good habit for PR authors in general.
@bors p=4 |
⌛ Testing commit 4fc8287f9525a9f522e17e5735db57b30778e05c with merge 43bc89a5827b1333476df6a373aac987d3b8de6c... |
The job Click to expand the log.
I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
💔 Test failed - checks-azure |
This appears to be a pre-existing bug. I've minimized the issue to the following this requires a rustc with llvm assertions enabled and I suspect all i686 toolchains are affected: // Only breaks at opt-level=2 or higher.
#![crate_type="lib"]
pub fn check_overlap(ext: &i32) -> usize {
let src_usize = &1 as *const _ as usize;
let dst_usize = ext as *const _ as usize;
let mut diff = src_usize.wrapping_sub(dst_usize);
if src_usize > dst_usize {
diff = diff.wrapping_neg();
};
diff
} |
This comment has been minimized.
This comment has been minimized.
An expression like `x[1][{ x = y; 2}]` would perform the bounds check for the inner index operation before evaluating the outer index. This would allow out of bounds memory accesses.
This fixes some ordering problems around assignment expressions.
3d3b0f9
to
698b347
Compare
I've pushed a work around and have opened #66315 for the CI failure. |
[WIP] Llvm update Asking for a `@bors try`, includes #65608 to verify if it fixes the issue.
698b347
to
4bf0685
Compare
@bors r=pnkfelix p=0 rollup=never |
📌 Commit 4bf0685 has been approved by |
Fix MIR lowering evaluation order and soundness bug * Fixes a soundness issue with built-in index operations * Ensures correct evaluation order of assignment expressions where the RHS is a FRU or is a use of a local of reference type. * Removes an unnecessary symbol to string conversion closes #65909 closes #65910
☀️ Test successful - checks-azure |
Tested on commit rust-lang/rust@4f03f4a. Direct link to PR: <rust-lang/rust#65608> 🎉 rls on linux: test-fail → test-pass (cc @Xanewok, @rust-lang/infra).
closes #65909
closes #65910