Skip to content

Commit

Permalink
Don't double panic in futures-test::test::panic_waker::wake_panic (#2236
Browse files Browse the repository at this point in the history
)

This function can get called during Drop, so it's important not to panic
if the thread is already panicking. Doing so makes debugging panics much
harder.
  • Loading branch information
asomers committed Oct 17, 2020
1 parent f605139 commit 66949b8
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion futures-test/src/task/panic_waker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ unsafe fn clone_panic_waker(_data: *const ()) -> RawWaker {
unsafe fn noop(_data: *const ()) {}

unsafe fn wake_panic(_data: *const ()) {
panic!("should not be woken");
if ! std::thread::panicking() {
panic!("should not be woken");
}
}

const PANIC_WAKER_VTABLE: RawWakerVTable = RawWakerVTable::new(
Expand Down

0 comments on commit 66949b8

Please sign in to comment.