Skip to content

Commit e6637cb

Browse files
committed
return_pointer_aliasing2 should also run with SB
1 parent e6aa233 commit e6637cb

File tree

3 files changed

+45
-2
lines changed

3 files changed

+45
-2
lines changed

src/tools/miri/tests/fail/function_calls/return_pointer_aliasing2.rs

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
//@compile-flags: -Zmiri-tree-borrows
1+
// This does need an aliasing model.
2+
//@revisions: stack tree
3+
//@[tree]compile-flags: -Zmiri-tree-borrows
24
#![feature(raw_ref_op)]
35
#![feature(core_intrinsics)]
46
#![feature(custom_mir)]
@@ -25,6 +27,7 @@ pub fn main() {
2527
fn myfun(ptr: *mut i32) -> i32 {
2628
// This overwrites the return place, which shouldn't be possible through another pointer.
2729
unsafe { ptr.write(0) };
28-
//~^ ERROR: /write access .* forbidden/
30+
//~[stack]^ ERROR: tag does not exist in the borrow stack
31+
//~[tree]| ERROR: /write access .* forbidden/
2932
13
3033
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
error: Undefined Behavior: attempting a write access using <TAG> at ALLOC[0x0], but that tag does not exist in the borrow stack for this location
2+
--> $DIR/return_pointer_aliasing2.rs:LL:CC
3+
|
4+
LL | unsafe { ptr.write(0) };
5+
| ^^^^^^^^^^^^
6+
| |
7+
| attempting a write access using <TAG> at ALLOC[0x0], but that tag does not exist in the borrow stack for this location
8+
| this error occurs as part of an access at ALLOC[0x0..0x4]
9+
|
10+
= help: this indicates a potential bug in the program: it performed an invalid operation, but the Stacked Borrows rules it violated are still experimental
11+
= help: see https://github.com/rust-lang/unsafe-code-guidelines/blob/master/wip/stacked-borrows.md for further information
12+
help: <TAG> was created by a SharedReadWrite retag at offsets [0x0..0x4]
13+
--> $DIR/return_pointer_aliasing2.rs:LL:CC
14+
|
15+
LL | / mir! {
16+
LL | | {
17+
LL | | let _x = 0;
18+
LL | | let ptr = &raw mut _x;
19+
... |
20+
LL | | }
21+
LL | | }
22+
| |_____^
23+
help: <TAG> was later invalidated at offsets [0x0..0x4] by a Unique in-place function argument/return passing protection
24+
--> $DIR/return_pointer_aliasing2.rs:LL:CC
25+
|
26+
LL | unsafe { ptr.write(0) };
27+
| ^^^^^^^^^^^^^^^^^^^^^^^
28+
= note: BACKTRACE (of the first span):
29+
= note: inside `myfun` at $DIR/return_pointer_aliasing2.rs:LL:CC
30+
note: inside `main`
31+
--> $DIR/return_pointer_aliasing2.rs:LL:CC
32+
|
33+
LL | Call(_x = myfun(ptr), after_call)
34+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
35+
= note: this error originates in the macro `::core::intrinsics::mir::__internal_remove_let` which comes from the expansion of the macro `mir` (in Nightly builds, run with -Z macro-backtrace for more info)
36+
37+
note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace
38+
39+
error: aborting due to previous error
40+

0 commit comments

Comments
 (0)