gir
gir copied to clipboard
Rust doesn't actually abort when unwinding through FFI functions; CallbackGuard may be needed again
Almost a year after #614 was merged, aborting when unwinding through an extern fn
was reverted from stable Rust again and, as of this writing, remains an open issue.
Does this mean CallbackGuard
needs to come back?
extern "C" fn try_panicking() {
panic!("Test panic");
}
fn main() {
if let Err(e) = std::panic::catch_unwind(|| try_panicking()) {
println!("Caught panic: {:?}", e);
}
println!("End of program.");
}
$ rustc --version
rustc 1.41.0 (5e1a79984 2020-01-27)
$ cargo run
Compiling test_program v0.1.0 (/home/[redacted]/test_program)
Finished dev [unoptimized + debuginfo] target(s) in 0.26s
Running `target/debug/test_program`
thread 'main' panicked at 'Test panic', src/main.rs:2:2
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace.
Caught panic: Any
End of program.
Does this mean
CallbackGuard
needs to come back?
Who knows. It was always supposed to panic again on FFI boundaries "really soon now" but then never happened.
I don't know what the current status of this is, but from what I understand things are more complicated now and maybe your testcase is actually supposed to work like this.
However it also still unwinds via FFI boundaries when actually going via C, and that should definitely panic but apparently not enough of the changes were applied back yet.
Best would be to first of all ask what the status of this is in the compiler. Adding it back will involve quite some manual work and code churn...