You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
error: Undefined Behavior: Race condition detected between (1) 2-byte Atomic Load on thread `<unnamed>` and (2) 1-byte (different-size) Atomic Load on thread `<unnamed>` at ALLOC. (2) just happened here
2
+
--> $DIR/mixed_size_read.rs:LL:CC
3
+
|
4
+
LL | a8[0].load(Ordering::SeqCst);
5
+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Race condition detected between (1) 2-byte Atomic Load on thread `<unnamed>` and (2) 1-byte (different-size) Atomic Load on thread `<unnamed>` at ALLOC. (2) just happened here
6
+
|
7
+
help: and (1) occurred earlier here
8
+
--> $DIR/mixed_size_read.rs:LL:CC
9
+
|
10
+
LL | a16.load(Ordering::SeqCst);
11
+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
12
+
= help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
13
+
= help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information
14
+
= note: BACKTRACE (of the first span):
15
+
= note: inside closure at $DIR/mixed_size_read.rs:LL:CC
16
+
17
+
note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace
use std::sync::atomic::{AtomicU16,AtomicU8,Ordering};
3
+
use std::thread;
4
+
5
+
fnconvert(a:&AtomicU16) -> &[AtomicU8;2]{
6
+
unsafe{ std::mem::transmute(a)}
7
+
}
8
+
9
+
// We can't allow mixed-size accesses; they are not possible in C++ and even
10
+
// Intel says you shouldn't do it.
11
+
fnmain(){
12
+
let a = AtomicU16::new(0);
13
+
let a16 = &a;
14
+
let a8 = convert(a16);
15
+
16
+
thread::scope(|s| {
17
+
s.spawn(|| {
18
+
a16.store(1,Ordering::SeqCst);
19
+
});
20
+
s.spawn(|| {
21
+
a8[0].store(1,Ordering::SeqCst);
22
+
//~^ ERROR: Race condition detected between (1) 2-byte Atomic Store on thread `<unnamed>` and (2) 1-byte (different-size) Atomic Store on thread `<unnamed>`
error: Undefined Behavior: Race condition detected between (1) 2-byte Atomic Store on thread `<unnamed>` and (2) 1-byte (different-size) Atomic Store on thread `<unnamed>` at ALLOC. (2) just happened here
2
+
--> $DIR/mixed_size_write.rs:LL:CC
3
+
|
4
+
LL | a8[0].store(1, Ordering::SeqCst);
5
+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Race condition detected between (1) 2-byte Atomic Store on thread `<unnamed>` and (2) 1-byte (different-size) Atomic Store on thread `<unnamed>` at ALLOC. (2) just happened here
6
+
|
7
+
help: and (1) occurred earlier here
8
+
--> $DIR/mixed_size_write.rs:LL:CC
9
+
|
10
+
LL | a16.store(1, Ordering::SeqCst);
11
+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
12
+
= help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
13
+
= help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information
14
+
= note: BACKTRACE (of the first span):
15
+
= note: inside closure at $DIR/mixed_size_write.rs:LL:CC
16
+
17
+
note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace
error: Undefined Behavior: Data race detected between (1) Read on thread `<unnamed>` and (2) Atomic Load on thread `<unnamed>` at ALLOC. (2) just happened here
2
+
--> $DIR/read_read_race1.rs:LL:CC
3
+
|
4
+
LL | a.load(Ordering::SeqCst);
5
+
| ^^^^^^^^^^^^^^^^^^^^^^^^ Data race detected between (1) Read on thread `<unnamed>` and (2) Atomic Load on thread `<unnamed>` at ALLOC. (2) just happened here
6
+
|
7
+
help: and (1) occurred earlier here
8
+
--> $DIR/read_read_race1.rs:LL:CC
9
+
|
10
+
LL | unsafe { ptr.read() };
11
+
| ^^^^^^^^^^
12
+
= help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
13
+
= help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information
14
+
= note: BACKTRACE (of the first span):
15
+
= note: inside closure at $DIR/read_read_race1.rs:LL:CC
16
+
17
+
note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace
error: Undefined Behavior: Data race detected between (1) Atomic Load on thread `<unnamed>` and (2) Read on thread `<unnamed>` at ALLOC. (2) just happened here
2
+
--> $DIR/read_read_race2.rs:LL:CC
3
+
|
4
+
LL | unsafe { ptr.read() };
5
+
| ^^^^^^^^^^ Data race detected between (1) Atomic Load on thread `<unnamed>` and (2) Read on thread `<unnamed>` at ALLOC. (2) just happened here
6
+
|
7
+
help: and (1) occurred earlier here
8
+
--> $DIR/read_read_race2.rs:LL:CC
9
+
|
10
+
LL | a.load(Ordering::SeqCst);
11
+
| ^^^^^^^^^^^^^^^^^^^^^^^^
12
+
= help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
13
+
= help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information
14
+
= note: BACKTRACE (of the first span):
15
+
= note: inside closure at $DIR/read_read_race2.rs:LL:CC
16
+
17
+
note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace
Copy file name to clipboardExpand all lines: tests/fail/weak_memory/racing_mixed_size.stderr
+10-4
Original file line number
Diff line number
Diff line change
@@ -1,11 +1,17 @@
1
-
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
1
+
error: Undefined Behavior: Race condition detected between (1) 4-byte Atomic Store on thread `<unnamed>` and (2) 2-byte (different-size) Atomic Load on thread `<unnamed>` at ALLOC. (2) just happened here
2
2
--> $DIR/racing_mixed_size.rs:LL:CC
3
3
|
4
4
LL | std::intrinsics::atomic_load_relaxed(hi);
5
-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ racy imperfectly overlapping atomic access is not possible in the C++20 memory model, and not supported by Miri's weak memory emulation
5
+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Race condition detected between (1) 4-byte Atomic Store on thread `<unnamed>` and (2) 2-byte (different-size) Atomic Load on thread `<unnamed>` at ALLOC. (2) just happened here
6
6
|
7
-
= help: this is likely not a bug in the program; it indicates that the program performed an operation that the interpreter does not support
8
-
= note: BACKTRACE:
7
+
help: and (1) occurred earlier here
8
+
--> $DIR/racing_mixed_size.rs:LL:CC
9
+
|
10
+
LL | x.store(1, Relaxed);
11
+
| ^^^^^^^^^^^^^^^^^^^
12
+
= help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
13
+
= help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information
14
+
= note: BACKTRACE (of the first span):
9
15
= note: inside closure at $DIR/racing_mixed_size.rs:LL:CC
10
16
11
17
note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace
Copy file name to clipboardExpand all lines: tests/fail/weak_memory/racing_mixed_size_read.stderr
+10-4
Original file line number
Diff line number
Diff line change
@@ -1,11 +1,17 @@
1
-
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
1
+
error: Undefined Behavior: Race condition detected between (1) 4-byte Atomic Load on thread `<unnamed>` and (2) 2-byte (different-size) Atomic Load on thread `<unnamed>` at ALLOC. (2) just happened here
2
2
--> $DIR/racing_mixed_size_read.rs:LL:CC
3
3
|
4
4
LL | (*hi).load(Relaxed);
5
-
| ^^^^^^^^^^^^^^^^^^^ racy imperfectly overlapping atomic access is not possible in the C++20 memory model, and not supported by Miri's weak memory emulation
5
+
| ^^^^^^^^^^^^^^^^^^^ Race condition detected between (1) 4-byte Atomic Load on thread `<unnamed>` and (2) 2-byte (different-size) Atomic Load on thread `<unnamed>` at ALLOC. (2) just happened here
6
6
|
7
-
= help: this is likely not a bug in the program; it indicates that the program performed an operation that the interpreter does not support
8
-
= note: BACKTRACE:
7
+
help: and (1) occurred earlier here
8
+
--> $DIR/racing_mixed_size_read.rs:LL:CC
9
+
|
10
+
LL | x.load(Relaxed);
11
+
| ^^^^^^^^^^^^^^^
12
+
= help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
13
+
= help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information
14
+
= note: BACKTRACE (of the first span):
9
15
= note: inside closure at $DIR/racing_mixed_size_read.rs:LL:CC
10
16
11
17
note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace
0 commit comments