Skip to content

Commit f4165be

Browse files
committed
Add a (1) and (2) to the data race errors
1 parent a2e09ba commit f4165be

File tree

57 files changed

+113
-113
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+113
-113
lines changed

src/tools/miri/src/diagnostics.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,8 @@ impl fmt::Display for TerminationInfo {
6969
DataRace { ptr, op1, op2 } =>
7070
write!(
7171
f,
72-
"Data race detected between {} on {} and {} on {} at {:?}. The {} is here",
73-
op1.action, op1.thread_info, op2.action, op2.thread_info, ptr, op1.action
72+
"Data race detected between (1) {} on {} and (2) {} on {} at {ptr:?}. (1) just happened here",
73+
op1.action, op1.thread_info, op2.action, op2.thread_info
7474
),
7575
}
7676
}
@@ -224,7 +224,7 @@ pub fn report_error<'tcx, 'mir>(
224224
vec![(None, format!("use Strict Provenance APIs (https://doc.rust-lang.org/nightly/std/ptr/index.html#strict-provenance, https://crates.io/crates/sptr) instead"))],
225225
DataRace { op2, .. } =>
226226
vec![
227-
(Some(op2.span), format!("and the {} on {} is here", op2.action, op2.thread_info)),
227+
(Some(op2.span), format!("and (2) occurred earlier here")),
228228
(None, format!("this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior")),
229229
(None, format!("see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information")),
230230
],

src/tools/miri/tests/fail/data_race/alloc_read_race.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ pub fn main() {
3737
let pointer = &*ptr.0;
3838

3939
// Note: could also error due to reading uninitialized memory, but the data-race detector triggers first.
40-
*pointer.load(Ordering::Relaxed) //~ ERROR: Data race detected between Read on thread `<unnamed>` and Allocate on thread `<unnamed>`
40+
*pointer.load(Ordering::Relaxed) //~ ERROR: Data race detected between (1) Read on thread `<unnamed>` and (2) Allocate on thread `<unnamed>`
4141
});
4242

4343
j1.join().unwrap();

src/tools/miri/tests/fail/data_race/alloc_read_race.stderr

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
error: Undefined Behavior: Data race detected between Read on thread `<unnamed>` and Allocate on thread `<unnamed>` at ALLOC. The Read is here
1+
error: Undefined Behavior: Data race detected between (1) Read on thread `<unnamed>` and (2) Allocate on thread `<unnamed>` at ALLOC. (1) just happened here
22
--> $DIR/alloc_read_race.rs:LL:CC
33
|
44
LL | *pointer.load(Ordering::Relaxed)
5-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Data race detected between Read on thread `<unnamed>` and Allocate on thread `<unnamed>` at ALLOC. The Read is here
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Data race detected between (1) Read on thread `<unnamed>` and (2) Allocate on thread `<unnamed>` at ALLOC. (1) just happened here
66
|
7-
help: and the Allocate on thread `<unnamed>` is here
7+
help: and (2) occurred earlier here
88
--> $DIR/alloc_read_race.rs:LL:CC
99
|
1010
LL | pointer.store(Box::into_raw(Box::new_uninit()), Ordering::Relaxed);

src/tools/miri/tests/fail/data_race/alloc_write_race.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ pub fn main() {
3535

3636
let j2 = spawn(move || {
3737
let pointer = &*ptr.0;
38-
*pointer.load(Ordering::Relaxed) = 2; //~ ERROR: Data race detected between Write on thread `<unnamed>` and Allocate on thread `<unnamed>`
38+
*pointer.load(Ordering::Relaxed) = 2; //~ ERROR: Data race detected between (1) Write on thread `<unnamed>` and (2) Allocate on thread `<unnamed>`
3939
});
4040

4141
j1.join().unwrap();

src/tools/miri/tests/fail/data_race/alloc_write_race.stderr

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
error: Undefined Behavior: Data race detected between Write on thread `<unnamed>` and Allocate on thread `<unnamed>` at ALLOC. The Write is here
1+
error: Undefined Behavior: Data race detected between (1) Write on thread `<unnamed>` and (2) Allocate on thread `<unnamed>` at ALLOC. (1) just happened here
22
--> $DIR/alloc_write_race.rs:LL:CC
33
|
44
LL | *pointer.load(Ordering::Relaxed) = 2;
5-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Data race detected between Write on thread `<unnamed>` and Allocate on thread `<unnamed>` at ALLOC. The Write is here
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Data race detected between (1) Write on thread `<unnamed>` and (2) Allocate on thread `<unnamed>` at ALLOC. (1) just happened here
66
|
7-
help: and the Allocate on thread `<unnamed>` is here
7+
help: and (2) occurred earlier here
88
--> $DIR/alloc_write_race.rs:LL:CC
99
|
1010
LL | .store(Box::into_raw(Box::<usize>::new_uninit()) as *mut usize, Ordering::Relaxed);

src/tools/miri/tests/fail/data_race/atomic_read_na_write_race1.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ pub fn main() {
2020
});
2121

2222
let j2 = spawn(move || {
23-
(&*c.0).load(Ordering::SeqCst) //~ ERROR: Data race detected between Atomic Load on thread `<unnamed>` and Write on thread `<unnamed>`
23+
(&*c.0).load(Ordering::SeqCst) //~ ERROR: Data race detected between (1) Atomic Load on thread `<unnamed>` and (2) Write on thread `<unnamed>`
2424
});
2525

2626
j1.join().unwrap();

src/tools/miri/tests/fail/data_race/atomic_read_na_write_race1.stderr

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
error: Undefined Behavior: Data race detected between Atomic Load on thread `<unnamed>` and Write on thread `<unnamed>` at ALLOC. The Atomic Load is here
1+
error: Undefined Behavior: Data race detected between (1) Atomic Load on thread `<unnamed>` and (2) Write on thread `<unnamed>` at ALLOC. (1) just happened here
22
--> $DIR/atomic_read_na_write_race1.rs:LL:CC
33
|
44
LL | (&*c.0).load(Ordering::SeqCst)
5-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Data race detected between Atomic Load on thread `<unnamed>` and Write on thread `<unnamed>` at ALLOC. The Atomic Load is here
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Data race detected between (1) Atomic Load on thread `<unnamed>` and (2) Write on thread `<unnamed>` at ALLOC. (1) just happened here
66
|
7-
help: and the Write on thread `<unnamed>` is here
7+
help: and (2) occurred earlier here
88
--> $DIR/atomic_read_na_write_race1.rs:LL:CC
99
|
1010
LL | *(c.0 as *mut usize) = 32;

src/tools/miri/tests/fail/data_race/atomic_read_na_write_race2.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ pub fn main() {
2323

2424
let j2 = spawn(move || {
2525
let atomic_ref = &mut *c.0;
26-
*atomic_ref.get_mut() = 32; //~ ERROR: Data race detected between Write on thread `<unnamed>` and Atomic Load on thread `<unnamed>`
26+
*atomic_ref.get_mut() = 32; //~ ERROR: Data race detected between (1) Write on thread `<unnamed>` and (2) Atomic Load on thread `<unnamed>`
2727
});
2828

2929
j1.join().unwrap();

src/tools/miri/tests/fail/data_race/atomic_read_na_write_race2.stderr

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
error: Undefined Behavior: Data race detected between Write on thread `<unnamed>` and Atomic Load on thread `<unnamed>` at ALLOC. The Write is here
1+
error: Undefined Behavior: Data race detected between (1) Write on thread `<unnamed>` and (2) Atomic Load on thread `<unnamed>` at ALLOC. (1) just happened here
22
--> $DIR/atomic_read_na_write_race2.rs:LL:CC
33
|
44
LL | *atomic_ref.get_mut() = 32;
5-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ Data race detected between Write on thread `<unnamed>` and Atomic Load on thread `<unnamed>` at ALLOC. The Write is here
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ Data race detected between (1) Write on thread `<unnamed>` and (2) Atomic Load on thread `<unnamed>` at ALLOC. (1) just happened here
66
|
7-
help: and the Atomic Load on thread `<unnamed>` is here
7+
help: and (2) occurred earlier here
88
--> $DIR/atomic_read_na_write_race2.rs:LL:CC
99
|
1010
LL | atomic_ref.load(Ordering::SeqCst)

src/tools/miri/tests/fail/data_race/atomic_write_na_read_race1.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ pub fn main() {
2323

2424
let j2 = spawn(move || {
2525
let atomic_ref = &mut *c.0;
26-
*atomic_ref.get_mut() //~ ERROR: Data race detected between Read on thread `<unnamed>` and Atomic Store on thread `<unnamed>`
26+
*atomic_ref.get_mut() //~ ERROR: Data race detected between (1) Read on thread `<unnamed>` and (2) Atomic Store on thread `<unnamed>`
2727
});
2828

2929
j1.join().unwrap();

0 commit comments

Comments
 (0)