about summary refs log tree commit diff
diff options
context:
space:
mode:
authorChris Denton <christophersdenton@gmail.com>2022-08-02 01:08:13 +0100
committerChris Denton <christophersdenton@gmail.com>2022-08-02 01:08:50 +0100
commit27b9b166d13024ca103dc8d611724b06c32302da (patch)
tree70d4f924d01f7761ed1a3f90e38858795f20ed5b
parent1f5d8d49eb6111931091f700d07518cd2b80bc18 (diff)
downloadrust-27b9b166d13024ca103dc8d611724b06c32302da.tar.gz
rust-27b9b166d13024ca103dc8d611724b06c32302da.zip
Error on broken pipe but do not ICE
-rw-r--r--compiler/rustc_driver/src/lib.rs11
1 files changed, 11 insertions, 0 deletions
diff --git a/compiler/rustc_driver/src/lib.rs b/compiler/rustc_driver/src/lib.rs
index 53ae913f94f..94639bf8e1e 100644
--- a/compiler/rustc_driver/src/lib.rs
+++ b/compiler/rustc_driver/src/lib.rs
@@ -1148,6 +1148,17 @@ static DEFAULT_HOOK: LazyLock<Box<dyn Fn(&panic::PanicInfo<'_>) + Sync + Send +
     LazyLock::new(|| {
         let hook = panic::take_hook();
         panic::set_hook(Box::new(|info| {
+            // 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)]
+            if let Some(msg) = info.payload().downcast_ref::<String>() {
+                if msg.starts_with("failed printing to stdout: ") && msg.ends_with("(os error 232)")
+                {
+                    early_error_no_abort(ErrorOutputType::default(), &msg);
+                    return;
+                }
+            };
+
             // Invoke the default handler, which prints the actual panic message and optionally a backtrace
             (*DEFAULT_HOOK)(info);