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

Panick when using -l option and piping the output #273

Closed
ngirard opened this issue Sep 3, 2019 · 7 comments · Fixed by #311
Closed

Panick when using -l option and piping the output #273

ngirard opened this issue Sep 3, 2019 · 7 comments · Fixed by #311
Labels
kind/bug Something isn't working

Comments

@ngirard
Copy link

ngirard commented Sep 3, 2019

Using the packaged lsd-musl_0.16.0_amd64.deb on Ubuntu 19.04.

Both

RUST_BACKTRACE=1 lsd| head
RUST_BACKTRACE=1 lsd -t| head

run fine, but doing

RUST_BACKTRACE=1 lsd -l| head

outputs

thread 'main' panicked at 'failed printing to stdout: Broken pipe (os error 32)', src/libstd/io/stdio.rs:792:9
stack backtrace:
   0: <unknown>
   1: <unknown>
   2: <unknown>
   ...
@ngirard ngirard added the kind/bug Something isn't working label Sep 3, 2019
@Peltoche
Copy link
Collaborator

Peltoche commented Sep 4, 2019

Curious, I can't reproduce the bug... Which shell do you use? Bash? Sh?

@ngirard
Copy link
Author

ngirard commented Sep 4, 2019

bash --version
GNU bash, version 5.0.3(1)-release (x86_64-pc-linux-gnu)

Oddly enough, it doesn't arise using Zsh.

@Peltoche
Copy link
Collaborator

Peltoche commented Sep 9, 2019

hum.... Reproduced on bash too. My guess is that bash close stdout a little too quickly for us when we have the -l flag and println panic when it fail. One possible solution would be to replace every println call by a call the the io::Write method and handle gracefully the error in case of a closed stdout.

This could be done by a macro I guess

related: rust-lang/rust#24821

@ackramer
Copy link

Just wanted to mention that I see the same issue on zsh 5.3 (x86_64-apple-darwin18.0).

@elpres
Copy link

elpres commented Dec 9, 2019

Here's a backtrace with lsd 0.16.0, zsh 4.3.11:

% ls -l nr | head -n 3   
...
...
...
thread 'main' panicked at 'failed printing to stdout: Broken pipe (os error 32)', src/libstd/io/stdio.rs:792:9
stack backtrace:
   0: std::sys::unix::backtrace::tracing::imp::unwind_backtrace
             at src/libstd/sys/unix/backtrace/tracing/gcc_s.rs:39
   1: std::sys_common::backtrace::_print
             at src/libstd/sys_common/backtrace.rs:71
   2: std::panicking::default_hook::{{closure}}
             at src/libstd/sys_common/backtrace.rs:59
             at src/libstd/panicking.rs:197
   3: std::panicking::default_hook
             at src/libstd/panicking.rs:211
   4: std::panicking::rust_panic_with_hook
             at src/libstd/panicking.rs:474
   5: std::panicking::continue_panic_fmt
             at src/libstd/panicking.rs:381
   6: std::panicking::begin_panic_fmt
             at src/libstd/panicking.rs:336
   7: std::io::stdio::_print
             at src/libstd/io/stdio.rs:792
             at src/libstd/io/stdio.rs:802
   8: lsd::core::Core::run
   9: lsd::main
  10: std::rt::lang_start::{{closure}}
  11: std::panicking::try::do_call
             at src/libstd/rt.rs:49
             at src/libstd/panicking.rs:293
  12: __rust_maybe_catch_panic
             at src/libpanic_unwind/lib.rs:85
  13: std::rt::lang_start_internal
             at src/libstd/panicking.rs:272
             at src/libstd/panic.rs:394
             at src/libstd/rt.rs:48
  14: main
  15: __libc_start_main
  16: <unknown>

@ngirard
Copy link
Author

ngirard commented Jan 19, 2020

@Peltoche hey, happy new year and thanks for the fix !

Would you be kind enough to publish a new release ? Cheers !

@Peltoche
Copy link
Collaborator

Yep, sorry. I'm don't have a lot of free time for open-source at the moment. I hope I will be able to take some time for a new release during the next week.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants