]> git.lizzy.rs Git - rust.git/blobdiff - src/libpanic_unwind/emcc.rs
Abort if C++ tries to swallow a Rust panic
[rust.git] / src / libpanic_unwind / emcc.rs
index 61f33fd4d5d664dc02d3af55c6c7662d06daee69..268bafd24093043e411b2c67c20a14b92ef97cdc 100644 (file)
@@ -53,6 +53,10 @@ pub fn payload() -> *mut u8 {
 }
 
 struct Exception {
+    // This needs to be an Option because the object's lifetime follows C++
+    // semantics: when catch_unwind moves the Box out of the exception it must
+    // still leave the exception object in a valid state because its destructor
+    // is still going to be called by __cxa_end_catch..
     data: Option<Box<dyn Any + Send>>,
 }
 
@@ -76,6 +80,7 @@ pub unsafe fn panic(data: Box<dyn Any + Send>) -> u32 {
     extern "C" fn exception_cleanup(ptr: *mut libc::c_void) {
         unsafe {
             ptr::drop_in_place(ptr as *mut Exception);
+            super::__rust_drop_panic();
         }
     }
 }