You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Some of the examples are using the assert! macro. This will panic and thus unwind. Unwinding across FFI boundaries however is undefined behavior and needs to be catched.
This can be solved either by:
Build with panic = "abort" in cargo.toml
Use std::panic::catch_unwind to catch the unwinding before it hits FFI code
Same as 2. but made easier by using the macro callback_guard! from the glib crate
I prefer number 1 (better performance) as long as the library created does not actively use unwinding, for example by restarting paniced threads. Since unwinding is a very important topic when it comes to FFI I think there should be a chapter with pros and cons in the book.
The text was updated successfully, but these errors were encountered:
janderholm
changed the title
Unwinding into FFI is Undefined behaviour in examples
Unwinding into FFI is undefined behaviour
Jan 6, 2018
janderholm
changed the title
Unwinding into FFI is undefined behaviour
Unwinding into FFI is undefined behavior
Jan 6, 2018
Some of the examples are using the
assert!
macro. This will panic and thus unwind. Unwinding across FFI boundaries however is undefined behavior and needs to be catched.This can be solved either by:
panic = "abort"
in cargo.tomlstd::panic::catch_unwind
to catch the unwinding before it hits FFI codecallback_guard!
from the glib crateI prefer number 1 (better performance) as long as the library created does not actively use unwinding, for example by restarting paniced threads. Since unwinding is a very important topic when it comes to FFI I think there should be a chapter with pros and cons in the book.
The text was updated successfully, but these errors were encountered: