Skip to content

Commit a0ed5e2

Browse files
author
lind
committed
recover from mutex poisoning
1 parent 54fd9a6 commit a0ed5e2

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/tests/mod.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,15 @@ mod setup {
3636
set_panic_hook();
3737

3838
//acquiring a lock on TESTMUTEX prevents other tests from running concurrently
39-
let thelock = TESTMUTEX.lock().unwrap();
39+
let thelock = TESTMUTEX.lock().unwrap_or_else(
40+
|e| {
41+
//if the lock is poisoned, we need to clear the poison and clean up references to the cage.
42+
lindrustfinalize();
43+
//clear the mutex poisoning.
44+
TESTMUTEX.clear_poison();
45+
//return the underlying guard.
46+
e.into_inner()
47+
});
4048

4149
interface::RUSTPOSIX_TESTSUITE.store(true, interface::RustAtomicOrdering::Relaxed);
4250

0 commit comments

Comments
 (0)