diff options
| author | Amanieu d'Antras <amanieu@gmail.com> | 2019-12-26 10:26:53 +0100 |
|---|---|---|
| committer | Amanieu d'Antras <amanieu@gmail.com> | 2020-01-11 10:18:44 +0000 |
| commit | 46f52260d89517bcb1c49b189dfb54645776e8c3 (patch) | |
| tree | 6c4c2c454b355eb7f624d52cb6464ade9588d8d1 | |
| parent | 10720b418ecc72709adddba1b26e2cb293558e1b (diff) | |
| download | rust-46f52260d89517bcb1c49b189dfb54645776e8c3.tar.gz rust-46f52260d89517bcb1c49b189dfb54645776e8c3.zip | |
Simplify exception cleanup for libunwind-style unwinding
| -rw-r--r-- | src/libpanic_unwind/gcc.rs | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/src/libpanic_unwind/gcc.rs b/src/libpanic_unwind/gcc.rs index 6a48fa05f8d..6bec2686533 100644 --- a/src/libpanic_unwind/gcc.rs +++ b/src/libpanic_unwind/gcc.rs @@ -57,7 +57,7 @@ use unwind as uw; #[repr(C)] struct Exception { _uwe: uw::_Unwind_Exception, - cause: Option<Box<dyn Any + Send>>, + cause: Box<dyn Any + Send>, } pub unsafe fn panic(data: Box<dyn Any + Send>) -> u32 { @@ -67,7 +67,7 @@ pub unsafe fn panic(data: Box<dyn Any + Send>) -> u32 { exception_cleanup, private: [0; uw::unwinder_private_data_size], }, - cause: Some(data), + cause: data, }); let exception_param = Box::into_raw(exception) as *mut uw::_Unwind_Exception; return uw::_Unwind_RaiseException(exception_param) as u32; @@ -87,10 +87,8 @@ pub fn payload() -> *mut u8 { } pub unsafe fn cleanup(ptr: *mut u8) -> Box<dyn Any + Send> { - let my_ep = ptr as *mut Exception; - let cause = (*my_ep).cause.take(); - uw::_Unwind_DeleteException(ptr as *mut _); - cause.unwrap() + let exception = Box::from_raw(ptr as *mut Exception); + exception.cause } // Rust's exception class identifier. This is used by personality routines to |
