Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Panic when piping --check to head #2926

Open
YaLTeR opened this issue Aug 16, 2018 · 4 comments
Open

Panic when piping --check to head #2926

YaLTeR opened this issue Aug 16, 2018 · 4 comments
Labels
blocked Blocked on rustc, an RFC, etc. bug Panic, non-idempotency, invalid code, etc. p-low

Comments

@YaLTeR
Copy link
Contributor

YaLTeR commented Aug 16, 2018

rustfmt 0.99.2-nightly (5c9a2b6 2018-08-07)

└─ env RUST_BACKTRACE=1 cargo +nightly fmt -- --check | head
Diff in /home/yalter/Source/rust/yalter-bot/src/bot.rs at line 21:
     pub fn new(discord: Discord, modules: Vec<Box<Module>>) -> Self {
         // Connect.
         let (connection, ready) = discord.connect().expect("Connect failed");
-        println!(
-            "[Ready] {} is serving {} servers.",
-            ready.user.username,
-            ready.servers.len()
-        );
+        println!("[Ready] {} is serving {} servers.",
thread 'main' panicked at 'failed printing to stdout: Broken pipe (os error 32)', libstd/io/stdio.rs:696:9
stack backtrace:
   0: std::sys::unix::backtrace::tracing::imp::unwind_backtrace
             at libstd/sys/unix/backtrace/tracing/gcc_s.rs:49
   1: std::sys_common::backtrace::print
             at libstd/sys_common/backtrace.rs:71
             at libstd/sys_common/backtrace.rs:59
   2: std::panicking::default_hook::{{closure}}
             at libstd/panicking.rs:211
   3: std::panicking::default_hook
             at libstd/panicking.rs:227
   4: std::panicking::rust_panic_with_hook
             at libstd/panicking.rs:475
   5: std::panicking::continue_panic_fmt
             at libstd/panicking.rs:390
   6: std::panicking::begin_panic_fmt
             at libstd/panicking.rs:345
   7: std::io::stdio::_print
             at libstd/io/stdio.rs:696
             at libstd/io/stdio.rs:705
   8: rustfmt_nightly::rustfmt_diff::OutputWriter::writeln
   9: rustfmt_nightly::filemap::write_file
  10: <rustfmt_nightly::Session<'b, T> as rustfmt_nightly::formatting::FormatHandler>::handle_formatted_file
  11: rustfmt_nightly::formatting::format_project
  12: syntax::with_globals
  13: <rustfmt_nightly::Session<'b, T>>::format
  14: rustfmt::format_and_emit_report
  15: <rustfmt_nightly::Session<'b, T>>::override_config
  16: rustfmt::execute
  17: rustfmt::main
  18: std::rt::lang_start::{{closure}}
  19: std::panicking::try::do_call
             at libstd/rt.rs:59
             at libstd/panicking.rs:310
  20: __rust_maybe_catch_panic
             at libpanic_unwind/lib.rs:105
  21: std::rt::lang_start_internal
             at libstd/panicking.rs:289
             at libstd/panic.rs:392
             at libstd/rt.rs:58
  22: main
  23: __libc_start_main
  24: <unknown>
@topecongiro topecongiro added the bug Panic, non-idempotency, invalid code, etc. label Aug 16, 2018
@max-sixty
Copy link
Contributor

Haven't diagnosed, but a couple findings to move this forward:

  • Only panics with that specific rustfmt.toml
  • With that rustfmt.toml, the formatting isn't stable - it switches back & forth each time cargo fmt is run

@YaLTeR
Copy link
Contributor Author

YaLTeR commented Aug 29, 2018

Actually after noticing this on one of my projects it seems to be rust-lang/rust#46016 which affects anything using print*!().

@topecongiro topecongiro added the blocked Blocked on rustc, an RFC, etc. label Jun 12, 2019
@ytmimi
Copy link
Contributor

ytmimi commented Jul 20, 2022

Confirming this is still an issue using rustfmt 1.5.1-nightly (2f3ddd9f 2022-06-27).

run cargo +nightly fmt -- --emit stdout | head from the root of the rustfmt repo:

output

rustfmt/build.rs:

use std::env;
use std::fs::File;
use std::io::Write;
use std::path::{Path, PathBuf};
use std::process::Command;

fn main() {
    // Only check .git/HEAD dirty status if it exists - doing so when
Error writing files: io error: rustfmt/src/bin/main.rs: Broken pipe (os error 32)
Error writing files: io error: rustfmt/src/cargo-fmt/main.rs: Broken pipe (os error 32)
Error writing files: io error: rustfmt/src/format-diff/main.rs: Broken pipe (os error 32)
Error writing files: io error: rustfmt/src/git-rustfmt/main.rs: Broken pipe (os error 32)
Error writing files: io error: rustfmt/src/attr/doc_comment.rs: Broken pipe (os error 32)
Error writing files: io error: rustfmt/tests/cargo-fmt/main.rs: Broken pipe (os error 32)
Error writing files: io error: rustfmt/tests/rustfmt/main.rs: Broken pipe (os error 32)
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Os { code: 32, kind: BrokenPipe, message: "Broken pipe" }', src/tools/rustfmt/src/bin/main.rs:34:31
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

This might be related to #5114

@ytmimi
Copy link
Contributor

ytmimi commented Jul 27, 2022

Also seems tangentially related to #2696

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
blocked Blocked on rustc, an RFC, etc. bug Panic, non-idempotency, invalid code, etc. p-low
Projects
None yet
Development

No branches or pull requests

4 participants