Lock stderr in panic handler

This commit is contained in:
John Kåre Alsaker 2024-03-09 01:26:59 +01:00
parent a655e648a9
commit 288380d457

View file

@ -1317,6 +1317,9 @@ pub fn install_ice_hook(
panic::update_hook(Box::new( panic::update_hook(Box::new(
move |default_hook: &(dyn Fn(&PanicInfo<'_>) + Send + Sync + 'static), move |default_hook: &(dyn Fn(&PanicInfo<'_>) + Send + Sync + 'static),
info: &PanicInfo<'_>| { info: &PanicInfo<'_>| {
// Lock stderr to prevent interleaving of concurrent panics.
let _guard = io::stderr().lock();
// If the error was caused by a broken pipe then this is not a bug. // If the error was caused by a broken pipe then this is not a bug.
// Write the error and return immediately. See #98700. // Write the error and return immediately. See #98700.
#[cfg(windows)] #[cfg(windows)]