Skip to content

Commit

Permalink
Auto merge of #1854 - RalfJung:partial-ptr-overwrite, r=RalfJung
Browse files Browse the repository at this point in the history
adjust for ERR_ON_PARTIAL_PTR_OVERWRITE

The Miri side of rust-lang/rust#87248
  • Loading branch information
bors committed Aug 2, 2021
2 parents 1f969da + 3a92228 commit 99ec9c1
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion rust-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3bc9dd0dd293ab82945e35888ed6d7ab802761ef
3227e35765bab6d02c581928e26ad1d34bacf394
6 changes: 5 additions & 1 deletion src/machine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,13 +123,17 @@ impl fmt::Display for MiriMemoryKind {
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct Tag {
pub alloc_id: AllocId,
// Stacked Borrows tag.
/// Stacked Borrows tag.
pub sb: SbTag,
}

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

/// We cannot err on partial overwrites, it happens too often in practice (due to unions).
const ERR_ON_PARTIAL_PTR_OVERWRITE: bool = false;

fn fmt(ptr: &Pointer<Self>, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let (tag, addr) = ptr.into_parts(); // address is absolute
write!(f, "0x{:x}", addr.bytes())?;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
// Make sure we find these even with many checks disabled.
// compile-flags: -Zmiri-disable-alignment-check -Zmiri-disable-stacked-borrows -Zmiri-disable-validation

// Test what happens when we overwrite parts of a pointer.
// Also see <https://github.com/rust-lang/rust/issues/87184>.

fn main() {
let mut p = &42;
unsafe {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// Test what happens when we read parts of a pointer.
// Related to <https://github.com/rust-lang/rust/issues/69488>.
fn main() {
let x = 13;
let y = &x;
Expand Down

0 comments on commit 99ec9c1

Please sign in to comment.