3 ms·
The called code is made unwind-safe at the FFI boundary using `std::panic::catch_unwind`. A panic will be converted to an Erlang exception.
by filmor 6y ago
The called code is made unwind-safe at the FFI boundary using `std::panic::catch_unwind`. A panic will be converted to an Erlang exception.
- pjmlp 6y agoExcept it doesn't work always, > Note that this function may not catch all panics in Rust. A panic in Rust is not always implemented via unwinding, but can be implemented by aborting the process as well. This function only catches unwinding panics, not those that abort the process.
- c-cube 6y agoIf you compile a NIF you probably will not go out of your way to write "panic = abort" in your project. Unwinding is the default behavior.
- pjmlp 6y agoIt depends on the dependencies.
- bluejekyll 6y agoFrom the docs filmor linked to, if a library sets panic = unwind and a user sets that to abort, “If any of your users choose to abort, they'll get a compile-time failure.”
- filmor 6y agoIt works whenever it's configured to unwind, which is the default. Apparently one can force this by adding a few lines in the rustler Cargo.toml (https://doc.rust-lang.org/edition-guide/rust-2018/error-handling-and-panics/controlling-panics-with-std-panic.html https://doc.rust-lang.org/edition-guide/rust-2018/error-hand...), I'll create a PR.