rust/tests/run-make/foreign-double-unwind/rmake.rs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

22 lines
1001 B
Rust
Raw Normal View History

2024-07-18 11:10:38 -05:00
// When using foreign function interface (FFI) with C++, it is possible
// to run into a "double unwind" if either both Rust and C++ run into a panic
// and exception at the same time, or C++ encounters two exceptions. In this case,
// one of the panic unwinds would be leaked and the other would be kept, leading
// to undefined behaviour. After this was fixed in #92911, this test checks that
// the keyword "unreachable" indicative of this bug triggering in this specific context
// does not appear after successfully compiling and executing the program.
// See https://github.com/rust-lang/rust/pull/92911
//@ needs-unwind
// Reason: this test exercises panic unwinding
//@ ignore-cross-compile
// Reason: the compiled binary is executed
2024-07-18 12:12:38 -05:00
use run_make_support::{build_native_static_lib_cxx, run_fail, rustc};
2024-07-18 11:10:38 -05:00
fn main() {
build_native_static_lib_cxx("foo");
rustc().input("foo.rs").arg("-lfoo").extra_rs_cxx_flags().run();
2024-07-18 12:12:38 -05:00
run_fail("foo").assert_stdout_not_contains("unreachable");
2024-07-18 11:10:38 -05:00
}