Skip to content

Commit

Permalink
Make racy imperfectly overlapping atomic access unsupported instead o…
Browse files Browse the repository at this point in the history
…f UB

Co-authored-by: Ralf Jung <post@ralfj.de>
  • Loading branch information
cbeuw and RalfJung committed Jun 6, 2022
1 parent ce67f5d commit 997e5fb
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 10 deletions.
4 changes: 2 additions & 2 deletions src/concurrency/weak_memory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -431,8 +431,8 @@ pub(super) trait EvalContextExt<'mir, 'tcx: 'mir>:
&& !alloc_clocks
.race_free_with_atomic(range, this.machine.data_race.as_ref().unwrap())
{
throw_ub_format!(
"racy imperfectly overlapping atomic access is not possible in the C++20 memory model"
throw_unsup_format!(
"racy imperfectly overlapping atomic access is not possible in the C++20 memory model, and not supported by Miri's weak memory emulation"
);
}
}
Expand Down
7 changes: 3 additions & 4 deletions tests/fail/weak_memory/racing_mixed_size.stderr
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
warning: thread support is experimental: the scheduler is not preemptive, and can get stuck in spin loops.
(see https://github.com/rust-lang/miri/issues/1388)

error: Undefined Behavior: racy imperfectly overlapping atomic access is not possible in the C++20 memory model
error: unsupported operation: racy imperfectly overlapping atomic access is not possible in the C++20 memory model, and not supported by Miri's weak memory emulation
--> $DIR/racing_mixed_size.rs:LL:CC
|
LL | std::intrinsics::atomic_load_relaxed(hi);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ racy imperfectly overlapping atomic access is not possible in the C++20 memory model
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ racy imperfectly overlapping atomic access is not possible in the C++20 memory model, and not supported by Miri's weak memory emulation
|
= 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
= help: this is likely not a bug in the program; it indicates that the program performed an operation that the interpreter does not support

= note: inside closure at $DIR/racing_mixed_size.rs:LL:CC

Expand Down
7 changes: 3 additions & 4 deletions tests/fail/weak_memory/racing_mixed_size_read.stderr
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
warning: thread support is experimental: the scheduler is not preemptive, and can get stuck in spin loops.
(see https://github.com/rust-lang/miri/issues/1388)

error: Undefined Behavior: racy imperfectly overlapping atomic access is not possible in the C++20 memory model
error: unsupported operation: racy imperfectly overlapping atomic access is not possible in the C++20 memory model, and not supported by Miri's weak memory emulation
--> $DIR/racing_mixed_size_read.rs:LL:CC
|
LL | std::intrinsics::atomic_load_relaxed(hi);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ racy imperfectly overlapping atomic access is not possible in the C++20 memory model
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ racy imperfectly overlapping atomic access is not possible in the C++20 memory model, and not supported by Miri's weak memory emulation
|
= 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
= help: this is likely not a bug in the program; it indicates that the program performed an operation that the interpreter does not support

= note: inside closure at $DIR/racing_mixed_size_read.rs:LL:CC

Expand Down

0 comments on commit 997e5fb

Please sign in to comment.