Skip to content

adjust for ERR_ON_PARTIAL_PTR_OVERWRITE #1854

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Aug 2, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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