Description
gtk-rs/cairo#257 added bindings for “user data” owned by cairo objects. Each user data entry has a destructor function pointer that cairo calls when the object is destroyed. This helps solve life time issues, since with reference counting it can be hard to predict when an object will be destroyed exactly.
The bindings are generic and accept user data of any type. They forward destructor function pointer calls to Drop
, which potentially panic and unwind. However, until rust-lang/rust#58794 is resolved, unwinding into C is undefined behavior.
A possible fix is using std::panic::catch_unwind
in the destructor function. However even if we stash the panic payload somewhere at that point, there is no good place in the code to call resume_unwind
. So the best we can do might be to abort the process.