Skip to content

Commit c9a46de

Browse files
authored
Merge pull request #299 from Lind-Project/poison_fix
Recover from mutex poisoning
2 parents 54fd9a6 + a0ed5e2 commit c9a46de

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)