Skip to content

Commit 5338a16

Browse files
committed
adjust for ERR_ON_PARTIAL_PTR_OVERWRITE
1 parent 1f969da commit 5338a16

File tree

3 files changed

+9
-0
lines changed

3 files changed

+9
-0
lines changed

src/machine.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,12 @@ pub struct Tag {
128128
}
129129

130130
impl Provenance for Tag {
131+
// We use absolute addresses in the `offset` of a `Pointer<Tag>`.
131132
const OFFSET_IS_ADDR: bool = true;
132133

134+
// We cannot err on partial overwrites, it happens too often in practice (due to unions).
135+
const ERR_ON_PARTIAL_PTR_OVERWRITE: bool = false;
136+
133137
fn fmt(ptr: &Pointer<Self>, f: &mut fmt::Formatter<'_>) -> fmt::Result {
134138
let (tag, addr) = ptr.into_parts(); // address is absolute
135139
write!(f, "0x{:x}", addr.bytes())?;
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
// Make sure we find these even with many checks disabled.
22
// compile-flags: -Zmiri-disable-alignment-check -Zmiri-disable-stacked-borrows -Zmiri-disable-validation
33

4+
// Test what happens when we overwrite parts of a pointer.
5+
// Also see <https://github.com/rust-lang/rust/issues/87184>.
6+
47
fn main() {
58
let mut p = &42;
69
unsafe {

tests/compile-fail/pointer_byte_read.rs renamed to tests/compile-fail/pointer_partial_read.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// Test what happens when we read parts of a pointer.
2+
// Related to <https://github.com/rust-lang/rust/issues/69488>.
13
fn main() {
24
let x = 13;
35
let y = &x;

0 commit comments

Comments
 (0)