about summary refs log tree commit diff
path: root/compiler/rustc_driver_impl/src
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2024-03-12 14:01:38 +0000
committerbors <bors@rust-lang.org>2024-03-12 14:01:38 +0000
commit7de1a1f6db26cf7af43cca74819118428e6317ee (patch)
treeee4539bb7b4538e49e6d052bd4d4e956cd6facb5 /compiler/rustc_driver_impl/src
parent3b85d2c7fc6d1698e68b94f7bc1a5c9633f2554d (diff)
parent288380d4578e6e0be913fea6852226227a6c4170 (diff)
downloadrust-7de1a1f6db26cf7af43cca74819118428e6317ee.tar.gz
rust-7de1a1f6db26cf7af43cca74819118428e6317ee.zip
Auto merge of #122218 - Zoxc:no-interleave-panics, r=michaelwoerister
Lock stderr in panic handler

Fixes https://github.com/rust-lang/rust/issues/119789.
Diffstat (limited to 'compiler/rustc_driver_impl/src')
-rw-r--r--compiler/rustc_driver_impl/src/lib.rs3
1 files changed, 3 insertions, 0 deletions
diff --git a/compiler/rustc_driver_impl/src/lib.rs b/compiler/rustc_driver_impl/src/lib.rs
index 7b1070f309b..c4488354135 100644
--- a/compiler/rustc_driver_impl/src/lib.rs
+++ b/compiler/rustc_driver_impl/src/lib.rs
@@ -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)]