nagisa / rust_libloading

Bindings around the platform's dynamic library loading primitives with greatly improved memory safety.
https://docs.rs/libloading
ISC License
1.22k stars 100 forks source link

Is it possible to catch_unwind library's panic #156

Closed tkkcc closed 3 weeks ago

tkkcc commented 3 weeks ago

I am trying to let the host handle plugin(library)'s panic gracefully. The host can continue if one plugin panic. It works to catch_unwind at plugin side, but not at host side(cross ffi-boundary). I wonder if it is possible currently or in the future. I already use "C-unwind" abi, and rustc 1.82.0-nightly.

reproduce: https://github.com/tkkcc/libloading_catch_unwind_test

nagisa commented 3 weeks ago

You did not explain what exactly is going wrong, but in short, loading a library via libloading is no different from linking it as a shared library ahead of time. As far as I know there are no fundamental reasons why it ought to not work, but there are considerations like C-unwind that you appear to have considered already. So I don't really have any immediate advice.

Regardless, this is not a right place for user support questions – I do not have capacity for them. Consider e.g. users.rust-lang.org or other similar forums for questions on use.