Skip to content
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 @@
9d82de19dfae60e55c291f5f28e28cfc2c1b9630
3f1552a273e43e15f6ed240d00e1efdd6a53e65e
2 changes: 2 additions & 0 deletions tests/fail/both_borrows/issue-miri-1050-1.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
//@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

Expand Down
2 changes: 2 additions & 0 deletions tests/fail/both_borrows/issue-miri-1050-2.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
//@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;
Expand Down
2 changes: 1 addition & 1 deletion tests/fail/both_borrows/return_invalid_shr.stack.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ help: <TAG> was created by a SharedReadOnly retag at offsets [0x4..0x8]
|
LL | let ret = unsafe { &(*xraw).1 };
| ^^^^^^^^^^
help: <TAG> was later invalidated at offsets [0x0..0x8] by a write access
help: <TAG> was later invalidated at offsets [0x4..0x8] by a write access
--> tests/fail/both_borrows/return_invalid_shr.rs:LL:CC
|
LL | unsafe { *xraw = (42, 23) }; // unfreeze
Expand Down
2 changes: 1 addition & 1 deletion tests/fail/both_borrows/return_invalid_shr.tree.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ help: the accessed tag <TAG> was created here, in the initial state Frozen
|
LL | let ret = unsafe { &(*xraw).1 };
| ^^^^^^^^^^
help: the accessed tag <TAG> later transitioned to Disabled due to a foreign write access at offsets [0x0..0x8]
help: the accessed tag <TAG> later transitioned to Disabled due to a foreign write access at offsets [0x4..0x8]
--> tests/fail/both_borrows/return_invalid_shr.rs:LL:CC
|
LL | unsafe { *xraw = (42, 23) }; // unfreeze
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ help: <TAG> was created by a SharedReadOnly retag at offsets [0x4..0x8]
|
LL | let ret = Some(unsafe { &(*xraw).1 });
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
help: <TAG> was later invalidated at offsets [0x0..0x8] by a write access
help: <TAG> was later invalidated at offsets [0x4..0x8] by a write access
--> tests/fail/both_borrows/return_invalid_shr_option.rs:LL:CC
|
LL | unsafe { *xraw = (42, 23) }; // unfreeze
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ help: the accessed tag <TAG> was created here, in the initial state Frozen
|
LL | let ret = Some(unsafe { &(*xraw).1 });
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
help: the accessed tag <TAG> later transitioned to Disabled due to a foreign write access at offsets [0x0..0x8]
help: the accessed tag <TAG> later transitioned to Disabled due to a foreign write access at offsets [0x4..0x8]
--> tests/fail/both_borrows/return_invalid_shr_option.rs:LL:CC
|
LL | unsafe { *xraw = (42, 23) }; // unfreeze
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ help: <TAG> was created by a SharedReadOnly retag at offsets [0x4..0x8]
|
LL | let ret = (unsafe { &(*xraw).1 },);
| ^^^^^^^^^^^^^^^^^^^^^^^^
help: <TAG> was later invalidated at offsets [0x0..0x8] by a write access
help: <TAG> was later invalidated at offsets [0x4..0x8] by a write access
--> tests/fail/both_borrows/return_invalid_shr_tuple.rs:LL:CC
|
LL | unsafe { *xraw = (42, 23) }; // unfreeze
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ help: the accessed tag <TAG> was created here, in the initial state Frozen
|
LL | let ret = (unsafe { &(*xraw).1 },);
| ^^^^^^^^^^^^^^^^^^^^^^^^
help: the accessed tag <TAG> later transitioned to Disabled due to a foreign write access at offsets [0x0..0x8]
help: the accessed tag <TAG> later transitioned to Disabled due to a foreign write access at offsets [0x4..0x8]
--> tests/fail/both_borrows/return_invalid_shr_tuple.rs:LL:CC
|
LL | unsafe { *xraw = (42, 23) }; // unfreeze
Expand Down
18 changes: 18 additions & 0 deletions tests/fail/overlapping_assignment_aggregate.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
//! This is like `pass/overlapping_assignment_aggregate_scalar.rs` but with a non-scalar
//! type, and that makes it definite UB.
#![feature(custom_mir, core_intrinsics)]
#![allow(internal_features)]

use std::intrinsics::mir::*;

#[custom_mir(dialect = "runtime")]
fn main() {
mir! {
let _1: ([u8; 1],);
{
_1.0 = [0_u8; 1];
_1 = (_1.0, ); //~ERROR: overlapping ranges
Return()
}
}
}
15 changes: 15 additions & 0 deletions tests/fail/overlapping_assignment_aggregate.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
error: Undefined Behavior: `copy_nonoverlapping` called on overlapping ranges
--> tests/fail/overlapping_assignment_aggregate.rs:LL:CC
|
LL | _1 = (_1.0, );
| ^^^^^^^^^^^^^ Undefined Behavior occurred here
|
= help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
= help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information
= note: BACKTRACE:
= note: inside `main` at tests/fail/overlapping_assignment_aggregate.rs:LL:CC

note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace

error: aborting due to 1 previous error

2 changes: 1 addition & 1 deletion tests/fail/validity/nonzero.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ error: Undefined Behavior: constructing invalid value: encountered 0, but expect
--> tests/fail/validity/nonzero.rs:LL:CC
|
LL | let _x = Some(unsafe { NonZero(0) });
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ Undefined Behavior occurred here
| ^^^^^^^^^^ Undefined Behavior occurred here
|
= help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
= help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information
Expand Down
19 changes: 19 additions & 0 deletions tests/pass/overlapping_assignment_aggregate_scalar.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#![feature(custom_mir, core_intrinsics)]
#![allow(internal_features)]

use std::intrinsics::mir::*;

#[custom_mir(dialect = "runtime")]
fn main() {
mir! {
let _1: (u8,);
{
_1.0 = 0_u8;
// This is a scalar type, so overlap is (for now) not UB.
// However, we used to treat such overlapping assignments incorrectly
// (see <https://github.com/rust-lang/rust/issues/146383#issuecomment-3273224645>).
_1 = (_1.0, );
Return()
}
}
}
Loading