Skip to content

Panic when piped into head #25

Closed

Description

@tavianator
$ find | head
.
./.git
./.git/branches
./.git/hooks
./.git/hooks/applypatch-msg.sample
./.git/hooks/commit-msg.sample
./.git/hooks/post-update.sample
./.git/hooks/pre-applypatch.sample
./.git/hooks/pre-commit.sample
./.git/hooks/prepare-commit-msg.sample
$ RUST_BACKTRACE=1 ./target/debug/find | head
.
./.git
./.git/branches
./.git/hooks
./.git/hooks/applypatch-msg.sample
./.git/hooks/commit-msg.sample
./.git/hooks/post-update.sample
./.git/hooks/pre-applypatch.sample
./.git/hooks/pre-commit.sample
./.git/hooks/prepare-commit-msg.sample
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Error { repr: Os { code: 32, message: "Broken pipe" } }', src/libcore/result.rs:859
stack backtrace:
   0: std::sys::imp::backtrace::tracing::imp::unwind_backtrace
   1: std::sys_common::backtrace::_print
   2: std::panicking::default_hook::{{closure}}
   3: std::panicking::default_hook
   4: std::panicking::rust_panic_with_hook
   5: std::panicking::begin_panic
   6: std::panicking::begin_panic_fmt
   7: rust_begin_unwind
   8: core::panicking::panic_fmt
   9: core::result::unwrap_failed
             at /build/rust/src/rustc-1.17.0-src/src/libcore/macros.rs:29
  10: <core::result::Result<T, E>>::unwrap
             at /build/rust/src/rustc-1.17.0-src/src/libcore/result.rs:737
  11: <findutils::find::matchers::printer::Printer as findutils::find::matchers::Matcher>::matches
             at ./src/find/matchers/printer.rs:26
  12: <findutils::find::matchers::logical_matchers::AndMatcher as findutils::find::matchers::Matcher>::matches::{{closure}}
             at ./src/find/matchers/logical_matchers.rs:39
  13: <core::slice::Iter<'a, T> as core::iter::iterator::Iterator>::all::{{closure}}
             at /build/rust/src/rustc-1.17.0-src/src/libcore/slice.rs:1027
  14: <core::slice::Iter<'a, T>>::search_while
             at /build/rust/src/rustc-1.17.0-src/src/libcore/slice.rs:1118
  15: <core::slice::Iter<'a, T> as core::iter::iterator::Iterator>::all
             at /build/rust/src/rustc-1.17.0-src/src/libcore/slice.rs:1026
  16: <findutils::find::matchers::logical_matchers::AndMatcher as findutils::find::matchers::Matcher>::matches
             at ./src/find/matchers/logical_matchers.rs:39
  17: findutils::find::process_dir
             at ./src/find/mod.rs:122
  18: findutils::find::do_find
             at ./src/find/mod.rs:139
  19: findutils::find::find_main
             at ./src/find/mod.rs:198
  20: find::main
             at ./src/find/main.rs:14
  21: std::panicking::try::do_call
  22: __rust_maybe_catch_panic
  23: std::rt::lang_start
  24: main
  25: __libc_start_main
  26: _start

Activity

  1. hanbings commented on Apr 4, 2024

    @hanbings
    Collaborator

    The panic is caused by the SIGPIPE signal issued after the head instruction reads the output. Refer to similar problems in uutils/coreutils and used uucore::panic::mute_sigpipe_panic(); to fix it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions