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
0 commit comments