From 2b6543350188f671d970b58349fdf46cbeaf619c Mon Sep 17 00:00:00 2001 From: Taiki Endo Date: Fri, 22 Jul 2022 09:58:05 +0900 Subject: [PATCH] Miri: Fix thread leaks in doctests in utils --- ci/miri.sh | 3 +-- crossbeam-utils/src/backoff.rs | 2 ++ crossbeam-utils/src/sync/parker.rs | 2 ++ 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/ci/miri.sh b/ci/miri.sh index 9c747ab24..50b19b9e5 100755 --- a/ci/miri.sh +++ b/ci/miri.sh @@ -9,8 +9,7 @@ echo export RUSTFLAGS="${RUSTFLAGS:-} -Z randomize-layout" -# -Zmiri-ignore-leaks is needed because we use detached threads in tests/docs: https://github.com/rust-lang/miri/issues/1371 -MIRIFLAGS="-Zmiri-symbolic-alignment-check -Zmiri-disable-isolation -Zmiri-ignore-leaks" \ +MIRIFLAGS="-Zmiri-symbolic-alignment-check -Zmiri-disable-isolation" \ cargo miri test \ -p crossbeam-queue \ -p crossbeam-utils 2>&1 | ts -i '%.s ' diff --git a/crossbeam-utils/src/backoff.rs b/crossbeam-utils/src/backoff.rs index 1012f06b2..133cd1413 100644 --- a/crossbeam-utils/src/backoff.rs +++ b/crossbeam-utils/src/backoff.rs @@ -201,6 +201,7 @@ impl Backoff { /// assert_eq!(ready.load(SeqCst), false); /// spin_wait(&ready); /// assert_eq!(ready.load(SeqCst), true); + /// # std::thread::sleep(std::time::Duration::from_secs_f64(0.5)); // wait for background threads closed: https://github.com/rust-lang/miri/issues/1371 /// ``` /// /// [`AtomicBool`]: std::sync::atomic::AtomicBool @@ -269,6 +270,7 @@ impl Backoff { /// assert_eq!(ready.load(SeqCst), false); /// blocking_wait(&ready); /// assert_eq!(ready.load(SeqCst), true); + /// # std::thread::sleep(std::time::Duration::from_secs_f64(0.5)); // wait for background threads closed: https://github.com/rust-lang/miri/issues/1371 /// ``` /// /// [`AtomicBool`]: std::sync::atomic::AtomicBool diff --git a/crossbeam-utils/src/sync/parker.rs b/crossbeam-utils/src/sync/parker.rs index 531f5a5fc..663b37404 100644 --- a/crossbeam-utils/src/sync/parker.rs +++ b/crossbeam-utils/src/sync/parker.rs @@ -44,6 +44,7 @@ use std::time::{Duration, Instant}; /// /// // Wakes up when `u.unpark()` provides the token. /// p.park(); +/// # std::thread::sleep(std::time::Duration::from_secs_f64(0.5)); // wait for background threads closed: https://github.com/rust-lang/miri/issues/1371 /// ``` /// /// [`park`]: Parker::park @@ -241,6 +242,7 @@ impl Unparker { /// /// // Wakes up when `u.unpark()` provides the token. /// p.park(); + /// # std::thread::sleep(std::time::Duration::from_secs_f64(0.5)); // wait for background threads closed: https://github.com/rust-lang/miri/issues/1371 /// ``` /// /// [`park`]: Parker::park