Skip to content

Commit a8568db

Browse files
committed
Explain the panic! in exception_copy
1 parent 3f0c097 commit a8568db

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/libpanic_unwind/seh.rs

+8
Original file line numberDiff line numberDiff line change
@@ -218,13 +218,20 @@ static mut TYPE_DESCRIPTOR: _TypeDescriptor = _TypeDescriptor {
218218
//
219219
// Note that x86 Windows uses the "thiscall" calling convention for C++ member
220220
// functions instead of the default "C" calling convention.
221+
//
222+
// The exception_copy function is a bit special here: it is invoked by the MSVC
223+
// runtime under a try/catch block and the panic that we generate here will be
224+
// used as the result of the exception copy. This is used by the C++ runtime to
225+
// support capturing exceptions with std::exception_ptr, which we can't support
226+
// because Box<dyn Any> isn't clonable.
221227
cfg_if::cfg_if! {
222228
if #[cfg(target_arch = "x86")] {
223229
unsafe extern "thiscall" fn exception_cleanup(e: *mut [u64; 2]) {
224230
if (*e)[0] != 0 {
225231
cleanup(*e);
226232
}
227233
}
234+
#[unwind(allowed)]
228235
unsafe extern "thiscall" fn exception_copy(_dest: *mut [u64; 2],
229236
_src: *mut [u64; 2])
230237
-> *mut [u64; 2] {
@@ -236,6 +243,7 @@ cfg_if::cfg_if! {
236243
cleanup(*e);
237244
}
238245
}
246+
#[unwind(allowed)]
239247
unsafe extern "C" fn exception_copy(_dest: *mut [u64; 2],
240248
_src: *mut [u64; 2])
241249
-> *mut [u64; 2] {

0 commit comments

Comments
 (0)