]> git.lizzy.rs Git - rust.git/blobdiff - library/std/src/thread/tests.rs
Auto merge of #100782 - thomcc:fix-android-sigaddset, r=Mark-Simulacrum
[rust.git] / library / std / src / thread / tests.rs
index ec68b5291880298aa8b31926dee073cf9b695810..130e47c8d44f09e0e8434089875124bf886c4fa9 100644 (file)
@@ -329,3 +329,22 @@ fn foo(x: &u8) {
     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));
+            }
+        });
+    }
+}