Skip to content

Commit

Permalink
Explain the panic! in exception_copy
Browse files Browse the repository at this point in the history
  • Loading branch information
Amanieu committed Jan 11, 2020
1 parent 4361192 commit 838e387
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/libpanic_unwind/seh.rs
Expand Up @@ -218,13 +218,20 @@ 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]) {
if (*e)[0] != 0 {
cleanup(*e);
}
}
#[unwind(allowed)]
unsafe extern "thiscall" fn exception_copy(_dest: *mut [u64; 2],
_src: *mut [u64; 2])
-> *mut [u64; 2] {
Expand All @@ -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] {
Expand Down

0 comments on commit 838e387

Please sign in to comment.