File tree 1 file changed +6
-2
lines changed
1 file changed +6
-2
lines changed Original file line number Diff line number Diff line change 49
49
50
50
use alloc:: boxed:: Box ;
51
51
use core:: any:: Any ;
52
- use core:: mem;
52
+ use core:: mem:: { self , ManuallyDrop } ;
53
53
use libc:: { c_int, c_uint, c_void} ;
54
54
55
55
struct Exception {
@@ -264,7 +264,11 @@ pub unsafe fn panic(data: Box<dyn Any + Send>) -> u32 {
264
264
// _CxxThrowException executes entirely on this stack frame, so there's no
265
265
// need to otherwise transfer `data` to the heap. We just pass a stack
266
266
// 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) } ) ;
268
272
let throw_ptr = & mut exception as * mut _ as * mut _ ;
269
273
270
274
// This... may seems surprising, and justifiably so. On 32-bit MSVC the
You can’t perform that action at this time.
0 commit comments