Function mz_ore::panic::install_enhanced_handler
source ยท pub fn install_enhanced_handler()
Expand description
Overwrites the default panic handler with an enhanced panic handler.
The enhanced panic handler:
-
Always emits a backtrace, regardless of how
RUST_BACKTRACE
was configured. -
Writes to stderr as atomically as possible, to minimize interleaving with concurrent log messages.
-
Instructs the entire process to abort if any thread panics.
By default, when a thread panics in Rust, only that thread is affected, and other threads continue running unaffected. This is a bad default. In almost all programs, thread panics are unexpected, unrecoverable, and leave the overall program in an invalid state. It is therefore typically less confusing to abort the entire program.
For example, consider a simple program with two threads communicating through a channel, where the first thread is waiting for the second thread to send a value over the channel. If the second thread panics, the first thread will block forever for a value that will never be produced. Blocking forever will be more confusing to the end user than aborting the program entirely.
Note that after calling this function, computations in which a panic is
expected must use the special catch_unwind
function in this module to
recover. Note that the catch_unwind
function in the standard library is
not compatible with this improved panic handler.