Skip to content

Commit 1b32d14

Browse files
cbeuwRalfJung
andcommitted
Make racy imperfectly overlapping atomic access unsupported instead of UB
Co-authored-by: Ralf Jung <[email protected]>
1 parent bf7a5c4 commit 1b32d14

File tree

3 files changed

+8
-10
lines changed

3 files changed

+8
-10
lines changed

src/concurrency/weak_memory.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -431,8 +431,8 @@ pub(super) trait EvalContextExt<'mir, 'tcx: 'mir>:
431431
&& !alloc_clocks
432432
.race_free_with_atomic(range, this.machine.data_race.as_ref().unwrap())
433433
{
434-
throw_ub_format!(
435-
"racy imperfectly overlapping atomic access is not possible in the C++20 memory model"
434+
throw_unsup_format!(
435+
"racy imperfectly overlapping atomic access is not possible in the C++20 memory model, and not supported by Miri's weak memory emulation"
436436
);
437437
}
438438
}

tests/fail/weak_memory/racing_mixed_size.stderr

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
warning: thread support is experimental: the scheduler is not preemptive, and can get stuck in spin loops.
22
(see https://github.com/rust-lang/miri/issues/1388)
33

4-
error: Undefined Behavior: racy imperfectly overlapping atomic access is not possible in the C++20 memory model
4+
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
55
--> $DIR/racing_mixed_size.rs:LL:CC
66
|
77
LL | std::intrinsics::atomic_load_relaxed(hi);
8-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ racy imperfectly overlapping atomic access is not possible in the C++20 memory model
8+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ racy imperfectly overlapping atomic access is not possible in the C++20 memory model, and not supported by Miri's weak memory emulation
99
|
10-
= help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
11-
= help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information
10+
= help: this is likely not a bug in the program; it indicates that the program performed an operation that the interpreter does not support
1211

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

tests/fail/weak_memory/racing_mixed_size_read.stderr

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
warning: thread support is experimental: the scheduler is not preemptive, and can get stuck in spin loops.
22
(see https://github.com/rust-lang/miri/issues/1388)
33

4-
error: Undefined Behavior: racy imperfectly overlapping atomic access is not possible in the C++20 memory model
4+
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
55
--> $DIR/racing_mixed_size_read.rs:LL:CC
66
|
77
LL | std::intrinsics::atomic_load_relaxed(hi);
8-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ racy imperfectly overlapping atomic access is not possible in the C++20 memory model
8+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ racy imperfectly overlapping atomic access is not possible in the C++20 memory model, and not supported by Miri's weak memory emulation
99
|
10-
= help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
11-
= help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information
10+
= help: this is likely not a bug in the program; it indicates that the program performed an operation that the interpreter does not support
1211

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

0 commit comments

Comments
 (0)