-
Notifications
You must be signed in to change notification settings - Fork 12.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of #122249 - RalfJung:machine-read-hook, r=oli-obk
interpret: do not call machine read hooks during validation Fixes rust-lang/miri#3347 r? ``@oli-obk``
- Loading branch information
Showing
6 changed files
with
107 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#![feature(start)] | ||
#![no_std] | ||
//@compile-flags: -Zmiri-track-alloc-id=17 -Zmiri-track-alloc-accesses -Cpanic=abort | ||
//@only-target-linux: alloc IDs differ between OSes for some reason | ||
|
||
extern "Rust" { | ||
fn miri_alloc(size: usize, align: usize) -> *mut u8; | ||
fn miri_dealloc(ptr: *mut u8, size: usize, align: usize); | ||
} | ||
|
||
#[start] | ||
fn start(_: isize, _: *const *const u8) -> isize { | ||
unsafe { | ||
let ptr = miri_alloc(123, 1); | ||
*ptr = 42; // Crucially, only a write is printed here, no read! | ||
assert_eq!(*ptr, 42); | ||
miri_dealloc(ptr, 123, 1); | ||
} | ||
0 | ||
} | ||
|
||
#[panic_handler] | ||
fn panic_handler(_: &core::panic::PanicInfo) -> ! { | ||
loop {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
note: tracking was triggered | ||
--> $DIR/alloc-access-tracking.rs:LL:CC | ||
| | ||
LL | let ptr = miri_alloc(123, 1); | ||
| ^^^^^^^^^^^^^^^^^^ created Miri bare-metal heap allocation of 123 bytes (alignment ALIGN bytes) with id 17 | ||
| | ||
= note: BACKTRACE: | ||
= note: inside `start` at $DIR/alloc-access-tracking.rs:LL:CC | ||
|
||
note: tracking was triggered | ||
--> $DIR/alloc-access-tracking.rs:LL:CC | ||
| | ||
LL | *ptr = 42; // Crucially, only a write is printed here, no read! | ||
| ^^^^^^^^^ write access to allocation with id 17 | ||
| | ||
= note: BACKTRACE: | ||
= note: inside `start` at $DIR/alloc-access-tracking.rs:LL:CC | ||
|
||
note: tracking was triggered | ||
--> $DIR/alloc-access-tracking.rs:LL:CC | ||
| | ||
LL | assert_eq!(*ptr, 42); | ||
| ^^^^^^^^^^^^^^^^^^^^ read access to allocation with id 17 | ||
| | ||
= note: BACKTRACE: | ||
= note: inside `start` at RUSTLIB/core/src/macros/mod.rs:LL:CC | ||
= note: this note originates in the macro `assert_eq` (in Nightly builds, run with -Z macro-backtrace for more info) | ||
|
||
note: tracking was triggered | ||
--> $DIR/alloc-access-tracking.rs:LL:CC | ||
| | ||
LL | miri_dealloc(ptr, 123, 1); | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^ freed allocation with id 17 | ||
| | ||
= note: BACKTRACE: | ||
= note: inside `start` at $DIR/alloc-access-tracking.rs:LL:CC | ||
|