repo
stringlengths
6
65
file_url
stringlengths
81
311
file_path
stringlengths
6
227
content
stringlengths
0
32.8k
language
stringclasses
1 value
license
stringclasses
7 values
commit_sha
stringlengths
40
40
retrieved_at
stringdate
2026-01-04 15:31:58
2026-01-04 20:25:31
truncated
bool
2 classes
rust-lang/rust
https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/miri/tests/fail/stacked_borrows/zst_slice.rs
src/tools/miri/tests/fail/stacked_borrows/zst_slice.rs
//@compile-flags: -Zmiri-strict-provenance fn main() { unsafe { let a = [1, 2, 3]; let s = &a[0..0]; assert_eq!(s.len(), 0); assert_eq!(*s.as_ptr().add(1), 2); //~ ERROR: /retag .* tag does not exist in the borrow stack/ } }
rust
Apache-2.0
f8b1d59a81c700cb7aa25cf69e3032b3ce333150
2026-01-04T15:31:58.503980Z
false
rust-lang/rust
https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/miri/tests/fail/stacked_borrows/static_memory_modification.rs
src/tools/miri/tests/fail/stacked_borrows/static_memory_modification.rs
static X: usize = 5; #[allow(mutable_transmutes)] fn main() { let _x = unsafe { std::mem::transmute::<&usize, &mut usize>(&X) //~ ERROR: writing to alloc1 which is read-only }; }
rust
Apache-2.0
f8b1d59a81c700cb7aa25cf69e3032b3ce333150
2026-01-04T15:31:58.503980Z
false
rust-lang/rust
https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/miri/tests/fail/stacked_borrows/disable_mut_does_not_merge_srw.rs
src/tools/miri/tests/fail/stacked_borrows/disable_mut_does_not_merge_srw.rs
// This tests demonstrates the effect of 'Disabling' mutable references on reads, rather than // removing them from the stack -- the latter would 'merge' neighboring SRW groups which we would // like to avoid. fn main() { unsafe { let mut mem = 0; let base = &mut mem as *mut i32; // the base pointer...
rust
Apache-2.0
f8b1d59a81c700cb7aa25cf69e3032b3ce333150
2026-01-04T15:31:58.503980Z
false
rust-lang/rust
https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/miri/tests/fail/stacked_borrows/pass_invalid_mut.rs
src/tools/miri/tests/fail/stacked_borrows/pass_invalid_mut.rs
// Make sure that we cannot pass by argument a `&mut` that got already invalidated. fn foo(_: &mut i32) {} fn main() { let x = &mut 42; let xraw = x as *mut _; let xref = unsafe { &mut *xraw }; let _val = unsafe { *xraw }; // invalidate xref foo(xref); //~ ERROR: /retag .* tag does not exist in the...
rust
Apache-2.0
f8b1d59a81c700cb7aa25cf69e3032b3ce333150
2026-01-04T15:31:58.503980Z
false
rust-lang/rust
https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/miri/tests/fail/stacked_borrows/illegal_write3.rs
src/tools/miri/tests/fail/stacked_borrows/illegal_write3.rs
#![allow(invalid_reference_casting)] fn main() { let target = 42; // Make sure raw ptr with raw tag cannot mutate frozen location without breaking the shared ref. let r#ref = &target; // freeze let ptr = r#ref as *const _ as *mut _; // raw ptr, with raw tag unsafe { *ptr = 42 }; //~ ERROR: /write a...
rust
Apache-2.0
f8b1d59a81c700cb7aa25cf69e3032b3ce333150
2026-01-04T15:31:58.503980Z
false
rust-lang/rust
https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/miri/tests/fail/stacked_borrows/drop_in_place_retag.rs
src/tools/miri/tests/fail/stacked_borrows/drop_in_place_retag.rs
//! Test that drop_in_place mutably retags the entire place, even for a type that does not need //! dropping, ensuring among other things that it is writeable //@error-in-other-file: /retag .* for Unique permission .* only grants SharedReadOnly permission/ fn main() { unsafe { let x = 0u8; let x =...
rust
Apache-2.0
f8b1d59a81c700cb7aa25cf69e3032b3ce333150
2026-01-04T15:31:58.503980Z
false
rust-lang/rust
https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/miri/tests/fail/stacked_borrows/shared_rw_borrows_are_weak1.rs
src/tools/miri/tests/fail/stacked_borrows/shared_rw_borrows_are_weak1.rs
// We want to test that granting a SharedReadWrite will be added // *below* an already granted Unique -- so writing to // the SharedReadWrite will invalidate the Unique. use std::cell::Cell; use std::mem; fn main() { unsafe { let x = &mut Cell::new(0); let y: &mut Cell<i32> = mem::transmute(&mut *...
rust
Apache-2.0
f8b1d59a81c700cb7aa25cf69e3032b3ce333150
2026-01-04T15:31:58.503980Z
false
rust-lang/rust
https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/miri/tests/fail/stacked_borrows/fnentry_invalidation2.rs
src/tools/miri/tests/fail/stacked_borrows/fnentry_invalidation2.rs
// Regression test for https://github.com/rust-lang/miri/issues/2536 // This tests that we don't try to back too far up the stack when selecting a span to report. // We should display the as_mut_ptr() call as the location of the invalidation, not the call to // inner struct Thing<'a> { sli: &'a mut [i32], } fn ma...
rust
Apache-2.0
f8b1d59a81c700cb7aa25cf69e3032b3ce333150
2026-01-04T15:31:58.503980Z
false
rust-lang/rust
https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/miri/tests/fail/stacked_borrows/illegal_dealloc1.rs
src/tools/miri/tests/fail/stacked_borrows/illegal_dealloc1.rs
use std::alloc::{Layout, alloc, dealloc}; fn main() { unsafe { let x = alloc(Layout::from_size_align_unchecked(1, 1)); let ptr1 = (&mut *x) as *mut u8; let ptr2 = (&mut *ptr1) as *mut u8; // Invalidate ptr2 by writing to ptr1. ptr1.write(0); // Deallocate through ptr...
rust
Apache-2.0
f8b1d59a81c700cb7aa25cf69e3032b3ce333150
2026-01-04T15:31:58.503980Z
false
rust-lang/rust
https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/miri/tests/fail/stacked_borrows/track_caller.rs
src/tools/miri/tests/fail/stacked_borrows/track_caller.rs
// This is a copy of illegal_read1.rs, but with #[track_caller] on the test. // This test only checks that our diagnostics do not display the contents of callee. #[rustfmt::skip] // rustfmt bug: https://github.com/rust-lang/rustfmt/issues/5391 fn main() { let mut x = 15; let xraw = &mut x as *mut _; let xr...
rust
Apache-2.0
f8b1d59a81c700cb7aa25cf69e3032b3ce333150
2026-01-04T15:31:58.503980Z
false
rust-lang/rust
https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/miri/tests/fail/stacked_borrows/illegal_read6.rs
src/tools/miri/tests/fail/stacked_borrows/illegal_read6.rs
// Creating a shared reference does not leak the data to raw pointers. fn main() { unsafe { let x = &mut 0; let raw = x as *mut _; let x = &mut *x; // kill `raw` let _y = &*x; // this should not activate `raw` again let _val = *raw; //~ ERROR: /read access .* tag does not exi...
rust
Apache-2.0
f8b1d59a81c700cb7aa25cf69e3032b3ce333150
2026-01-04T15:31:58.503980Z
false
rust-lang/rust
https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/miri/tests/fail/stacked_borrows/interior_mut1.rs
src/tools/miri/tests/fail/stacked_borrows/interior_mut1.rs
use std::cell::UnsafeCell; fn main() { unsafe { let c = &UnsafeCell::new(UnsafeCell::new(0)); let inner_uniq = &mut *c.get(); // stack: [c: SharedReadWrite, inner_uniq: Unique] let inner_shr = &*inner_uniq; // adds a SharedReadWrite // stack: [c: SharedReadWrite, inner_uniq...
rust
Apache-2.0
f8b1d59a81c700cb7aa25cf69e3032b3ce333150
2026-01-04T15:31:58.503980Z
false
rust-lang/rust
https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/miri/tests/fail/stacked_borrows/return_invalid_mut.rs
src/tools/miri/tests/fail/stacked_borrows/return_invalid_mut.rs
// Make sure that we cannot return a `&mut` that got already invalidated. fn foo(x: &mut (i32, i32)) -> &mut i32 { let xraw = x as *mut (i32, i32); let ret = unsafe { &mut (*xraw).1 }; let _val = unsafe { *xraw }; // invalidate xref ret //~ ERROR: /retag .* tag does not exist in the borrow stack/ } fn ...
rust
Apache-2.0
f8b1d59a81c700cb7aa25cf69e3032b3ce333150
2026-01-04T15:31:58.503980Z
false
rust-lang/rust
https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/miri/tests/fail/stacked_borrows/return_invalid_mut_option.rs
src/tools/miri/tests/fail/stacked_borrows/return_invalid_mut_option.rs
// Make sure that we cannot return a `&mut` that got already invalidated, not even in an `Option`. fn foo(x: &mut (i32, i32)) -> Option<&mut i32> { let xraw = x as *mut (i32, i32); let ret = unsafe { &mut (*xraw).1 }; // let-bind to avoid 2phase let ret = Some(ret); let _val = unsafe { *xraw }; // inval...
rust
Apache-2.0
f8b1d59a81c700cb7aa25cf69e3032b3ce333150
2026-01-04T15:31:58.503980Z
false
rust-lang/rust
https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/miri/tests/fail/stacked_borrows/illegal_read3.rs
src/tools/miri/tests/fail/stacked_borrows/illegal_read3.rs
// A callee may not read the destination of our `&mut` without us noticing. // This code got carefully checked to not introduce any reborrows // that are not explicit in the source. Let's hope the compiler does not break this later! use std::mem; union HiddenRef { // We avoid retagging at this type, and we only r...
rust
Apache-2.0
f8b1d59a81c700cb7aa25cf69e3032b3ce333150
2026-01-04T15:31:58.503980Z
false
rust-lang/rust
https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/miri/tests/fail/stacked_borrows/retag_data_race_read.rs
src/tools/miri/tests/fail/stacked_borrows/retag_data_race_read.rs
//! Make sure that a retag acts like a read for the data race model. //@compile-flags:-Zmiri-deterministic-concurrency #[derive(Copy, Clone)] struct SendPtr(*mut u8); unsafe impl Send for SendPtr {} fn thread_1(p: SendPtr) { let p = p.0; unsafe { let _r = &*p; } } fn thread_2(p: SendPtr) { le...
rust
Apache-2.0
f8b1d59a81c700cb7aa25cf69e3032b3ce333150
2026-01-04T15:31:58.503980Z
false
rust-lang/rust
https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/miri/tests/fail/stacked_borrows/transmute-is-no-escape.rs
src/tools/miri/tests/fail/stacked_borrows/transmute-is-no-escape.rs
// Make sure we cannot use raw ptrs that got transmuted from mutable references // (i.e, no EscapeToRaw happened). // We could, in principle, do EscapeToRaw lazily to allow this code, but that // would no alleviate the need for EscapeToRaw (see `ref_raw_int_raw` in // `run-pass/stacked-borrows.rs`), and thus increase o...
rust
Apache-2.0
f8b1d59a81c700cb7aa25cf69e3032b3ce333150
2026-01-04T15:31:58.503980Z
false
rust-lang/rust
https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/miri/tests/fail/stacked_borrows/drop_in_place_protector.rs
src/tools/miri/tests/fail/stacked_borrows/drop_in_place_protector.rs
//! Test that drop_in_place retags the entire place, //! invalidating all aliases to it. // A zero-sized drop type -- the retagging of `fn drop` itself won't // do anything (since it is zero-sized); we are entirely relying on the retagging // in `drop_in_place` here. #[repr(transparent)] struct HasDrop; impl Drop for ...
rust
Apache-2.0
f8b1d59a81c700cb7aa25cf69e3032b3ce333150
2026-01-04T15:31:58.503980Z
false
rust-lang/rust
https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/miri/tests/fail/stacked_borrows/retag_data_race_protected_read.rs
src/tools/miri/tests/fail/stacked_borrows/retag_data_race_protected_read.rs
//@compile-flags:-Zmiri-deterministic-concurrency use std::thread; #[derive(Copy, Clone)] struct SendPtr(*mut i32); unsafe impl Send for SendPtr {} fn main() { let mut mem = 0; let ptr = SendPtr(&mut mem as *mut _); let t = thread::spawn(move || { let ptr = ptr; // We do a protected mutab...
rust
Apache-2.0
f8b1d59a81c700cb7aa25cf69e3032b3ce333150
2026-01-04T15:31:58.503980Z
false
rust-lang/rust
https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/miri/tests/fail/stacked_borrows/fnentry_invalidation.rs
src/tools/miri/tests/fail/stacked_borrows/fnentry_invalidation.rs
// Test that spans displayed in diagnostics identify the function call, not the function // definition, as the location of invalidation due to FnEntry retag. Technically the FnEntry retag // occurs inside the function, but what the user wants to know is which call produced the // invalidation. fn main() { let mut x...
rust
Apache-2.0
f8b1d59a81c700cb7aa25cf69e3032b3ce333150
2026-01-04T15:31:58.503980Z
false
rust-lang/rust
https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/miri/tests/fail/stacked_borrows/illegal_read5.rs
src/tools/miri/tests/fail/stacked_borrows/illegal_read5.rs
// We *can* have aliasing &RefCell<T> and &mut T, but we cannot read through the former. // Else we couldn't optimize based on the assumption that `xref` below is truly unique. //@normalize-stderr-test: "0x[0-9a-fA-F]+" -> "$$HEX" use std::cell::RefCell; use std::{mem, ptr}; #[rustfmt::skip] // rustfmt bug: https://g...
rust
Apache-2.0
f8b1d59a81c700cb7aa25cf69e3032b3ce333150
2026-01-04T15:31:58.503980Z
false
rust-lang/rust
https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/miri/tests/fail/stacked_borrows/invalidate_against_protector1.rs
src/tools/miri/tests/fail/stacked_borrows/invalidate_against_protector1.rs
fn inner(x: *mut i32, _y: &mut i32) { // If `x` and `y` alias, retagging is fine with this... but we really // shouldn't be allowed to use `x` at all because `y` was assumed to be // unique for the duration of this call. let _val = unsafe { *x }; //~ ERROR: protect } fn main() { let mut x = 0; ...
rust
Apache-2.0
f8b1d59a81c700cb7aa25cf69e3032b3ce333150
2026-01-04T15:31:58.503980Z
false
rust-lang/rust
https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/miri/tests/fail/stacked_borrows/unescaped_local.rs
src/tools/miri/tests/fail/stacked_borrows/unescaped_local.rs
//@compile-flags: -Zmiri-permissive-provenance // Make sure we cannot use raw ptrs to access a local that // we took the direct address of. fn main() { let mut x = 42; let raw = &mut x as *mut i32 as usize as *mut i32; let _ptr = &mut x; unsafe { *raw = 13; //~ ERROR: /write access .* no expose...
rust
Apache-2.0
f8b1d59a81c700cb7aa25cf69e3032b3ce333150
2026-01-04T15:31:58.503980Z
false
rust-lang/rust
https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/miri/tests/fail/stacked_borrows/illegal_write2.rs
src/tools/miri/tests/fail/stacked_borrows/illegal_write2.rs
#![allow(dropping_references)] fn main() { let target = &mut 42; let target2 = target as *mut _; drop(&mut *target); // reborrow // Now make sure our ref is still the only one. unsafe { *target2 = 13 }; //~ ERROR: /write access .* tag does not exist in the borrow stack/ let _val = *target; }
rust
Apache-2.0
f8b1d59a81c700cb7aa25cf69e3032b3ce333150
2026-01-04T15:31:58.503980Z
false
rust-lang/rust
https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/miri/tests/fail/stacked_borrows/unescaped_static.rs
src/tools/miri/tests/fail/stacked_borrows/unescaped_static.rs
static ARRAY: [u8; 2] = [0, 1]; fn main() { let ptr_to_first = &ARRAY[0] as *const u8; // Illegally use this to access the 2nd element. let _val = unsafe { *ptr_to_first.add(1) }; //~ ERROR: /read access .* tag does not exist in the borrow stack/ }
rust
Apache-2.0
f8b1d59a81c700cb7aa25cf69e3032b3ce333150
2026-01-04T15:31:58.503980Z
false
rust-lang/rust
https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/miri/tests/fail/stacked_borrows/illegal_read1.rs
src/tools/miri/tests/fail/stacked_borrows/illegal_read1.rs
// A callee may not read the destination of our `&mut` without // us noticing. #[rustfmt::skip] // rustfmt bug: https://github.com/rust-lang/rustfmt/issues/5391 fn main() { let mut x = 15; let xraw = &mut x as *mut _; let xref = unsafe { &mut *xraw }; // derived from raw, so using raw is still ok... ca...
rust
Apache-2.0
f8b1d59a81c700cb7aa25cf69e3032b3ce333150
2026-01-04T15:31:58.503980Z
false
rust-lang/rust
https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/miri/tests/fail/stacked_borrows/illegal_write4.rs
src/tools/miri/tests/fail/stacked_borrows/illegal_write4.rs
use std::mem; fn main() { let mut target = 42; // Make sure we cannot use a raw-tagged `&mut` pointing to a frozen location. // Even just creating it unfreezes. let raw = &mut target as *mut _; // let this leak to raw let reference = unsafe { &*raw }; // freeze let _ptr = reference as *const _ ...
rust
Apache-2.0
f8b1d59a81c700cb7aa25cf69e3032b3ce333150
2026-01-04T15:31:58.503980Z
false
rust-lang/rust
https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/miri/tests/fail/closures/deref-in-pattern.rs
src/tools/miri/tests/fail/closures/deref-in-pattern.rs
// This test serves to document the change in semantics introduced by // rust-lang/rust#138961. // // A corollary of partial-pattern.rs: while the tuple access testcase makes // it clear why these semantics are useful, it is actually the dereference // being performed by the pattern that matters. fn main() { // th...
rust
Apache-2.0
f8b1d59a81c700cb7aa25cf69e3032b3ce333150
2026-01-04T15:31:58.503980Z
false
rust-lang/rust
https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/miri/tests/fail/closures/uninhabited-variant.rs
src/tools/miri/tests/fail/closures/uninhabited-variant.rs
// Motivated by rust-lang/rust#138961, this shows how invalid discriminants interact with // closure captures. #![feature(never_type)] #[repr(C)] #[allow(dead_code)] enum E { V0, // discriminant: 0 V1, // 1 V2(!), // 2 } fn main() { assert_eq!(std::mem::size_of::<E>(), 4); let val = 2u32; ...
rust
Apache-2.0
f8b1d59a81c700cb7aa25cf69e3032b3ce333150
2026-01-04T15:31:58.503980Z
false
rust-lang/rust
https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/miri/tests/fail/closures/partial-pattern.rs
src/tools/miri/tests/fail/closures/partial-pattern.rs
// This test serves to document the change in semantics introduced by // rust-lang/rust#138961. // // Previously, the closure would capture the entirety of x, and access *(*x).0 // when called. Now, the closure only captures *(*x).0, which means that // a &*(*x).0 reborrow happens when the closure is constructed. // //...
rust
Apache-2.0
f8b1d59a81c700cb7aa25cf69e3032b3ce333150
2026-01-04T15:31:58.503980Z
false
rust-lang/rust
https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/miri/tests/fail/both_borrows/issue-miri-1050-2.rs
src/tools/miri/tests/fail/both_borrows/issue-miri-1050-2.rs
//@revisions: stack tree // Ensure this even hits the aliasing model //@compile-flags: -Zmiri-disable-validation //@[tree]compile-flags: -Zmiri-tree-borrows //@error-in-other-file: is a dangling pointer use std::ptr::NonNull; fn main() { unsafe { let ptr = NonNull::<i32>::dangling(); drop(Box::from...
rust
Apache-2.0
f8b1d59a81c700cb7aa25cf69e3032b3ce333150
2026-01-04T15:31:58.503980Z
false
rust-lang/rust
https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/miri/tests/fail/both_borrows/box_noalias_violation.rs
src/tools/miri/tests/fail/both_borrows/box_noalias_violation.rs
//@revisions: stack tree //@[tree]compile-flags: -Zmiri-tree-borrows unsafe fn test(mut x: Box<i32>, y: *const i32) -> i32 { // We will call this in a way that x and y alias. *x = 5; std::mem::forget(x); *y //~[stack]^ ERROR: weakly protected //~[tree]| ERROR: /read access through .* is forbidd...
rust
Apache-2.0
f8b1d59a81c700cb7aa25cf69e3032b3ce333150
2026-01-04T15:31:58.503980Z
false
rust-lang/rust
https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/miri/tests/fail/both_borrows/return_invalid_shr.rs
src/tools/miri/tests/fail/both_borrows/return_invalid_shr.rs
//@revisions: stack tree //@[tree]compile-flags: -Zmiri-tree-borrows // Make sure that we cannot return a `&` that got already invalidated. fn foo(x: &mut (i32, i32)) -> &i32 { let xraw = x as *mut (i32, i32); let ret = unsafe { &(*xraw).1 }; unsafe { *xraw = (42, 23) }; // unfreeze ret //~[stack]^...
rust
Apache-2.0
f8b1d59a81c700cb7aa25cf69e3032b3ce333150
2026-01-04T15:31:58.503980Z
false
rust-lang/rust
https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/miri/tests/fail/both_borrows/load_invalid_shr.rs
src/tools/miri/tests/fail/both_borrows/load_invalid_shr.rs
//@revisions: stack tree //@[tree]compile-flags: -Zmiri-tree-borrows // Make sure we catch this even without validation //@compile-flags: -Zmiri-disable-validation // Make sure that we cannot load from memory a `&` that got already invalidated. fn main() { let x = &mut 42; let xraw = x as *mut _; let xref ...
rust
Apache-2.0
f8b1d59a81c700cb7aa25cf69e3032b3ce333150
2026-01-04T15:31:58.503980Z
false
rust-lang/rust
https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/miri/tests/fail/both_borrows/alias_through_mutation.rs
src/tools/miri/tests/fail/both_borrows/alias_through_mutation.rs
//@revisions: stack tree //@[tree]compile-flags: -Zmiri-tree-borrows // This makes a ref that was passed to us via &mut alias with things it should not alias with fn retarget(x: &mut &u32, target: &mut u32) { unsafe { *x = &mut *(target as *mut _); } } fn main() { let target = &mut 42; let mut...
rust
Apache-2.0
f8b1d59a81c700cb7aa25cf69e3032b3ce333150
2026-01-04T15:31:58.503980Z
false
rust-lang/rust
https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/miri/tests/fail/both_borrows/return_invalid_shr_option.rs
src/tools/miri/tests/fail/both_borrows/return_invalid_shr_option.rs
//@revisions: stack tree //@[tree]compile-flags: -Zmiri-tree-borrows // Make sure that we cannot return a `&` that got already invalidated, not even in an `Option`. fn foo(x: &mut (i32, i32)) -> Option<&i32> { let xraw = x as *mut (i32, i32); let ret = Some(unsafe { &(*xraw).1 }); unsafe { *xraw = (42, 23)...
rust
Apache-2.0
f8b1d59a81c700cb7aa25cf69e3032b3ce333150
2026-01-04T15:31:58.503980Z
false
rust-lang/rust
https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/miri/tests/fail/both_borrows/aliasing_mut3.rs
src/tools/miri/tests/fail/both_borrows/aliasing_mut3.rs
//@revisions: stack tree //@[tree]compile-flags: -Zmiri-tree-borrows use std::mem; fn safe(x: &mut i32, y: &i32) { //~[stack]^ ERROR: borrow stack *x = 1; //~[tree] ERROR: /write access through .* is forbidden/ let _v = *y; } fn main() { let mut x = 0; let xref = &mut x; let xraw: *mut i32 = u...
rust
Apache-2.0
f8b1d59a81c700cb7aa25cf69e3032b3ce333150
2026-01-04T15:31:58.503980Z
false
rust-lang/rust
https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/miri/tests/fail/both_borrows/issue-miri-1050-1.rs
src/tools/miri/tests/fail/both_borrows/issue-miri-1050-1.rs
//@revisions: stack tree // Ensure this even hits the aliasing model //@compile-flags: -Zmiri-disable-validation //@[tree]compile-flags: -Zmiri-tree-borrows //@error-in-other-file: pointer not dereferenceable fn main() { unsafe { let ptr = Box::into_raw(Box::new(0u16)); drop(Box::from_raw(ptr as *m...
rust
Apache-2.0
f8b1d59a81c700cb7aa25cf69e3032b3ce333150
2026-01-04T15:31:58.503980Z
false
rust-lang/rust
https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/miri/tests/fail/both_borrows/invalidate_against_protector3.rs
src/tools/miri/tests/fail/both_borrows/invalidate_against_protector3.rs
//@revisions: stack tree //@[tree]compile-flags: -Zmiri-tree-borrows use std::alloc::{Layout, alloc}; fn inner(x: *mut i32, _y: &i32) { // If `x` and `y` alias, retagging is fine with this... but we really // shouldn't be allowed to write to `x` at all because `y` was assumed to be // immutable for the du...
rust
Apache-2.0
f8b1d59a81c700cb7aa25cf69e3032b3ce333150
2026-01-04T15:31:58.503980Z
false
rust-lang/rust
https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/miri/tests/fail/both_borrows/aliasing_mut1.rs
src/tools/miri/tests/fail/both_borrows/aliasing_mut1.rs
//@revisions: stack tree //@[tree]compile-flags: -Zmiri-tree-borrows use std::mem; fn safe(x: &mut i32, y: &mut i32) { //~[stack]^ ERROR: protect *x = 1; //~[tree] ERROR: /write access through .* is forbidden/ *y = 2; } fn main() { let mut x = 0; let xraw: *mut i32 = unsafe { mem::transmute(&mut x...
rust
Apache-2.0
f8b1d59a81c700cb7aa25cf69e3032b3ce333150
2026-01-04T15:31:58.503980Z
false
rust-lang/rust
https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/miri/tests/fail/both_borrows/illegal_write_despite_exposed1.rs
src/tools/miri/tests/fail/both_borrows/illegal_write_despite_exposed1.rs
//@revisions: stack tree //@compile-flags: -Zmiri-permissive-provenance //@[tree]compile-flags: -Zmiri-tree-borrows fn main() { unsafe { let root = &mut 42; let addr = root as *mut i32 as usize; let exposed_ptr = addr as *mut i32; // From the exposed ptr, we get a new SRO ptr. ...
rust
Apache-2.0
f8b1d59a81c700cb7aa25cf69e3032b3ce333150
2026-01-04T15:31:58.503980Z
false
rust-lang/rust
https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/miri/tests/fail/both_borrows/outdated_local.rs
src/tools/miri/tests/fail/both_borrows/outdated_local.rs
//@revisions: stack tree //@[tree]compile-flags: -Zmiri-tree-borrows fn main() { let mut x = 0; let y: *const i32 = &x; x = 1; // this invalidates y by reactivating the lowermost uniq borrow for this local assert_eq!(unsafe { *y }, 1); //~[stack]^ ERROR: /read access .* tag does not exist in the b...
rust
Apache-2.0
f8b1d59a81c700cb7aa25cf69e3032b3ce333150
2026-01-04T15:31:58.503980Z
false
rust-lang/rust
https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/miri/tests/fail/both_borrows/shr_frozen_violation1.rs
src/tools/miri/tests/fail/both_borrows/shr_frozen_violation1.rs
//@revisions: stack tree //@[tree]compile-flags: -Zmiri-tree-borrows #![allow(invalid_reference_casting)] fn foo(x: &mut i32) -> i32 { *x = 5; unknown_code(&*x); *x // must return 5 } fn main() { println!("{}", foo(&mut 0)); } fn unknown_code(x: &i32) { unsafe { *(x as *const i32 as *mut...
rust
Apache-2.0
f8b1d59a81c700cb7aa25cf69e3032b3ce333150
2026-01-04T15:31:58.503980Z
false
rust-lang/rust
https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/miri/tests/fail/both_borrows/retag_data_race_write.rs
src/tools/miri/tests/fail/both_borrows/retag_data_race_write.rs
//! Make sure that a retag acts like a write for the data race model. //@revisions: stack tree //@compile-flags: -Zmiri-deterministic-concurrency //@[tree]compile-flags: -Zmiri-tree-borrows #[derive(Copy, Clone)] struct SendPtr(*mut u8); unsafe impl Send for SendPtr {} fn thread_1(p: SendPtr) { let p = p.0; u...
rust
Apache-2.0
f8b1d59a81c700cb7aa25cf69e3032b3ce333150
2026-01-04T15:31:58.503980Z
false
rust-lang/rust
https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/miri/tests/fail/both_borrows/illegal_write6.rs
src/tools/miri/tests/fail/both_borrows/illegal_write6.rs
//@revisions: stack tree //@[tree]compile-flags: -Zmiri-tree-borrows fn main() { let x = &mut 0u32; let p = x as *mut u32; foo(x, p); } fn foo(a: &mut u32, y: *mut u32) -> u32 { *a = 1; let _b = &*a; unsafe { *y = 2 }; //~[stack]^ ERROR: /not granting access .* because that would remove .*...
rust
Apache-2.0
f8b1d59a81c700cb7aa25cf69e3032b3ce333150
2026-01-04T15:31:58.503980Z
false
rust-lang/rust
https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/miri/tests/fail/both_borrows/newtype_pair_retagging.rs
src/tools/miri/tests/fail/both_borrows/newtype_pair_retagging.rs
//@revisions: stack tree //@[tree]compile-flags: -Zmiri-tree-borrows //@[stack]error-in-other-file: which is strongly protected //@[tree]error-in-other-file: /deallocation through .* is forbidden/ struct Newtype<'a>(#[allow(dead_code)] &'a mut i32, #[allow(dead_code)] i32); fn dealloc_while_running(_n: Newtype<'_>, d...
rust
Apache-2.0
f8b1d59a81c700cb7aa25cf69e3032b3ce333150
2026-01-04T15:31:58.503980Z
false
rust-lang/rust
https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/miri/tests/fail/both_borrows/illegal_write5.rs
src/tools/miri/tests/fail/both_borrows/illegal_write5.rs
//@revisions: stack tree //@[tree]compile-flags: -Zmiri-tree-borrows // A callee may not write to the destination of our `&mut` without us noticing. fn main() { let mut x = 15; let xraw = &mut x as *mut _; // Derived from raw value, so using raw value is still ok ... let xref = unsafe { &mut *xraw }; ...
rust
Apache-2.0
f8b1d59a81c700cb7aa25cf69e3032b3ce333150
2026-01-04T15:31:58.503980Z
false
rust-lang/rust
https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/miri/tests/fail/both_borrows/pass_invalid_shr.rs
src/tools/miri/tests/fail/both_borrows/pass_invalid_shr.rs
//@revisions: stack tree //@[tree]compile-flags: -Zmiri-tree-borrows // Make sure that we cannot pass by argument a `&` that got already invalidated. fn foo(_: &i32) {} fn main() { let x = &mut 42; let xraw = x as *mut _; let xref = unsafe { &*xraw }; unsafe { *xraw = 42 }; // unfreeze foo(xref); ...
rust
Apache-2.0
f8b1d59a81c700cb7aa25cf69e3032b3ce333150
2026-01-04T15:31:58.503980Z
false
rust-lang/rust
https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/miri/tests/fail/both_borrows/return_invalid_shr_tuple.rs
src/tools/miri/tests/fail/both_borrows/return_invalid_shr_tuple.rs
//@revisions: stack tree //@[tree]compile-flags: -Zmiri-tree-borrows // Make sure that we cannot return a `&` that got already invalidated, not even in a tuple. fn foo(x: &mut (i32, i32)) -> (&i32,) { let xraw = x as *mut (i32, i32); let ret = (unsafe { &(*xraw).1 },); unsafe { *xraw = (42, 23) }; // unfre...
rust
Apache-2.0
f8b1d59a81c700cb7aa25cf69e3032b3ce333150
2026-01-04T15:31:58.503980Z
false
rust-lang/rust
https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/miri/tests/fail/both_borrows/illegal_write1.rs
src/tools/miri/tests/fail/both_borrows/illegal_write1.rs
//@revisions: stack tree //@[tree]compile-flags: -Zmiri-tree-borrows #![allow(invalid_reference_casting)] fn main() { let target = Box::new(42); // has an implicit raw let xref = &*target; { let x: *mut u32 = xref as *const _ as *mut _; unsafe { *x = 42 }; //~[stack]^ ERROR: /write...
rust
Apache-2.0
f8b1d59a81c700cb7aa25cf69e3032b3ce333150
2026-01-04T15:31:58.503980Z
false
rust-lang/rust
https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/miri/tests/fail/both_borrows/pass_invalid_shr_tuple.rs
src/tools/miri/tests/fail/both_borrows/pass_invalid_shr_tuple.rs
//@revisions: stack tree //@[tree]compile-flags: -Zmiri-tree-borrows // Make sure that we cannot pass by argument a `&` that got already invalidated. fn foo(_: (&i32, &i32)) {} fn main() { let x = &mut (42i32, 31i32); let xraw0 = &mut x.0 as *mut _; let xraw1 = &mut x.1 as *mut _; let pair_xref = unsa...
rust
Apache-2.0
f8b1d59a81c700cb7aa25cf69e3032b3ce333150
2026-01-04T15:31:58.503980Z
false
rust-lang/rust
https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/miri/tests/fail/both_borrows/buggy_as_mut_slice.rs
src/tools/miri/tests/fail/both_borrows/buggy_as_mut_slice.rs
//@revisions: stack tree //@[tree]compile-flags: -Zmiri-tree-borrows mod safe { use std::slice::from_raw_parts_mut; pub fn as_mut_slice<T>(self_: &Vec<T>) -> &mut [T] { unsafe { from_raw_parts_mut(self_.as_ptr() as *mut T, self_.len()) } } } fn main() { let v = vec![0, 1, 2]; let v1 = safe...
rust
Apache-2.0
f8b1d59a81c700cb7aa25cf69e3032b3ce333150
2026-01-04T15:31:58.503980Z
false
rust-lang/rust
https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/miri/tests/fail/both_borrows/buggy_split_at_mut.rs
src/tools/miri/tests/fail/both_borrows/buggy_split_at_mut.rs
//@revisions: stack tree //@[tree]compile-flags: -Zmiri-tree-borrows mod safe { use std::slice::from_raw_parts_mut; pub fn split_at_mut<T>(self_: &mut [T], mid: usize) -> (&mut [T], &mut [T]) { let len = self_.len(); let ptr = self_.as_mut_ptr(); unsafe { assert!(mid <= len...
rust
Apache-2.0
f8b1d59a81c700cb7aa25cf69e3032b3ce333150
2026-01-04T15:31:58.503980Z
false
rust-lang/rust
https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/miri/tests/fail/both_borrows/aliasing_mut2.rs
src/tools/miri/tests/fail/both_borrows/aliasing_mut2.rs
//@revisions: stack tree //@[tree]compile-flags: -Zmiri-tree-borrows use std::mem; fn safe(x: &i32, y: &mut i32) { //~[stack]^ ERROR: protect let _v = *x; *y = 2; //~[tree] ERROR: /write access through .* is forbidden/ } fn main() { let mut x = 0; let xref = &mut x; let xraw: *mut i32 = unsafe...
rust
Apache-2.0
f8b1d59a81c700cb7aa25cf69e3032b3ce333150
2026-01-04T15:31:58.503980Z
false
rust-lang/rust
https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/miri/tests/fail/both_borrows/illegal_read_despite_exposed2.rs
src/tools/miri/tests/fail/both_borrows/illegal_read_despite_exposed2.rs
//@revisions: stack tree //@compile-flags: -Zmiri-permissive-provenance //@[tree]compile-flags: -Zmiri-tree-borrows fn main() { unsafe { let root = &mut 42; let addr = root as *mut i32 as usize; let exposed_ptr = addr as *mut i32; // From the exposed ptr, we get a new unique ptr. ...
rust
Apache-2.0
f8b1d59a81c700cb7aa25cf69e3032b3ce333150
2026-01-04T15:31:58.503980Z
false
rust-lang/rust
https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/miri/tests/fail/both_borrows/invalidate_against_protector2.rs
src/tools/miri/tests/fail/both_borrows/invalidate_against_protector2.rs
//@revisions: stack tree //@[tree]compile-flags: -Zmiri-tree-borrows fn inner(x: *mut i32, _y: &i32) { // If `x` and `y` alias, retagging is fine with this... but we really // shouldn't be allowed to write to `x` at all because `y` was assumed to be // immutable for the duration of this call. unsafe { ...
rust
Apache-2.0
f8b1d59a81c700cb7aa25cf69e3032b3ce333150
2026-01-04T15:31:58.503980Z
false
rust-lang/rust
https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/miri/tests/fail/both_borrows/box_exclusive_violation1.rs
src/tools/miri/tests/fail/both_borrows/box_exclusive_violation1.rs
//@revisions: stack tree //@[tree]compile-flags: -Zmiri-tree-borrows fn demo_box_advanced_unique(mut our: Box<i32>) -> i32 { unknown_code_1(&*our); // This "re-asserts" uniqueness of the reference: After writing, we know // our tag is at the top of the stack. *our = 5; unknown_code_2(); // W...
rust
Apache-2.0
f8b1d59a81c700cb7aa25cf69e3032b3ce333150
2026-01-04T15:31:58.503980Z
false
rust-lang/rust
https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/miri/tests/fail/both_borrows/shr_frozen_violation2.rs
src/tools/miri/tests/fail/both_borrows/shr_frozen_violation2.rs
//@revisions: stack tree //@[tree]compile-flags: -Zmiri-tree-borrows fn main() { unsafe { let mut x = 0; let ptr = std::ptr::addr_of_mut!(x); let frozen = &*ptr; let _val = *frozen; x = 1; let _val = *frozen; //~[stack]^ ERROR: /read access .* tag does not exi...
rust
Apache-2.0
f8b1d59a81c700cb7aa25cf69e3032b3ce333150
2026-01-04T15:31:58.503980Z
false
rust-lang/rust
https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/miri/tests/fail/both_borrows/illegal_read_despite_exposed1.rs
src/tools/miri/tests/fail/both_borrows/illegal_read_despite_exposed1.rs
//@revisions: stack tree //@compile-flags: -Zmiri-permissive-provenance //@[tree]compile-flags: -Zmiri-tree-borrows fn main() { unsafe { let root = &mut 42; let addr = root as *mut i32 as usize; let exposed_ptr = addr as *mut i32; // From the exposed ptr, we get a new unique ptr. ...
rust
Apache-2.0
f8b1d59a81c700cb7aa25cf69e3032b3ce333150
2026-01-04T15:31:58.503980Z
false
rust-lang/rust
https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/miri/tests/fail/both_borrows/newtype_retagging.rs
src/tools/miri/tests/fail/both_borrows/newtype_retagging.rs
//@revisions: stack tree //@[tree]compile-flags: -Zmiri-tree-borrows //@[stack]error-in-other-file: which is strongly protected //@[tree]error-in-other-file: /deallocation through .* is forbidden/ struct Newtype<'a>(#[allow(dead_code)] &'a mut i32); fn dealloc_while_running(_n: Newtype<'_>, dealloc: impl FnOnce()) {...
rust
Apache-2.0
f8b1d59a81c700cb7aa25cf69e3032b3ce333150
2026-01-04T15:31:58.503980Z
false
rust-lang/rust
https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/miri/tests/fail/both_borrows/mut_exclusive_violation2.rs
src/tools/miri/tests/fail/both_borrows/mut_exclusive_violation2.rs
//@revisions: stack tree //@[tree]compile-flags: -Zmiri-tree-borrows use std::ptr::NonNull; fn main() { unsafe { let x = &mut 0; let mut ptr1 = NonNull::from(x); let mut ptr2 = ptr1.clone(); let raw1 = ptr1.as_mut(); let raw2 = ptr2.as_mut(); let _val = *raw1; //~[st...
rust
Apache-2.0
f8b1d59a81c700cb7aa25cf69e3032b3ce333150
2026-01-04T15:31:58.503980Z
false
rust-lang/rust
https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/miri/tests/fail/both_borrows/mut_exclusive_violation1.rs
src/tools/miri/tests/fail/both_borrows/mut_exclusive_violation1.rs
//@revisions: stack tree //@[tree]compile-flags: -Zmiri-tree-borrows fn demo_mut_advanced_unique(our: &mut i32) -> i32 { unknown_code_1(&*our); // This "re-asserts" uniqueness of the reference: After writing, we know // our tag is at the top of the stack. *our = 5; unknown_code_2(); // We kn...
rust
Apache-2.0
f8b1d59a81c700cb7aa25cf69e3032b3ce333150
2026-01-04T15:31:58.503980Z
false
rust-lang/rust
https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/miri/tests/fail/both_borrows/pass_invalid_shr_option.rs
src/tools/miri/tests/fail/both_borrows/pass_invalid_shr_option.rs
//@revisions: stack tree //@[tree]compile-flags: -Zmiri-tree-borrows // Make sure that we cannot pass by argument a `&` that got already invalidated. fn foo(_: Option<&i32>) {} fn main() { let x = &mut 42; let xraw = x as *mut _; let some_xref = unsafe { Some(&*xraw) }; unsafe { *xraw = 42 }; // unfre...
rust
Apache-2.0
f8b1d59a81c700cb7aa25cf69e3032b3ce333150
2026-01-04T15:31:58.503980Z
false
rust-lang/rust
https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/miri/tests/fail/both_borrows/aliasing_mut4.rs
src/tools/miri/tests/fail/both_borrows/aliasing_mut4.rs
//@revisions: stack tree //@[tree]compile-flags: -Zmiri-tree-borrows //@[tree]error-in-other-file: /write access through .* is forbidden/ use std::cell::Cell; use std::mem; // Make sure &mut UnsafeCell also is exclusive fn safe(x: &i32, y: &mut Cell<i32>) { //~[stack]^ ERROR: protect y.set(1); let _load = ...
rust
Apache-2.0
f8b1d59a81c700cb7aa25cf69e3032b3ce333150
2026-01-04T15:31:58.503980Z
false
rust-lang/rust
https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/miri/tests/fail/unaligned_pointers/unaligned_ptr2.rs
src/tools/miri/tests/fail/unaligned_pointers/unaligned_ptr2.rs
// This should fail even without validation or Stacked Borrows. //@compile-flags: -Zmiri-disable-validation -Zmiri-disable-stacked-borrows -Cdebug-assertions=no fn main() { // No retry needed, this fails reliably. let x = [2u32, 3]; // Make it big enough so we don't get an out-of-bounds error. let x = (x....
rust
Apache-2.0
f8b1d59a81c700cb7aa25cf69e3032b3ce333150
2026-01-04T15:31:58.503980Z
false
rust-lang/rust
https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/miri/tests/fail/unaligned_pointers/dyn_alignment.rs
src/tools/miri/tests/fail/unaligned_pointers/dyn_alignment.rs
// should find the bug even without, but gets masked by optimizations //@compile-flags: -Zmiri-disable-stacked-borrows -Cdebug-assertions=no //@normalize-stderr-test: "but found [0-9]+" -> "but found $$ALIGN" #[repr(align(256))] #[derive(Debug)] struct MuchAlign; fn main() { // Try many times as this might work b...
rust
Apache-2.0
f8b1d59a81c700cb7aa25cf69e3032b3ce333150
2026-01-04T15:31:58.503980Z
false
rust-lang/rust
https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/miri/tests/fail/unaligned_pointers/field_requires_parent_struct_alignment2.rs
src/tools/miri/tests/fail/unaligned_pointers/field_requires_parent_struct_alignment2.rs
/// This tests that when a field sits at a well-aligned offset, accessing the field /// requires high alignment even if the field type has lower alignment requirements. #[repr(C, align(16))] #[derive(Default, Copy, Clone)] pub struct Aligned { _pad: [u8; 11], packed: Packed, } #[repr(C, packed)] #[derive(Defau...
rust
Apache-2.0
f8b1d59a81c700cb7aa25cf69e3032b3ce333150
2026-01-04T15:31:58.503980Z
false
rust-lang/rust
https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/miri/tests/fail/unaligned_pointers/unaligned_ptr3.rs
src/tools/miri/tests/fail/unaligned_pointers/unaligned_ptr3.rs
// This should fail even without validation or Stacked Borrows. //@compile-flags: -Zmiri-disable-validation -Zmiri-disable-stacked-borrows -Cdebug-assertions=no fn main() { // Try many times as this might work by chance. for _ in 0..20 { let x = [2u16, 3, 4, 5]; // Make it big enough so we don't get an...
rust
Apache-2.0
f8b1d59a81c700cb7aa25cf69e3032b3ce333150
2026-01-04T15:31:58.503980Z
false
rust-lang/rust
https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/miri/tests/fail/unaligned_pointers/unaligned_ref_addr_of.rs
src/tools/miri/tests/fail/unaligned_pointers/unaligned_ref_addr_of.rs
// This should fail even without Stacked Borrows. //@compile-flags: -Zmiri-disable-stacked-borrows -Cdebug-assertions=no #![allow(invalid_reference_casting)] // for u16 -> u32 fn main() { // Try many times as this might work by chance. for _ in 0..20 { let x = [2u16, 3, 4]; // Make it big enough so we...
rust
Apache-2.0
f8b1d59a81c700cb7aa25cf69e3032b3ce333150
2026-01-04T15:31:58.503980Z
false
rust-lang/rust
https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/miri/tests/fail/unaligned_pointers/alignment.rs
src/tools/miri/tests/fail/unaligned_pointers/alignment.rs
//@normalize-stderr-test: "\| +\^+" -> "| ^" //@compile-flags: -Cdebug-assertions=no fn main() { // No retry needed, this fails reliably. let mut x = [0u8; 20]; let x_ptr: *mut u8 = x.as_mut_ptr(); #[rustfmt::skip] unsafe { // At least one of these is definitely unaligned. *(x_ptr ...
rust
Apache-2.0
f8b1d59a81c700cb7aa25cf69e3032b3ce333150
2026-01-04T15:31:58.503980Z
false
rust-lang/rust
https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/miri/tests/fail/unaligned_pointers/promise_alignment.rs
src/tools/miri/tests/fail/unaligned_pointers/promise_alignment.rs
//@compile-flags: -Zmiri-symbolic-alignment-check //@revisions: call_unaligned_ptr read_unaligned_ptr #[path = "../../utils/mod.rs"] mod utils; #[repr(align(8))] #[derive(Copy, Clone)] struct Align8(#[allow(dead_code)] u64); fn main() { let buffer = [0u32; 128]; // get some 4-aligned memory let buffer = buff...
rust
Apache-2.0
f8b1d59a81c700cb7aa25cf69e3032b3ce333150
2026-01-04T15:31:58.503980Z
false
rust-lang/rust
https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/miri/tests/fail/unaligned_pointers/unaligned_ptr1.rs
src/tools/miri/tests/fail/unaligned_pointers/unaligned_ptr1.rs
// This should fail even without validation or Stacked Borrows. //@compile-flags: -Zmiri-disable-validation -Zmiri-disable-stacked-borrows -Cdebug-assertions=no fn main() { // Try many times as this might work by chance. for _ in 0..20 { let x = [2u16, 3, 4]; // Make it big enough so we don't get an ou...
rust
Apache-2.0
f8b1d59a81c700cb7aa25cf69e3032b3ce333150
2026-01-04T15:31:58.503980Z
false
rust-lang/rust
https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/miri/tests/fail/unaligned_pointers/unaligned_ptr4.rs
src/tools/miri/tests/fail/unaligned_pointers/unaligned_ptr4.rs
// This should fail even without validation or Stacked Borrows. //@compile-flags: -Zmiri-disable-validation -Zmiri-disable-stacked-borrows -Cdebug-assertions=no fn main() { // Make sure we notice when a u16 is loaded at offset 1 into a u8 allocation. // (This would be missed if u8 allocations are *always* at o...
rust
Apache-2.0
f8b1d59a81c700cb7aa25cf69e3032b3ce333150
2026-01-04T15:31:58.503980Z
false
rust-lang/rust
https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/miri/tests/fail/unaligned_pointers/promise_alignment_zero.rs
src/tools/miri/tests/fail/unaligned_pointers/promise_alignment_zero.rs
#[path = "../../utils/mod.rs"] mod utils; fn main() { let buffer = [0u32; 128]; unsafe { utils::miri_promise_symbolic_alignment(buffer.as_ptr().cast(), 0) }; //~^ERROR: alignment must be a power of 2 }
rust
Apache-2.0
f8b1d59a81c700cb7aa25cf69e3032b3ce333150
2026-01-04T15:31:58.503980Z
false
rust-lang/rust
https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/miri/tests/fail/unaligned_pointers/field_requires_parent_struct_alignment.rs
src/tools/miri/tests/fail/unaligned_pointers/field_requires_parent_struct_alignment.rs
/// This tests that when a field sits at offset 0 in a 4-aligned struct, accessing the field /// requires alignment 4 even if the field type has lower alignment requirements. #[repr(C)] pub struct S { x: u8, y: u32, } unsafe fn foo(x: *const S) -> u8 { unsafe { (*x).x } //~ERROR: based on pointer with ali...
rust
Apache-2.0
f8b1d59a81c700cb7aa25cf69e3032b3ce333150
2026-01-04T15:31:58.503980Z
false
rust-lang/rust
https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/miri/tests/fail/unaligned_pointers/atomic_unaligned.rs
src/tools/miri/tests/fail/unaligned_pointers/atomic_unaligned.rs
//@compile-flags: -Zmiri-symbolic-alignment-check -Cdebug-assertions=no #![feature(core_intrinsics)] use std::intrinsics; fn main() { // Do a 4-aligned u64 atomic access. That should be UB on all platforms, // even if u64 only has alignment 4. let z = [0u32; 2]; let zptr = &z as *const _ as *const u64;...
rust
Apache-2.0
f8b1d59a81c700cb7aa25cf69e3032b3ce333150
2026-01-04T15:31:58.503980Z
false
rust-lang/rust
https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/miri/tests/fail/unaligned_pointers/intptrcast_alignment_check.rs
src/tools/miri/tests/fail/unaligned_pointers/intptrcast_alignment_check.rs
//@compile-flags: -Zmiri-symbolic-alignment-check -Zmiri-permissive-provenance -Cdebug-assertions=no // With the symbolic alignment check, even with intptrcast and without // validation, we want to be *sure* to catch bugs that arise from pointers being // insufficiently aligned. The only way to achieve that is not to l...
rust
Apache-2.0
f8b1d59a81c700cb7aa25cf69e3032b3ce333150
2026-01-04T15:31:58.503980Z
false
rust-lang/rust
https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/miri/tests/fail/unaligned_pointers/unaligned_ptr_zst.rs
src/tools/miri/tests/fail/unaligned_pointers/unaligned_ptr_zst.rs
// This should fail even without validation //@compile-flags: -Zmiri-disable-validation -Cdebug-assertions=no fn main() { // Try many times as this might work by chance. for i in 0..20 { let x = i as u8; let x = &x as *const _ as *const [u32; 0]; // This must fail because alignment is v...
rust
Apache-2.0
f8b1d59a81c700cb7aa25cf69e3032b3ce333150
2026-01-04T15:31:58.503980Z
false
rust-lang/rust
https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/miri/tests/fail/unaligned_pointers/drop_in_place.rs
src/tools/miri/tests/fail/unaligned_pointers/drop_in_place.rs
//@compile-flags: -Cdebug-assertions=no #[repr(transparent)] struct HasDrop(u8); impl Drop for HasDrop { fn drop(&mut self) {} } #[repr(C, align(2))] struct PartialDrop { a: HasDrop, b: u8, } //@error-in-other-file: /required 2 byte alignment/ fn main() { unsafe { // Create an unaligned poin...
rust
Apache-2.0
f8b1d59a81c700cb7aa25cf69e3032b3ce333150
2026-01-04T15:31:58.503980Z
false
rust-lang/rust
https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/miri/tests/fail/unaligned_pointers/reference_to_packed.rs
src/tools/miri/tests/fail/unaligned_pointers/reference_to_packed.rs
// This should fail even without SB //@compile-flags: -Zmiri-disable-stacked-borrows -Cdebug-assertions=no #![allow(dead_code, unused_variables)] use std::{mem, ptr}; #[repr(packed)] struct Foo { x: i32, y: i32, } unsafe fn raw_to_ref<'a, T>(x: *const T) -> &'a T { mem::transmute(x) //~ERROR: required 4...
rust
Apache-2.0
f8b1d59a81c700cb7aa25cf69e3032b3ce333150
2026-01-04T15:31:58.503980Z
false
rust-lang/rust
https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/miri/tests/fail/provenance/mix-ptrs2.rs
src/tools/miri/tests/fail/provenance/mix-ptrs2.rs
use std::mem; const PTR_SIZE: usize = mem::size_of::<&i32>(); /// Overwrite one byte of a pointer, then restore it. fn main() { unsafe fn ptr_bytes<'x>(ptr: &'x mut *const i32) -> &'x mut [mem::MaybeUninit<u8>; PTR_SIZE] { mem::transmute(ptr) } // Returns a value with the same provenance as `x` b...
rust
Apache-2.0
f8b1d59a81c700cb7aa25cf69e3032b3ce333150
2026-01-04T15:31:58.503980Z
false
rust-lang/rust
https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/miri/tests/fail/provenance/ptr_int_unexposed.rs
src/tools/miri/tests/fail/provenance/ptr_int_unexposed.rs
//@compile-flags: -Zmiri-permissive-provenance fn main() { let x: i32 = 3; let x_ptr = &x as *const i32; let x_usize: usize = x_ptr.addr(); // Cast back an address that did *not* get exposed. let ptr = std::ptr::with_exposed_provenance::<i32>(x_usize); assert_eq!(unsafe { *ptr }, 3); //~ ERROR...
rust
Apache-2.0
f8b1d59a81c700cb7aa25cf69e3032b3ce333150
2026-01-04T15:31:58.503980Z
false
rust-lang/rust
https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/miri/tests/fail/provenance/int_copy_looses_provenance2.rs
src/tools/miri/tests/fail/provenance/int_copy_looses_provenance2.rs
use std::mem; // Doing a copy at integer type should lose provenance. // This tests the case where provenacne is hiding in the metadata of a pointer. fn main() { let ptrs = [(&42, &42)]; // Typed copy at wide pointer type (with integer-typed metadata). let ints: [*const [usize]; 1] = unsafe { mem::transmut...
rust
Apache-2.0
f8b1d59a81c700cb7aa25cf69e3032b3ce333150
2026-01-04T15:31:58.503980Z
false
rust-lang/rust
https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/miri/tests/fail/provenance/pointer_partial_overwrite.rs
src/tools/miri/tests/fail/provenance/pointer_partial_overwrite.rs
// 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. fn main() { let mut p = &42; unsafe { let ptr: *mut _ = &mut p; *(ptr ...
rust
Apache-2.0
f8b1d59a81c700cb7aa25cf69e3032b3ce333150
2026-01-04T15:31:58.503980Z
false
rust-lang/rust
https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/miri/tests/fail/provenance/provenance_transmute.rs
src/tools/miri/tests/fail/provenance/provenance_transmute.rs
//@compile-flags: -Zmiri-permissive-provenance #![allow(integer_to_ptr_transmutes)] use std::mem; // This is the example from // <https://github.com/rust-lang/unsafe-code-guidelines/issues/286#issuecomment-1085144431>. unsafe fn deref(left: *const u8, right: *const u8) { let left_int: usize = mem::transmute(lef...
rust
Apache-2.0
f8b1d59a81c700cb7aa25cf69e3032b3ce333150
2026-01-04T15:31:58.503980Z
false
rust-lang/rust
https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/miri/tests/fail/provenance/int_copy_looses_provenance3.rs
src/tools/miri/tests/fail/provenance/int_copy_looses_provenance3.rs
use std::mem; #[repr(C, usize)] #[allow(unused)] enum E { Var1(usize), Var2(usize), } // Doing a copy at integer type should lose provenance. // This tests the case where provenacne is hiding in the discriminant of an enum. fn main() { assert_eq!(mem::size_of::<E>(), 2 * mem::size_of::<usize>()); // ...
rust
Apache-2.0
f8b1d59a81c700cb7aa25cf69e3032b3ce333150
2026-01-04T15:31:58.503980Z
false
rust-lang/rust
https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/miri/tests/fail/provenance/ptr_invalid.rs
src/tools/miri/tests/fail/provenance/ptr_invalid.rs
// Ensure that a `ptr::without_provenance` ptr is truly invalid. fn main() { let x = 42; let xptr = &x as *const i32; let xptr_invalid = std::ptr::without_provenance::<i32>(xptr.expose_provenance()); let _val = unsafe { *xptr_invalid }; //~ ERROR: is a dangling pointer }
rust
Apache-2.0
f8b1d59a81c700cb7aa25cf69e3032b3ce333150
2026-01-04T15:31:58.503980Z
false
rust-lang/rust
https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/miri/tests/fail/provenance/int_copy_looses_provenance0.rs
src/tools/miri/tests/fail/provenance/int_copy_looses_provenance0.rs
use std::mem; // Doing a copy at integer type should lose provenance. // This tests the unoptimized base case. fn main() { let ptrs = [(&42, true)]; let ints: [(usize, bool); 1] = unsafe { mem::transmute(ptrs) }; let ptr = (&raw const ints[0].0).cast::<&i32>(); let _val = unsafe { *ptr.read() }; //~ERR...
rust
Apache-2.0
f8b1d59a81c700cb7aa25cf69e3032b3ce333150
2026-01-04T15:31:58.503980Z
false
rust-lang/rust
https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/miri/tests/fail/provenance/ptr_invalid_offset.rs
src/tools/miri/tests/fail/provenance/ptr_invalid_offset.rs
//@compile-flags: -Zmiri-strict-provenance fn main() { let x = 22; let ptr = &x as *const _ as *const u8; let roundtrip = std::ptr::without_provenance::<u8>(ptr as usize); // Not even offsetting this is allowed. let _ = unsafe { roundtrip.offset(1) }; //~ERROR: is a dangling pointer }
rust
Apache-2.0
f8b1d59a81c700cb7aa25cf69e3032b3ce333150
2026-01-04T15:31:58.503980Z
false
rust-lang/rust
https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/miri/tests/fail/provenance/strict_provenance_cast.rs
src/tools/miri/tests/fail/provenance/strict_provenance_cast.rs
//@compile-flags: -Zmiri-strict-provenance fn main() { let addr = &0 as *const i32 as usize; let _ptr = std::ptr::with_exposed_provenance::<i32>(addr); //~ ERROR: integer-to-pointer casts and `ptr::with_exposed_provenance` are not supported }
rust
Apache-2.0
f8b1d59a81c700cb7aa25cf69e3032b3ce333150
2026-01-04T15:31:58.503980Z
false
rust-lang/rust
https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/miri/tests/fail/provenance/int_copy_looses_provenance1.rs
src/tools/miri/tests/fail/provenance/int_copy_looses_provenance1.rs
use std::mem; // Doing a copy at integer type should lose provenance. // This tests the optimized-array case of integer copies. fn main() { let ptrs = [&42]; let ints: [usize; 1] = unsafe { mem::transmute(ptrs) }; let ptr = (&raw const ints[0]).cast::<&i32>(); let _val = unsafe { *ptr.read() }; //~ERRO...
rust
Apache-2.0
f8b1d59a81c700cb7aa25cf69e3032b3ce333150
2026-01-04T15:31:58.503980Z
false
rust-lang/rust
https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/miri/tests/fail/provenance/mix-ptrs1.rs
src/tools/miri/tests/fail/provenance/mix-ptrs1.rs
use std::{mem, ptr}; const PTR_SIZE: usize = mem::size_of::<&i32>(); fn main() { unsafe { let ptr = &0 as *const i32; let arr = [ptr; 2]; // We want to do a scalar read of a pointer at offset PTR_SIZE/2 into this array. But we // cannot use a packed struct or `read_unaligned`, as t...
rust
Apache-2.0
f8b1d59a81c700cb7aa25cf69e3032b3ce333150
2026-01-04T15:31:58.503980Z
false
rust-lang/rust
https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/miri/tests/fail/provenance/ptr_copy_loses_partial_provenance0.rs
src/tools/miri/tests/fail/provenance/ptr_copy_loses_partial_provenance0.rs
fn main() { let half_ptr = std::mem::size_of::<*const ()>() / 2; let mut bytes = [1u8; 16]; let bytes = bytes.as_mut_ptr(); unsafe { // Put a pointer in the middle. bytes.add(half_ptr).cast::<&i32>().write_unaligned(&42); // Typed copy of the entire thing as two pointers, but no...
rust
Apache-2.0
f8b1d59a81c700cb7aa25cf69e3032b3ce333150
2026-01-04T15:31:58.503980Z
false
rust-lang/rust
https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/miri/tests/fail/provenance/ptr_copy_loses_partial_provenance1.rs
src/tools/miri/tests/fail/provenance/ptr_copy_loses_partial_provenance1.rs
fn main() { let half_ptr = std::mem::size_of::<*const ()>() / 2; let mut bytes = [1u8; 16]; let bytes = bytes.as_mut_ptr(); unsafe { // Put a pointer in the middle. bytes.add(half_ptr).cast::<&i32>().write_unaligned(&42); // Typed copy of the entire thing as two *function* point...
rust
Apache-2.0
f8b1d59a81c700cb7aa25cf69e3032b3ce333150
2026-01-04T15:31:58.503980Z
false
rust-lang/rust
https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/miri/tests/fail/dangling_pointers/dangling_primitive.rs
src/tools/miri/tests/fail/dangling_pointers/dangling_primitive.rs
// The interpreter tries to delay allocating locals until their address is taken. // This test checks that we correctly use the span associated with the local itself, not the span // where we take the address of the local and force it to be allocated. fn main() { let ptr = { let x = 0usize; // This line sh...
rust
Apache-2.0
f8b1d59a81c700cb7aa25cf69e3032b3ce333150
2026-01-04T15:31:58.503980Z
false
rust-lang/rust
https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/miri/tests/fail/dangling_pointers/out_of_bounds_read.rs
src/tools/miri/tests/fail/dangling_pointers/out_of_bounds_read.rs
fn main() { let v: Vec<u16> = vec![1, 2]; // This read is also misaligned. We make sure that the OOB message has priority. let x = unsafe { *v.as_ptr().wrapping_byte_add(5) }; //~ ERROR: attempting to access 2 bytes panic!("this should never print: {}", x); }
rust
Apache-2.0
f8b1d59a81c700cb7aa25cf69e3032b3ce333150
2026-01-04T15:31:58.503980Z
false
rust-lang/rust
https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/miri/tests/fail/dangling_pointers/deref-invalid-ptr.rs
src/tools/miri/tests/fail/dangling_pointers/deref-invalid-ptr.rs
// This should fail even without validation. //@compile-flags: -Zmiri-disable-validation -Zmiri-permissive-provenance fn main() { let x = 16usize as *const u32; let _y = unsafe { &*x as *const u32 }; //~ ERROR: is a dangling pointer }
rust
Apache-2.0
f8b1d59a81c700cb7aa25cf69e3032b3ce333150
2026-01-04T15:31:58.503980Z
false
rust-lang/rust
https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/miri/tests/fail/dangling_pointers/out_of_bounds_read_neg_offset.rs
src/tools/miri/tests/fail/dangling_pointers/out_of_bounds_read_neg_offset.rs
fn main() { let v: Vec<u16> = vec![1, 2]; // This read is also misaligned. We make sure that the OOB message has priority. let x = unsafe { *v.as_ptr().wrapping_byte_sub(5) }; //~ ERROR: before the beginning of the allocation panic!("this should never print: {}", x); }
rust
Apache-2.0
f8b1d59a81c700cb7aa25cf69e3032b3ce333150
2026-01-04T15:31:58.503980Z
false
rust-lang/rust
https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/miri/tests/fail/dangling_pointers/out_of_bounds_write.rs
src/tools/miri/tests/fail/dangling_pointers/out_of_bounds_write.rs
fn main() { let mut v: Vec<u16> = vec![1, 2]; // This read is also misaligned. We make sure that the OOB message has priority. unsafe { *v.as_mut_ptr().wrapping_byte_add(5) = 0 }; //~ ERROR: attempting to access 2 bytes }
rust
Apache-2.0
f8b1d59a81c700cb7aa25cf69e3032b3ce333150
2026-01-04T15:31:58.503980Z
false
rust-lang/rust
https://github.com/rust-lang/rust/blob/f8b1d59a81c700cb7aa25cf69e3032b3ce333150/src/tools/miri/tests/fail/dangling_pointers/dangling_pointer_project_underscore_match.rs
src/tools/miri/tests/fail/dangling_pointers/dangling_pointer_project_underscore_match.rs
// Make sure we find these even with many checks disabled. //@compile-flags: -Zmiri-disable-alignment-check -Zmiri-disable-stacked-borrows -Zmiri-disable-validation fn main() { let p = { let b = Box::new(42); &*b as *const i32 as *const (u8, u8, u8, u8) }; unsafe { match (*p).1 { ...
rust
Apache-2.0
f8b1d59a81c700cb7aa25cf69e3032b3ce333150
2026-01-04T15:31:58.503980Z
false