Skip to main content

drop_payload

Function drop_payload 

Source
pub fn drop_payload(payload: Box<dyn Any + Send>)
Expand description

Drops a panic payload while suppressing any unwind from its Drop impl.

std::panic::catch_unwind catches the original panic, but if the payload itself panics on drop the second panic unwinds the caller. For an extern "C" thunk that is undefined behaviour. Wrapping the drop in another catch_unwind keeps the surface around the FFI boundary unwind-free even with adversarial payloads (e.g. panic_any(T) where T: Drop panics).