Closed as not planned
Closed as not planned
Description
#![feature(strict_provenance)]
fn main() {
let x = 0u8;
let original_ptr = &x as *const u8;
let addr = original_ptr.expose_addr();
let new_ptr: *const u8 = core::ptr::from_exposed_addr(addr);
unsafe {
dbg!(*new_ptr);
}
}
error: Undefined Behavior: dereferencing pointer failed: 0x27c02 is not a valid pointer
--> src/main.rs:8:9
|
8 | dbg!(*new_ptr);
| ^^^^^^^^^^^^^^ dereferencing pointer failed: 0x27c02 is not a valid pointer
|
= help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
= help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information
= note: inside `main` at /home/ben/.rustup/toolchains/miri/lib/rustlib/src/rust/library/std/src/macros.rs:315:13
= note: this error originates in the macro `dbg` (in Nightly builds, run with -Z macro-backtrace for more info)
note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace
error: aborting due to previous error
I understand why this happens, but this is if nothing else incredibly surprising for users. The intuition is that the Strict Provenance mode in Miri should be compatible with the Strict Provenance APIs in the standard library. Could we make that happen? Or will this just be closed by the permissive provenance work?