You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Dangling raw pointers in constants will ICE in codegen #55353
Compiling playground v0.0.1 (/playground)
warning: unused variable: `x`
--> src/main.rs:10:9
|
10 | let x = FOO;
| ^ help: consider using `_x` instead
|
= note: #[warn(unused_variables)] on by default
error: internal compiler error: librustc_mir/monomorphize/collector.rs:1174: alloc id without corresponding allocation: 3
thread 'main' panicked at 'Box<Any>', librustc_errors/lib.rs:600:9
note: Run with `RUST_BACKTRACE=1` for a backtrace.
error: aborting due to previous error
note: the compiler unexpectedly panicked. this is a bug.
note: we would appreciate a bug report: https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md#bug-reports
note: rustc 1.31.0-nightly (f99911a4a 2018-10-23) running on x86_64-unknown-linux-gnu
note: compiler flags: -C codegen-units=1 -C debuginfo=2 --crate-type bin
note: some of the compiler flags provided by cargo are hidden
error: Could not compile `playground`.
To learn more, run the command again with --verbose.
doesn't handle raw pointers at all, because the assumption is that we can't know anything about raw pointers.
In fact we can know one thing, and that is whether the raw pointer is dangling.
So, expand the condition to handle the ty.is_unsafe_ptr() case and call self.memory.get(place.ptr). If that results in an Ok, then we're good, but if you get an Err, it can essentially only mean that we got a dangling pointer. So you can call validation_failure! with an appropriate error.
Remember to also add a test in src/test/ui/consts to make sure that this doesn't ICE the compiler anymore.
I thought you had #55262 which would bail out during interning when it sees a dangling relocation. That didn't land yet, so I am not surprised we have this ICE.
Activity
oli-obk commentedon Oct 25, 2018
Fix instructions:
The
ifinrust/src/librustc_mir/interpret/validity.rs
Line 211 in 8ec22e7
In fact we can know one thing, and that is whether the raw pointer is dangling.
So, expand the condition to handle the
ty.is_unsafe_ptr()case and callself.memory.get(place.ptr). If that results in anOk, then we're good, but if you get anErr, it can essentially only mean that we got a dangling pointer. So you can callvalidation_failure!with an appropriate error.Remember to also add a test in
src/test/ui/conststo make sure that this doesn't ICE the compiler anymore.RalfJung commentedon Oct 26, 2018
Why do you want to validate raw pointers not to dangle? That seems wrong, they are allowed to.
RalfJung commentedon Oct 26, 2018
I thought you had #55262 which would bail out during interning when it sees a dangling relocation. That didn't land yet, so I am not surprised we have this ICE.
Update and add new test (fixes rust-lang#55353)