From e1462ad6b820b0329e8826eb7096502f0ee048c4 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Fri, 10 Nov 2023 08:30:19 +0100 Subject: [PATCH] data_race: link to docs for 'unusual' race conditions --- src/diagnostics.rs | 3 ++- tests/fail/data_race/mixed_size_read.stderr | 1 + tests/fail/data_race/mixed_size_write.stderr | 1 + tests/fail/data_race/read_read_race1.stderr | 1 + tests/fail/data_race/read_read_race2.stderr | 1 + tests/fail/weak_memory/racing_mixed_size.stderr | 1 + tests/fail/weak_memory/racing_mixed_size_read.stderr | 1 + 7 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/diagnostics.rs b/src/diagnostics.rs index fe445c6dcd..c2ef771001 100644 --- a/src/diagnostics.rs +++ b/src/diagnostics.rs @@ -270,7 +270,8 @@ pub fn report_error<'tcx, 'mir>( DataRace { op1, extra, .. } => { let mut helps = vec![(Some(op1.span), format!("and (1) occurred earlier here"))]; if let Some(extra) = extra { - helps.push((None, format!("{extra}"))) + helps.push((None, format!("{extra}"))); + helps.push((None, format!("see https://doc.rust-lang.org/nightly/std/sync/atomic/index.html#memory-model-for-atomic-accesses for more information about the Rust memory model"))); } helps.push((None, format!("this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior"))); helps.push((None, format!("see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information"))); diff --git a/tests/fail/data_race/mixed_size_read.stderr b/tests/fail/data_race/mixed_size_read.stderr index cb7dc89359..8988655208 100644 --- a/tests/fail/data_race/mixed_size_read.stderr +++ b/tests/fail/data_race/mixed_size_read.stderr @@ -10,6 +10,7 @@ help: and (1) occurred earlier here LL | a16.load(Ordering::SeqCst); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ = help: overlapping unsynchronized atomic accesses must use the same access size + = help: see https://doc.rust-lang.org/nightly/std/sync/atomic/index.html#memory-model-for-atomic-accesses for more information about the Rust memory model = 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 = note: BACKTRACE (of the first span): diff --git a/tests/fail/data_race/mixed_size_write.stderr b/tests/fail/data_race/mixed_size_write.stderr index b3908e9c6b..55c9011f1b 100644 --- a/tests/fail/data_race/mixed_size_write.stderr +++ b/tests/fail/data_race/mixed_size_write.stderr @@ -10,6 +10,7 @@ help: and (1) occurred earlier here LL | a16.store(1, Ordering::SeqCst); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = help: overlapping unsynchronized atomic accesses must use the same access size + = help: see https://doc.rust-lang.org/nightly/std/sync/atomic/index.html#memory-model-for-atomic-accesses for more information about the Rust memory model = 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 = note: BACKTRACE (of the first span): diff --git a/tests/fail/data_race/read_read_race1.stderr b/tests/fail/data_race/read_read_race1.stderr index 0846a88f36..e1009472fe 100644 --- a/tests/fail/data_race/read_read_race1.stderr +++ b/tests/fail/data_race/read_read_race1.stderr @@ -10,6 +10,7 @@ help: and (1) occurred earlier here LL | unsafe { ptr.read() }; | ^^^^^^^^^^ = help: overlapping atomic and non-atomic accesses must be synchronized, even if both are read-only + = help: see https://doc.rust-lang.org/nightly/std/sync/atomic/index.html#memory-model-for-atomic-accesses for more information about the Rust memory model = 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 = note: BACKTRACE (of the first span): diff --git a/tests/fail/data_race/read_read_race2.stderr b/tests/fail/data_race/read_read_race2.stderr index c6181cc45b..22017ae633 100644 --- a/tests/fail/data_race/read_read_race2.stderr +++ b/tests/fail/data_race/read_read_race2.stderr @@ -10,6 +10,7 @@ help: and (1) occurred earlier here LL | a.load(Ordering::SeqCst); | ^^^^^^^^^^^^^^^^^^^^^^^^ = help: overlapping atomic and non-atomic accesses must be synchronized, even if both are read-only + = help: see https://doc.rust-lang.org/nightly/std/sync/atomic/index.html#memory-model-for-atomic-accesses for more information about the Rust memory model = 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 = note: BACKTRACE (of the first span): diff --git a/tests/fail/weak_memory/racing_mixed_size.stderr b/tests/fail/weak_memory/racing_mixed_size.stderr index 03b5a4e4c1..d35970205f 100644 --- a/tests/fail/weak_memory/racing_mixed_size.stderr +++ b/tests/fail/weak_memory/racing_mixed_size.stderr @@ -10,6 +10,7 @@ help: and (1) occurred earlier here LL | x.store(1, Relaxed); | ^^^^^^^^^^^^^^^^^^^ = help: overlapping unsynchronized atomic accesses must use the same access size + = help: see https://doc.rust-lang.org/nightly/std/sync/atomic/index.html#memory-model-for-atomic-accesses for more information about the Rust memory model = 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 = note: BACKTRACE (of the first span): diff --git a/tests/fail/weak_memory/racing_mixed_size_read.stderr b/tests/fail/weak_memory/racing_mixed_size_read.stderr index 05eba41f4d..e85d76951b 100644 --- a/tests/fail/weak_memory/racing_mixed_size_read.stderr +++ b/tests/fail/weak_memory/racing_mixed_size_read.stderr @@ -10,6 +10,7 @@ help: and (1) occurred earlier here LL | x.load(Relaxed); | ^^^^^^^^^^^^^^^ = help: overlapping unsynchronized atomic accesses must use the same access size + = help: see https://doc.rust-lang.org/nightly/std/sync/atomic/index.html#memory-model-for-atomic-accesses for more information about the Rust memory model = 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 = note: BACKTRACE (of the first span):