about summary refs log tree commit diff
diff options
context:
space:
mode:
authorAmanieu d'Antras <amanieu@gmail.com>2020-01-01 22:14:37 +0100
committerAmanieu d'Antras <amanieu@gmail.com>2020-01-11 10:18:44 +0000
commit838e3874fc11f24ebe8a7dff02a7f7614a5d2938 (patch)
treef6ead622f0523897de6625f1351d76bed458ef08
parent43611921120e2df3383f99b42bf060a6be28f23e (diff)
downloadrust-838e3874fc11f24ebe8a7dff02a7f7614a5d2938.tar.gz
rust-838e3874fc11f24ebe8a7dff02a7f7614a5d2938.zip
Explain the panic! in exception_copy
-rw-r--r--src/libpanic_unwind/seh.rs8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/libpanic_unwind/seh.rs b/src/libpanic_unwind/seh.rs
index 417de8e23cc..ef27e38c2d1 100644
--- a/src/libpanic_unwind/seh.rs
+++ b/src/libpanic_unwind/seh.rs
@@ -218,6 +218,12 @@ static mut TYPE_DESCRIPTOR: _TypeDescriptor = _TypeDescriptor {
 //
 // Note that x86 Windows uses the "thiscall" calling convention for C++ member
 // functions instead of the default "C" calling convention.
+//
+// The exception_copy function is a bit special here: it is invoked by the MSVC
+// runtime under a try/catch block and the panic that we generate here will be
+// used as the result of the exception copy. This is used by the C++ runtime to
+// support capturing exceptions with std::exception_ptr, which we can't support
+// because Box<dyn Any> isn't clonable.
 cfg_if::cfg_if! {
     if #[cfg(target_arch = "x86")] {
         unsafe extern "thiscall" fn exception_cleanup(e: *mut [u64; 2]) {
@@ -225,6 +231,7 @@ cfg_if::cfg_if! {
                 cleanup(*e);
             }
         }
+        #[unwind(allowed)]
         unsafe extern "thiscall" fn exception_copy(_dest: *mut [u64; 2],
                                                    _src: *mut [u64; 2])
                                                    -> *mut [u64; 2] {
@@ -236,6 +243,7 @@ cfg_if::cfg_if! {
                 cleanup(*e);
             }
         }
+        #[unwind(allowed)]
         unsafe extern "C" fn exception_copy(_dest: *mut [u64; 2],
                                             _src: *mut [u64; 2])
                                             -> *mut [u64; 2] {