Skip to content

Instantly share code, notes, and snippets.

@haxpor
Last active May 1, 2022 06:26
Show Gist options
  • Save haxpor/f593667ad883bc915a581bd95e358ecc to your computer and use it in GitHub Desktop.
Save haxpor/f593667ad883bc915a581bd95e358ecc to your computer and use it in GitHub Desktop.
attempt to bypass poisoned mutex (not work yet)
macro_rules! serial_test {
(fn $name: ident() $body: block) => {
#[test]
fn $name() {
let guard = LOCK.try_lock();
if let Ok(mutex) = guard {
$body
}
else {
let err = guard.unwrap_err();
if let std::sync::TryLockError::Poisoned(p) = err {
let _guard = p.get_ref(); // not hit this at all
$body
}
else {
panic!("Error cannot acquire lock"); // always hit this
}
}
};
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment