Trait CrashEvent

Source
pub unsafe trait CrashEvent: Send + Sync {
    // Required method
    fn on_crash(&self, context: &CrashContext) -> CrashEventResult;
}
Expand description

User implemented trait for handling a crash event that has ocurred.

§Safety

This trait is marked unsafe as care needs to be taken when implementing it due to the Self::on_crash method being run in a compromised context. In general, it is advised to do as little as possible when handling a crash, with more complicated or dangerous (in a compromised context) code being intialized before the CrashHandler is installed, or hoisted out to another process entirely.

§Linux

Notably, only a small subset of libc functions are async signal safe and calling non-safe ones can have undefined behavior, including such common ones as malloc (especially if using a multi-threaded allocator).

§Windows

Windows structured exceptions don’t have the a notion similar to signal safety, but it is again recommended to do as little work as possible in response to an exception.

§Macos

Mac uses exception ports (sorry, can’t give a good link here since Apple documentation is terrible) which are handled by a thread owned by the exception handler which makes them slightly safer to handle than UNIX signals, but it is again recommended to do as little work as possible.

Required Methods§

Source

fn on_crash(&self, context: &CrashContext) -> CrashEventResult

Method invoked when a crash occurs.

Returning true indicates your handler has processed the crash and that no further handlers should run.

Implementors§