use ui_test regex capabilities
This commit is contained in:
parent
4e9de31174
commit
757e88c901
@ -1,6 +1,6 @@
|
||||
// Make sure we detect when the `Global` and `System` allocators are mixed
|
||||
// (even when the default `Global` uses `System`).
|
||||
//@error-pattern: which is Rust heap memory, using
|
||||
//@error-pattern: /deallocating .*, which is Rust heap memory, using .* heap deallocation operation/
|
||||
|
||||
//@normalize-stderr-test: "using [A-Za-z]+ heap deallocation operation" -> "using PLATFORM heap deallocation operation"
|
||||
//@normalize-stderr-test: "\| +\^+" -> "| ^"
|
||||
|
@ -1,7 +1,7 @@
|
||||
// Validation/SB changes why we fail
|
||||
//@compile-flags: -Zmiri-disable-validation -Zmiri-disable-stacked-borrows
|
||||
|
||||
//@error-pattern: which is stack variable memory, using Rust heap deallocation operation
|
||||
//@error-pattern: /deallocating .*, which is stack variable memory, using Rust heap deallocation operation/
|
||||
|
||||
fn main() {
|
||||
let x = 42;
|
||||
|
@ -8,5 +8,5 @@ fn main() {
|
||||
let x_usize: usize = x_ptr.addr();
|
||||
// Cast back an address that did *not* get exposed.
|
||||
let ptr = std::ptr::from_exposed_addr::<i32>(x_usize);
|
||||
assert_eq!(unsafe { *ptr }, 3); //~ ERROR: Undefined Behavior: dereferencing pointer failed
|
||||
assert_eq!(unsafe { *ptr }, 3); //~ ERROR: is a dangling pointer
|
||||
}
|
||||
|
@ -11,5 +11,5 @@ fn main() {
|
||||
retarget(&mut target_alias, target);
|
||||
// now `target_alias` points to the same thing as `target`
|
||||
*target = 13;
|
||||
let _val = *target_alias; //~ ERROR: borrow stack
|
||||
let _val = *target_alias; //~ ERROR: /read access .* tag does not exist in the borrow stack/
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
fn demo_mut_advanced_unique(mut our: Box<i32>) -> i32 {
|
||||
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
|
||||
@ -24,10 +24,10 @@ fn unknown_code_1(x: &i32) {
|
||||
|
||||
fn unknown_code_2() {
|
||||
unsafe {
|
||||
*LEAK = 7; //~ ERROR: borrow stack
|
||||
*LEAK = 7; //~ ERROR: /write access .* tag does not exist in the borrow stack/
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
demo_mut_advanced_unique(Box::new(0));
|
||||
demo_box_advanced_unique(Box::new(0));
|
||||
}
|
||||
|
@ -21,7 +21,7 @@ LL | *our = 5;
|
||||
| ^^^^^^^^
|
||||
= note: backtrace:
|
||||
= note: inside `unknown_code_2` at $DIR/box_exclusive_violation1.rs:LL:CC
|
||||
note: inside `demo_mut_advanced_unique` at $DIR/box_exclusive_violation1.rs:LL:CC
|
||||
note: inside `demo_box_advanced_unique` at $DIR/box_exclusive_violation1.rs:LL:CC
|
||||
--> $DIR/box_exclusive_violation1.rs:LL:CC
|
||||
|
|
||||
LL | unknown_code_2();
|
||||
@ -29,7 +29,7 @@ LL | unknown_code_2();
|
||||
note: inside `main` at $DIR/box_exclusive_violation1.rs:LL:CC
|
||||
--> $DIR/box_exclusive_violation1.rs:LL:CC
|
||||
|
|
||||
LL | demo_mut_advanced_unique(Box::new(0));
|
||||
LL | demo_box_advanced_unique(Box::new(0));
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace
|
||||
|
@ -11,5 +11,5 @@ fn main() {
|
||||
let v1 = safe::as_mut_slice(&v);
|
||||
let _v2 = safe::as_mut_slice(&v);
|
||||
v1[1] = 5;
|
||||
//~^ ERROR: borrow stack
|
||||
//~^ ERROR: /write access .* tag does not exist in the borrow stack/
|
||||
}
|
||||
|
@ -19,7 +19,7 @@ mod safe {
|
||||
fn main() {
|
||||
let mut array = [1, 2, 3, 4];
|
||||
let (a, b) = safe::split_at_mut(&mut array, 0);
|
||||
//~^ ERROR: borrow stack
|
||||
//~^ ERROR: /reborrow .* tag does not exist in the borrow stack/
|
||||
a[1] = 5;
|
||||
b[1] = 6;
|
||||
}
|
||||
|
@ -8,5 +8,5 @@ fn main() {
|
||||
let _fool = &mut x as *mut i32; // this would have fooled the old untagged pointer logic
|
||||
let addr = (&x as *const i32).expose_addr();
|
||||
let ptr = std::ptr::from_exposed_addr_mut::<i32>(addr);
|
||||
unsafe { *ptr = 0 }; //~ ERROR: borrow stack
|
||||
unsafe { *ptr = 0 }; //~ ERROR: /write access using <wildcard> .* no exposed tags have suitable permission in the borrow stack/
|
||||
}
|
||||
|
@ -8,7 +8,7 @@ fn main() {
|
||||
let xref = unsafe { &mut *xraw }; // derived from raw, so using raw is still ok...
|
||||
callee(xraw);
|
||||
let _val = *xref; // ...but any use of raw will invalidate our ref.
|
||||
//~^ ERROR: borrow stack
|
||||
//~^ ERROR: /read access .* tag does not exist in the borrow stack/
|
||||
}
|
||||
|
||||
fn callee(xraw: *mut i32) {
|
||||
|
@ -8,7 +8,7 @@ fn main() {
|
||||
let xref = unsafe { &mut *xraw }; // derived from raw, so using raw is still ok...
|
||||
callee(xraw);
|
||||
let _val = *xref; // ...but any use of raw will invalidate our ref.
|
||||
//~^ ERROR: borrow stack
|
||||
//~^ ERROR: /read access .* tag does not exist in the borrow stack/
|
||||
}
|
||||
|
||||
fn callee(xraw: *mut i32) {
|
||||
|
@ -18,7 +18,7 @@ fn main() {
|
||||
callee(xref1_sneaky);
|
||||
// ... though any use of it will invalidate our ref.
|
||||
let _val = *xref2;
|
||||
//~^ ERROR: borrow stack
|
||||
//~^ ERROR: /read access .* tag does not exist in the borrow stack/
|
||||
}
|
||||
|
||||
fn callee(xref1: HiddenRef) {
|
||||
|
@ -5,5 +5,5 @@ fn main() {
|
||||
let xraw = xref1 as *mut _;
|
||||
let xref2 = unsafe { &mut *xraw };
|
||||
let _val = unsafe { *xraw }; // use the raw again, this invalidates xref2 *even* with the special read except for uniq refs
|
||||
let _illegal = *xref2; //~ ERROR: borrow stack
|
||||
let _illegal = *xref2; //~ ERROR: /read access .* tag does not exist in the borrow stack/
|
||||
}
|
||||
|
@ -14,5 +14,5 @@ fn main() {
|
||||
let _val = *xref; // we can even still use our mutable reference
|
||||
mem::forget(unsafe { ptr::read(xshr) }); // but after reading through the shared ref
|
||||
let _val = *xref; // the mutable one is dead and gone
|
||||
//~^ ERROR: borrow stack
|
||||
//~^ ERROR: /read access .* tag does not exist in the borrow stack/
|
||||
}
|
||||
|
@ -5,6 +5,6 @@ fn main() {
|
||||
let raw = x as *mut _;
|
||||
let x = &mut *x; // kill `raw`
|
||||
let _y = &*x; // this should not activate `raw` again
|
||||
let _val = *raw; //~ ERROR: borrow stack
|
||||
let _val = *raw; //~ ERROR: /read access .* tag does not exist in the borrow stack/
|
||||
}
|
||||
}
|
||||
|
@ -17,6 +17,6 @@ fn main() {
|
||||
// without invalidating `x`. That would be bad! It would mean that creating `shr`
|
||||
// leaked `x` to `raw`.
|
||||
let _val = ptr::read(raw);
|
||||
let _val = *x.get_mut(); //~ ERROR: borrow stack
|
||||
let _val = *x.get_mut(); //~ ERROR: /reborrow .* tag does not exist in the borrow stack/
|
||||
}
|
||||
}
|
||||
|
@ -10,6 +10,6 @@ fn main() {
|
||||
let _val = *y2;
|
||||
let _val = *y1;
|
||||
*y2 += 1;
|
||||
let _fail = *y1; //~ ERROR: borrow stack
|
||||
let _fail = *y1; //~ ERROR: /read access .* tag does not exist in the borrow stack/
|
||||
}
|
||||
}
|
||||
|
@ -12,6 +12,6 @@ fn main() {
|
||||
// And we test that it has uniqueness by doing a conflicting write.
|
||||
*exposed_ptr = 0;
|
||||
// Stack: Unknown(<N)
|
||||
let _val = *root2; //~ ERROR: borrow stack
|
||||
let _val = *root2; //~ ERROR: /read access .* tag does not exist in the borrow stack/
|
||||
}
|
||||
}
|
||||
|
@ -15,6 +15,6 @@ fn main() {
|
||||
// Stack: Unknown(<N), Disabled(N)
|
||||
// collapsed to Unknown(<N)
|
||||
// Stack if _fool existed: Unknown(<N), Disabled(N), SRW(N+1); collapsed to Unknown(<N+2) which would not cause an ERROR
|
||||
let _val = *root2; //~ ERROR: borrow stack
|
||||
let _val = *root2; //~ ERROR: /read access .* tag does not exist in the borrow stack/
|
||||
}
|
||||
}
|
||||
|
@ -3,7 +3,7 @@ fn main() {
|
||||
let xref = &*target;
|
||||
{
|
||||
let x: *mut u32 = xref as *const _ as *mut _;
|
||||
unsafe { *x = 42 }; //~ ERROR: only grants SharedReadOnly permission
|
||||
unsafe { *x = 42 }; //~ ERROR: /write access .* tag only grants SharedReadOnly permission/
|
||||
}
|
||||
let _x = *xref;
|
||||
}
|
||||
|
@ -3,6 +3,6 @@ fn main() {
|
||||
let target2 = target as *mut _;
|
||||
drop(&mut *target); // reborrow
|
||||
// Now make sure our ref is still the only one.
|
||||
unsafe { *target2 = 13 }; //~ ERROR: borrow stack
|
||||
unsafe { *target2 = 13 }; //~ ERROR: /write access .* tag does not exist in the borrow stack/
|
||||
let _val = *target;
|
||||
}
|
||||
|
@ -3,6 +3,6 @@ fn main() {
|
||||
// Make sure raw ptr with raw tag cannot mutate frozen location without breaking the shared ref.
|
||||
let r#ref = ⌖ // freeze
|
||||
let ptr = r#ref as *const _ as *mut _; // raw ptr, with raw tag
|
||||
unsafe { *ptr = 42 }; //~ ERROR: only grants SharedReadOnly permission
|
||||
unsafe { *ptr = 42 }; //~ ERROR: /write access .* only grants SharedReadOnly permission/
|
||||
let _val = *r#ref;
|
||||
}
|
||||
|
@ -9,5 +9,5 @@ fn main() {
|
||||
let _ptr = reference as *const _ as *mut i32; // raw ptr, with raw tag
|
||||
let _mut_ref: &mut i32 = unsafe { mem::transmute(raw) }; // &mut, with raw tag
|
||||
// Now we retag, making our ref top-of-stack -- and, in particular, unfreezing.
|
||||
let _val = *reference; //~ ERROR: borrow stack
|
||||
let _val = *reference; //~ ERROR: /read access .* tag does not exist in the borrow stack/
|
||||
}
|
||||
|
@ -8,7 +8,7 @@ fn main() {
|
||||
callee(xraw);
|
||||
// ... though any use of raw value will invalidate our ref.
|
||||
let _val = *xref;
|
||||
//~^ ERROR: borrow stack
|
||||
//~^ ERROR: /read access .* tag does not exist in the borrow stack/
|
||||
}
|
||||
|
||||
fn callee(xraw: *mut i32) {
|
||||
|
@ -7,6 +7,6 @@ fn main() {
|
||||
fn foo(a: &mut u32, y: *mut u32) -> u32 {
|
||||
*a = 1;
|
||||
let _b = &*a;
|
||||
unsafe { *y = 2 }; //~ ERROR: not granting access to tag
|
||||
unsafe { *y = 2 }; //~ ERROR: /not granting access .* because incompatible item .* is protected/
|
||||
return *a;
|
||||
}
|
||||
|
@ -9,8 +9,9 @@ fn main() {
|
||||
let root2 = &*exposed_ptr;
|
||||
// Stack: Unknown(<N), SRO(N), SRO(N+1)
|
||||
// And we test that it is read-only by doing a conflicting write.
|
||||
// (The write is still fine, using the `root as *mut i32` provenance which got exposed.)
|
||||
*exposed_ptr = 0;
|
||||
// Stack: Unknown(<N)
|
||||
let _val = *root2; //~ ERROR: borrow stack
|
||||
let _val = *root2; //~ ERROR: /read access .* tag does not exist in the borrow stack/
|
||||
}
|
||||
}
|
||||
|
@ -12,6 +12,6 @@ fn main() {
|
||||
*c.get() = UnsafeCell::new(1); // invalidates inner_shr
|
||||
// stack: [c: SharedReadWrite]
|
||||
|
||||
let _val = *inner_shr.get(); //~ ERROR: borrow stack
|
||||
let _val = *inner_shr.get(); //~ ERROR: /reborrow .* tag does not exist in the borrow stack/
|
||||
}
|
||||
}
|
||||
|
@ -25,6 +25,6 @@ fn main() {
|
||||
// stack: [c: SharedReadWrite]
|
||||
|
||||
// now this does not work any more
|
||||
let _val = *inner_shr.get(); //~ ERROR: borrow stack
|
||||
let _val = *inner_shr.get(); //~ ERROR: /reborrow .* tag does not exist in the borrow stack/
|
||||
}
|
||||
}
|
||||
|
@ -8,5 +8,5 @@ fn main() {
|
||||
let xref = unsafe { &mut *xraw };
|
||||
let xref_in_mem = Box::new(xref);
|
||||
let _val = unsafe { *xraw }; // invalidate xref
|
||||
let _val = *xref_in_mem; //~ ERROR: borrow stack
|
||||
let _val = *xref_in_mem; //~ ERROR: /reborrow .* tag does not exist in the borrow stack/
|
||||
}
|
||||
|
@ -8,5 +8,5 @@ fn main() {
|
||||
let xref = unsafe { &*xraw };
|
||||
let xref_in_mem = Box::new(xref);
|
||||
unsafe { *xraw = 42 }; // unfreeze
|
||||
let _val = *xref_in_mem; //~ ERROR: borrow stack
|
||||
let _val = *xref_in_mem; //~ ERROR: /reborrow .* tag does not exist in the borrow stack/
|
||||
}
|
||||
|
@ -24,7 +24,7 @@ fn unknown_code_1(x: &i32) {
|
||||
|
||||
fn unknown_code_2() {
|
||||
unsafe {
|
||||
*LEAK = 7; //~ ERROR: borrow stack
|
||||
*LEAK = 7; //~ ERROR: /write access .* tag does not exist in the borrow stack/
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -7,6 +7,6 @@ fn main() {
|
||||
let mut ptr2 = ptr1.clone();
|
||||
let raw1 = ptr1.as_mut();
|
||||
let _raw2 = ptr2.as_mut();
|
||||
let _val = *raw1; //~ ERROR: borrow stack
|
||||
let _val = *raw1; //~ ERROR: /read access .* tag does not exist in the borrow stack/
|
||||
}
|
||||
}
|
||||
|
@ -3,7 +3,7 @@ fn main() {
|
||||
let y: *const i32 = &x;
|
||||
x = 1; // this invalidates y by reactivating the lowermost uniq borrow for this local
|
||||
|
||||
assert_eq!(unsafe { *y }, 1); //~ ERROR: borrow stack
|
||||
assert_eq!(unsafe { *y }, 1); //~ ERROR: /read access .* tag does not exist in the borrow stack/
|
||||
|
||||
assert_eq!(x, 1);
|
||||
}
|
||||
|
@ -6,5 +6,5 @@ fn main() {
|
||||
let xraw = x as *mut _;
|
||||
let xref = unsafe { &mut *xraw };
|
||||
let _val = unsafe { *xraw }; // invalidate xref
|
||||
foo(xref); //~ ERROR: borrow stack
|
||||
foo(xref); //~ ERROR: /reborrow .* tag does not exist in the borrow stack/
|
||||
}
|
||||
|
@ -6,5 +6,5 @@ fn main() {
|
||||
let xraw = x as *mut _;
|
||||
let xref = unsafe { &*xraw };
|
||||
unsafe { *xraw = 42 }; // unfreeze
|
||||
foo(xref); //~ ERROR: borrow stack
|
||||
foo(xref); //~ ERROR: /reborrow .* tag does not exist in the borrow stack/
|
||||
}
|
||||
|
@ -8,7 +8,7 @@ fn fun1(x: &mut u8) {
|
||||
|
||||
fn fun2() {
|
||||
// Now we use a pointer we are not allowed to use
|
||||
let _x = unsafe { *PTR }; //~ ERROR: borrow stack
|
||||
let _x = unsafe { *PTR }; //~ ERROR: /read access .* tag does not exist in the borrow stack/
|
||||
}
|
||||
|
||||
fn main() {
|
||||
|
@ -6,6 +6,6 @@ fn main() {
|
||||
let raw2 = &mut l as *mut _; // invalidates raw1
|
||||
// Without raw pointer tracking, Stacked Borrows cannot distinguish raw1 and raw2, and thus
|
||||
// fails to realize that raw1 should not be used any more.
|
||||
unsafe { *raw1 = 13 }; //~ ERROR: does not exist in the borrow stack
|
||||
unsafe { *raw1 = 13 }; //~ ERROR: /write access .* tag does not exist in the borrow stack/
|
||||
unsafe { *raw2 = 13 };
|
||||
}
|
||||
|
@ -3,7 +3,7 @@ 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: borrow stack
|
||||
ret //~ ERROR: /reborrow .* tag does not exist in the borrow stack/
|
||||
}
|
||||
|
||||
fn main() {
|
||||
|
@ -10,7 +10,7 @@ fn foo(x: &mut (i32, i32)) -> Option<&mut i32> {
|
||||
|
||||
fn main() {
|
||||
match foo(&mut (1, 2)) {
|
||||
Some(_x) => {} //~ ERROR: borrow stack
|
||||
Some(_x) => {} //~ ERROR: /reborrow .* tag does not exist in the borrow stack/
|
||||
None => {}
|
||||
}
|
||||
}
|
||||
|
@ -8,5 +8,5 @@ fn foo(x: &mut (i32, i32)) -> (&mut i32,) {
|
||||
}
|
||||
|
||||
fn main() {
|
||||
foo(&mut (1, 2)).0; //~ ERROR: borrow stack
|
||||
foo(&mut (1, 2)).0; //~ ERROR: /reborrow .* tag does not exist in the borrow stack/
|
||||
}
|
||||
|
@ -3,7 +3,7 @@ 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 //~ ERROR: borrow stack
|
||||
ret //~ ERROR: /reborrow .* tag does not exist in the borrow stack/
|
||||
}
|
||||
|
||||
fn main() {
|
||||
|
@ -9,7 +9,7 @@ fn foo(x: &mut (i32, i32)) -> Option<&i32> {
|
||||
|
||||
fn main() {
|
||||
match foo(&mut (1, 2)) {
|
||||
Some(_x) => {} //~ ERROR: borrow stack
|
||||
Some(_x) => {} //~ ERROR: /reborrow .* tag does not exist in the borrow stack/
|
||||
None => {}
|
||||
}
|
||||
}
|
||||
|
@ -8,5 +8,5 @@ fn foo(x: &mut (i32, i32)) -> (&i32,) {
|
||||
}
|
||||
|
||||
fn main() {
|
||||
foo(&mut (1, 2)).0; //~ ERROR: borrow stack
|
||||
foo(&mut (1, 2)).0; //~ ERROR: /reborrow .* tag does not exist in the borrow stack/
|
||||
}
|
||||
|
@ -11,6 +11,6 @@ fn main() {
|
||||
let y: &mut Cell<i32> = mem::transmute(&mut *x); // launder lifetime
|
||||
let shr_rw = &*x; // thanks to interior mutability this will be a SharedReadWrite
|
||||
shr_rw.set(1);
|
||||
y.get_mut(); //~ ERROR: borrow stack
|
||||
y.get_mut(); //~ ERROR: /reborrow .* tag does not exist in the borrow stack/
|
||||
}
|
||||
}
|
||||
|
@ -12,6 +12,6 @@ fn main() {
|
||||
let y: &i32 = mem::transmute(&*x.borrow()); // launder lifetime
|
||||
let shr_rw = &*x; // thanks to interior mutability this will be a SharedReadWrite
|
||||
shr_rw.replace(1);
|
||||
let _val = *y; //~ ERROR: borrow stack
|
||||
let _val = *y; //~ ERROR: /read access .* tag does not exist in the borrow stack/
|
||||
}
|
||||
}
|
||||
|
@ -10,6 +10,6 @@ fn main() {
|
||||
|
||||
fn unknown_code(x: &i32) {
|
||||
unsafe {
|
||||
*(x as *const i32 as *mut i32) = 7; //~ ERROR: only grants SharedReadOnly permission
|
||||
*(x as *const i32 as *mut i32) = 7; //~ ERROR: /write access .* only grants SharedReadOnly permission/
|
||||
}
|
||||
}
|
||||
|
@ -10,5 +10,5 @@ fn main() {
|
||||
let _raw: *mut i32 = unsafe { mem::transmute(&mut x[0]) };
|
||||
// `raw` still carries a tag, so we get another pointer to the same location that does not carry a tag
|
||||
let raw = (&mut x[1] as *mut i32).wrapping_offset(-1);
|
||||
unsafe { *raw = 13 }; //~ ERROR: borrow stack
|
||||
unsafe { *raw = 13 }; //~ ERROR: /write access .* tag does not exist in the borrow stack/
|
||||
}
|
||||
|
@ -7,6 +7,6 @@ fn main() {
|
||||
let raw = &mut x as *mut i32 as usize as *mut i32;
|
||||
let _ptr = &mut x;
|
||||
unsafe {
|
||||
*raw = 13; //~ ERROR: borrow stack
|
||||
*raw = 13; //~ ERROR: /write access .* no exposed tags/
|
||||
}
|
||||
}
|
||||
|
@ -3,5 +3,5 @@ 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: borrow stack
|
||||
let _val = unsafe { *ptr_to_first.add(1) }; //~ ERROR: /read access .* tag does not exist in the borrow stack/
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
//@compile-flags: -Zmiri-strict-provenance
|
||||
//@error-pattern: does not exist in the borrow stack
|
||||
//@error-pattern: /reborrow .* tag does not exist in the borrow stack/
|
||||
|
||||
fn main() {
|
||||
unsafe {
|
||||
|
Loading…
x
Reference in New Issue
Block a user