File tree Expand file tree Collapse file tree 1 file changed +6
-2
lines changed
Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Original file line number Diff line number Diff line change 4949
5050use alloc:: boxed:: Box ;
5151use core:: any:: Any ;
52- use core:: mem;
52+ use core:: mem:: { self , ManuallyDrop } ;
5353use libc:: { c_int, c_uint, c_void} ;
5454
5555struct Exception {
@@ -264,7 +264,11 @@ pub unsafe fn panic(data: Box<dyn Any + Send>) -> u32 {
264264 // _CxxThrowException executes entirely on this stack frame, so there's no
265265 // need to otherwise transfer `data` to the heap. We just pass a stack
266266 // pointer to this function.
267- let mut exception = Exception { data : Some ( data) } ;
267+ //
268+ // The ManuallyDrop is needed here since we don't want Exception to be
269+ // dropped when unwinding. Instead it will be dropped by exception_cleanup
270+ // which is invoked by the C++ runtime.
271+ let mut exception = ManuallyDrop :: new ( Exception { data : Some ( data) } ) ;
268272 let throw_ptr = & mut exception as * mut _ as * mut _ ;
269273
270274 // This... may seems surprising, and justifiably so. On 32-bit MSVC the
You can’t perform that action at this time.
0 commit comments