The documentation for
It is currently undefined behavior to unwind from Rust code into foreign code
but unfortunately that’s exactly what I wanted to do. libjpeg expects its error handler callback to never return, so I make it panic on error via something like this:
It appears to work fine on x86_64. How big risk is it, if:
- I’m mixing with only plain C, not C++
setjmpis not used
- catch_panic + panic are always called on the same thread, same stack (there are no async callbacks).