Skip to content

Rust doesn't actually abort when unwinding through FFI functions; CallbackGuard may be needed again #889

@argv-minus-one

Description

@argv-minus-one

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions