-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Corrupted memory after updated to 1.12 #36936
Comments
This looks like something about drop and drop flags is going awry wrt struct A;
impl Drop for A {
fn drop(&mut self) {
println!("hello");
}
}
fn foo() -> A { A }
fn main() {
let a = &(foo() as A);
println!("here: {:p}", a);
} That prints "hello" before "here", which means we're allowing use of a value after it's been destroyed. |
@paulusx if you're looking for a quick fix then removing |
Here's a shorter repro without any #![crate_type="lib"]
struct A(u32);
impl Drop for A {
fn drop(&mut self) {
self.0 = 0;
}
}
fn foo() -> u32 {
let a = &(A(1) as A);
a.0
} The too-early drop is already present in the debug-mode MIR: bb0: {
/* snip */
_2 = A::A(const 1u32,); // scope 0 at <anon>:12:15: 12:19
_1 = &_2; // scope 0 at <anon>:12:13: 12:25
drop(_2) -> bb1; // scope 0 at <anon>:12:15: 12:19
}
bb1: {
/* snip */
_4 = ((*_1).0: u32); // scope 1 at <anon>:13:5: 13:8
/* ... */ |
cc @rust-lang/compiler |
Will fix. |
that made no sense (see test), and was incompatible with borrowck. Fixes rust-lang#36936.
that made no sense (see test), and was incompatible with borrowck. Fixes rust-lang#36936.
that made no sense (see test), and was incompatible with borrowck. Fixes rust-lang#36936.
Hello!
I see some garbage in memory:
I expect correct return (like with rust 1.11), but I have panic:
Rust 1.12
Rust 1.11
Data corrupted always in last record.
Thanks!
The text was updated successfully, but these errors were encountered: