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 piped into head #25

Closed
tavianator opened this issue Jun 14, 2017 · 1 comment · Fixed by #351
Closed

Panic when piped into head #25

tavianator opened this issue Jun 14, 2017 · 1 comment · Fixed by #351
Labels

Comments

@tavianator
Copy link
Contributor

$ 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
@hanbings
Copy link
Collaborator

hanbings commented Apr 4, 2024

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
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants