-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Unsoundness in borrowck around deref and mutable refs #29053
Comments
Nominating for P-high. |
The code isn't semantically unsound. In
The problem is just that trans is taking illegal shortcuts. |
@eefriedman Along those lines, in this example: fn main() {
let x: &'static str = "x";
{
let z = &mut &*x;
*z = "z";
}
println!("{:?}", x);
} the code compiles, runs, and prints |
@apasel422 Yes, same bug. |
The same bug is coming up for me when I use html5ever. |
triage: P-high My preferred fix would be to go through MIR, but this may be worth fixing another way. |
cc me |
triage: p-medium Another one that will be fixed by MIR, but not soon. If we think this is higher priority than that we should go back to p-high, but we should make a plan to actually fix it. |
It would make Rust advocacy a lot easier if bugs like this one were fixed before MIR. The typechecker and borrow checker are the reasons many people would choose Rust over other languages. The rewrite of the compiler (MIR) is likely to cause induce bugs itself, so I think a lot of people would like to see a very good stable release before MIR, to allow for skipping the first few (at least) MIR-based releases. |
Variations of this bug were one of the primary motivations for MIR - the code that is supposed to be handling this part is horrible and we don't want to make changes to it out of fear of introducing new bugs. I think we will have MIR-based trans+borrowck at 1.8 if not before. |
This seems to be fixed on nightly (but still crashes on stable & beta): https://is.gd/KqgBhe |
Only thing left to do here is land a test for it. |
I can add that. |
Add test for issue rust-lang#29053 This PR adds a test for rust-lang#29053 (currently fails on stage 0, but works with stage 1, as it should). Fixes rust-lang#29053
Add test for issue rust-lang#29053 This PR adds a test for rust-lang#29053 (currently fails on stage 0, but works with stage 1, as it should). Fixes rust-lang#29053
Add test for issue rust-lang#29053 This PR adds a test for rust-lang#29053 (currently fails on stage 0, but works with stage 1, as it should). Fixes rust-lang#29053
Stable and nightly happily compile the following:
Running the program on my local Ubuntu machine yields:
The playpen yields different results depending on whether debug or release mode is chosen.
Someone is welcome to retitle this issue more accurately.
The text was updated successfully, but these errors were encountered: