Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
argv-minus-one opened this issue Feb 8, 2020 · 1 comment

Comments

@argv-minus-one
Copy link

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.
@sdroege
Copy link
Member

sdroege commented Feb 8, 2020

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...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants