diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2022-08-10 00:00:26 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-08-10 00:00:26 +0200 |
| commit | cf7a9ae8699033c5d2dd860dc0b2360851c49356 (patch) | |
| tree | 1086193f641d33bcf8810791270b0cf2ead7eb89 | |
| parent | 0dc39c7bd9795927b903c8c24e89a00788ce3e33 (diff) | |
| parent | 27b9b166d13024ca103dc8d611724b06c32302da (diff) | |
| download | rust-cf7a9ae8699033c5d2dd860dc0b2360851c49356.tar.gz rust-cf7a9ae8699033c5d2dd860dc0b2360851c49356.zip | |
Rollup merge of #100040 - ChrisDenton:broken-pipe, r=davidtwco
Error on broken pipe but do not backtrace or ICE Windows will report a broken pipe as a normal error which in turn `println!` will panic on. Currently this causes rustc to produce a backtrace and ICE. However, this is not a bug with rustc so a backtrace is overly verbose and ultimately unhelpful to the user. Kind of fixes #98700. Although this is admittedly a bit of a hack because at panic time all we have is a string to inspect. On zulip it was suggested that libstd might someday provide a way to indicate a soft panic but that day isn't today.
| -rw-r--r-- | compiler/rustc_driver/src/lib.rs | 11 |
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); |
