From 997e5fbcef1bc37f8bc8aa892d9f953c6163ffd3 Mon Sep 17 00:00:00 2001 From: Andy Wang Date: Sun, 5 Jun 2022 22:11:55 +0100 Subject: [PATCH] Make racy imperfectly overlapping atomic access unsupported instead of UB Co-authored-by: Ralf Jung --- src/concurrency/weak_memory.rs | 4 ++-- tests/fail/weak_memory/racing_mixed_size.stderr | 7 +++---- tests/fail/weak_memory/racing_mixed_size_read.stderr | 7 +++---- 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/src/concurrency/weak_memory.rs b/src/concurrency/weak_memory.rs index 02af0efe9f..da36fcd2fb 100644 --- a/src/concurrency/weak_memory.rs +++ b/src/concurrency/weak_memory.rs @@ -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" ); } } diff --git a/tests/fail/weak_memory/racing_mixed_size.stderr b/tests/fail/weak_memory/racing_mixed_size.stderr index b03424a861..fc6be84315 100644 --- a/tests/fail/weak_memory/racing_mixed_size.stderr +++ b/tests/fail/weak_memory/racing_mixed_size.stderr @@ -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 diff --git a/tests/fail/weak_memory/racing_mixed_size_read.stderr b/tests/fail/weak_memory/racing_mixed_size_read.stderr index 80cc2fe756..846d03f544 100644 --- a/tests/fail/weak_memory/racing_mixed_size_read.stderr +++ b/tests/fail/weak_memory/racing_mixed_size_read.stderr @@ -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