From 3a025760be8f4c56f0777fa34ba64a4f7bada8e7 Mon Sep 17 00:00:00 2001 From: Amanieu d'Antras Date: Fri, 10 Jan 2020 00:19:40 +0000 Subject: Abort if C++ tries to swallow a Rust panic --- src/libstd/panicking.rs | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src/libstd') diff --git a/src/libstd/panicking.rs b/src/libstd/panicking.rs index 599ccc809be..43c2965f231 100644 --- a/src/libstd/panicking.rs +++ b/src/libstd/panicking.rs @@ -55,6 +55,14 @@ extern "C" { fn __rust_start_panic(payload: usize) -> u32; } +/// This function is called by the panic runtime if FFI code catches a Rust +/// panic but doesn't rethrow it. We don't support this case since it messes +/// with our panic count. +#[rustc_std_internal_symbol] +extern "C" fn __rust_drop_panic() -> ! { + rtabort!("Rust panics must be rethrown"); +} + #[derive(Copy, Clone)] enum Hook { Default, -- cgit 1.4.1-3-g733a5 From 8f60db8da8f7f159dbe93ce481a4608633c4c1bf Mon Sep 17 00:00:00 2001 From: Amanieu d'Antras Date: Sun, 12 Jan 2020 16:59:44 +0000 Subject: Don't include __rust_drop_panic when testing libstd --- src/libstd/panicking.rs | 1 + 1 file changed, 1 insertion(+) (limited to 'src/libstd') diff --git a/src/libstd/panicking.rs b/src/libstd/panicking.rs index 43c2965f231..bfadeafb7c7 100644 --- a/src/libstd/panicking.rs +++ b/src/libstd/panicking.rs @@ -58,6 +58,7 @@ extern "C" { /// This function is called by the panic runtime if FFI code catches a Rust /// panic but doesn't rethrow it. We don't support this case since it messes /// with our panic count. +#[cfg(not(test))] #[rustc_std_internal_symbol] extern "C" fn __rust_drop_panic() -> ! { rtabort!("Rust panics must be rethrown"); -- cgit 1.4.1-3-g733a5