@@ -402,8 +402,8 @@ unsafe extern "C" fn signal_handler(
402
402
403
403
/// The size of `CrashContext` can be too big w.r.t the size of alternatate stack
404
404
/// for `signal_handler`. Keep the crash context as a .bss field.
405
- static CRASH_CONTEXT : parking_lot:: Mutex < mem :: MaybeUninit < crash_context:: CrashContext > > =
406
- parking_lot:: const_mutex ( mem:: MaybeUninit :: uninit ( ) ) ;
405
+ static CRASH_CONTEXT : parking_lot:: Mutex < crash_context:: CrashContext > =
406
+ parking_lot:: const_mutex ( unsafe { mem:: zeroed ( ) } ) ;
407
407
408
408
pub ( super ) struct HandlerInner {
409
409
handler : Box < dyn crate :: CrashEvent > ,
@@ -430,18 +430,25 @@ impl HandlerInner {
430
430
// that we require
431
431
let nix_info = & * ( ( info as * const libc:: siginfo_t ) . cast :: < libc:: signalfd_siginfo > ( ) ) ;
432
432
433
+ debug_print ! ( "acquired siginfo" ) ;
434
+
433
435
// Allow ourselves to be dumped, if that is what the user handler wishes to do
434
436
let _set_dumpable = SetDumpable :: new ( self . dump_process ) ;
435
- let mut crash_ctx = CRASH_CONTEXT . lock ( ) ;
437
+ debug_print ! ( "set dumpable" ) ;
438
+ let mut cc = CRASH_CONTEXT . lock ( ) ;
436
439
437
440
{
438
- * crash_ctx = mem:: MaybeUninit :: zeroed ( ) ;
439
- let cc = & mut * crash_ctx. as_mut_ptr ( ) ;
441
+ use std:: ops:: DerefMut ;
442
+ #[ allow( clippy:: explicit_deref_methods) ]
443
+ ptr:: write_bytes ( cc. deref_mut ( ) , 0 , 1 ) ;
444
+ debug_print ! ( "zeroed crashctx" ) ;
440
445
441
446
ptr:: copy_nonoverlapping ( nix_info, & mut cc. siginfo , 1 ) ;
447
+ debug_print ! ( "copied siginfo" ) ;
442
448
443
449
let uc_ptr = & * ( uc as * const libc:: c_void ) . cast :: < crash_context:: ucontext_t > ( ) ;
444
450
ptr:: copy_nonoverlapping ( uc_ptr, & mut cc. context , 1 ) ;
451
+ debug_print ! ( "copied context" ) ;
445
452
446
453
cfg_if:: cfg_if! {
447
454
if #[ cfg( target_arch = "aarch64" ) ] {
@@ -453,7 +460,6 @@ impl HandlerInner {
453
460
} else if #[ cfg( not( target_arch = "arm" ) ) ] {
454
461
if !uc_ptr. uc_mcontext. fpregs. is_null( ) {
455
462
ptr:: copy_nonoverlapping( uc_ptr. uc_mcontext. fpregs, ( ( & mut cc. float_state) as * mut crash_context:: fpregset_t) . cast( ) , 1 ) ;
456
-
457
463
}
458
464
}
459
465
}
@@ -462,7 +468,7 @@ impl HandlerInner {
462
468
cc. tid = libc:: syscall ( libc:: SYS_gettid ) as i32 ;
463
469
}
464
470
465
- self . handler . on_crash ( & * crash_ctx . as_ptr ( ) )
471
+ self . handler . on_crash ( & cc )
466
472
}
467
473
}
468
474
}
0 commit comments