about summary refs log tree commit diff
path: root/library/std/src/thread
diff options
context:
space:
mode:
authorRalf Jung <post@ralfj.de>2022-08-04 09:01:00 -0400
committerRalf Jung <post@ralfj.de>2022-08-18 18:07:39 -0400
commit27b044433367d7305f71bcf67dd9b5be0a0bd65a (patch)
tree0c6eef8280cb9854fc4cb672c9a42fc1b5293a49 /library/std/src/thread
parentac66baad1a9787f60ff86fac125da8176e053dbc (diff)
downloadrust-27b044433367d7305f71bcf67dd9b5be0a0bd65a.tar.gz
rust-27b044433367d7305f71bcf67dd9b5be0a0bd65a.zip
add some Miri-only tests
Diffstat (limited to 'library/std/src/thread')
-rw-r--r--library/std/src/thread/tests.rs19
1 files changed, 19 insertions, 0 deletions
diff --git a/library/std/src/thread/tests.rs b/library/std/src/thread/tests.rs
index ec68b529188..130e47c8d44 100644
--- a/library/std/src/thread/tests.rs
+++ b/library/std/src/thread/tests.rs
@@ -329,3 +329,22 @@ fn test_scoped_threads_nll() {
     let x = 42_u8;
     foo(&x);
 }
+
+// Regression test for https://github.com/rust-lang/rust/issues/98498.
+#[test]
+#[cfg(miri)] // relies on Miri's data race detector
+fn scope_join_race() {
+    for _ in 0..100 {
+        let a_bool = AtomicBool::new(false);
+
+        thread::scope(|s| {
+            for _ in 0..5 {
+                s.spawn(|| a_bool.load(Ordering::Relaxed));
+            }
+
+            for _ in 0..5 {
+                s.spawn(|| a_bool.load(Ordering::Relaxed));
+            }
+        });
+    }
+}