Auto merge of #122218 - Zoxc:no-interleave-panics, r=michaelwoerister

Lock stderr in panic handler

Fixes https://github.com/rust-lang/rust/issues/119789.
This commit is contained in:
bors 2024-03-12 14:01:38 +00:00
commit 7de1a1f6db

View file

@ -1327,6 +1327,9 @@ pub fn install_ice_hook(
panic::update_hook(Box::new(
move |default_hook: &(dyn Fn(&PanicInfo<'_>) + Send + Sync + 'static),
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.
// Write the error and return immediately. See #98700.
#[cfg(windows)]