Open
Description
All panics must be catch and unwind otherwise it is UB.
I recommend use catch_unwind
with the following if let
:
let result = panic::catch_unwind(|| {
// ffi function call
});
if let Err(err) = result {
// if `err` panic in `Drop` we will be sad
forget(err);
}
You can create macro
or function to resolve it
In currently implementation:
#[ffi::specialize_for(
. . .
)]
unsafe fn drop_links<T: LinkType>(this: *mut c_void) {
let links: &mut WrappedLinks<T> = unnull_or_panic(this);
drop_in_place(links);
}
We can split to:
unsafe fn drop_links_impl<T: LinkType>(this: *mut c_void) {
// impl
}
#[ffi::specialize_for(
. . .
)]
unsafe fn drop_links<T: LinkType>(this: *mut c_void) {
catch_unwind(/* some */)
}
Or add this behavior to ffi::specialize_for