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 occurs when running `deno test | hoge #15767

Open
skanehira opened this issue Sep 4, 2022 · 5 comments
Open

Panic occurs when running `deno test | hoge #15767

skanehira opened this issue Sep 4, 2022 · 5 comments
Labels
bug Something isn't working help wanted community help requested testing related to deno test and coverage

Comments

@skanehira
Copy link
Contributor

skanehira commented Sep 4, 2022

Summary

Panic occurs when running deno test | hoge
It seems that panic occurs when using a non-existent command with pipe.

root@c2814216bc11:/sandbox# cat hoge_test.ts 
Deno.test("hoge", () => {})
root@c2814216bc11:/sandbox# RUST_BACKTRACE=full deno test | hoge
bash: hoge: command not found

============================================================
Deno has panicked. This is a bug in Deno. Please report this
at https://github.com/denoland/deno/issues/new.
If you can reliably reproduce this panic, include the
reproduction steps and re-run with the RUST_BACKTRACE=1 env
var set and include the backtrace in your report.

Platform: linux aarch64
Version: 1.25.1
Args: ["deno", "test"]

thread 'main' panicked at 'failed printing to stdout: Broken pipe (os error 32)', library/std/src/io/stdio.rs:1015:9
stack backtrace:
   0:     0xaaaad6e5bff4 - std::backtrace_rs::backtrace::libunwind::trace::hdaf7b926686b76e5
                               at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
   1:     0xaaaad6e5bff4 - std::backtrace_rs::backtrace::trace_unsynchronized::h24b637dca55f9a5e
                               at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0xaaaad6e5bff4 - std::sys_common::backtrace::_print_fmt::h4cb8409104309785
                               at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library/std/src/sys_common/backtrace.rs:66:5
   3:     0xaaaad6e5bff4 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::hc4ec9cb9b20b5a7b
                               at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library/std/src/sys_common/backtrace.rs:45:22
   4:     0xaaaad6667994 - core::fmt::write::h2322d71f3fb268fc
                               at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library/core/src/fmt/mod.rs:1197:17
   5:     0xaaaad6e3241c - std::io::Write::write_fmt::hc0c6b55df7cbd64b
                               at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library/std/src/io/mod.rs:1672:15
   6:     0xaaaad6e5df20 - std::sys_common::backtrace::_print::h446ed48475d9d586
                               at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library/std/src/sys_common/backtrace.rs:48:5
   7:     0xaaaad6e5df20 - std::sys_common::backtrace::print::h9b9a1d50fa9ea120
                               at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library/std/src/sys_common/backtrace.rs:35:9
   8:     0xaaaad6e5df20 - std::panicking::default_hook::{{closure}}::ha6c2222df3379e34
                               at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library/std/src/panicking.rs:295:22
   9:     0xaaaad6e5dbe0 - std::panicking::default_hook::hfce7a8f7bcbba82f
                               at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library/std/src/panicking.rs:314:9
  10:     0xaaaad66165b0 - deno::setup_panic_hook::{{closure}}::h70f0e0e72ca716d3
  11:     0xaaaad6e5e978 - std::panicking::rust_panic_with_hook::h90a858afb3dbe829
                               at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library/std/src/panicking.rs:702:17
  12:     0xaaaad6e5e7d8 - std::panicking::begin_panic_handler::{{closure}}::h882ab86c0d7c5158
                               at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library/std/src/panicking.rs:588:13
  13:     0xaaaad6e5e754 - std::sys_common::backtrace::__rust_end_short_backtrace::hbcab7df1db34555f
                               at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library/std/src/sys_common/backtrace.rs:138:18
  14:     0xaaaad6e5e720 - rust_begin_unwind
                               at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library/std/src/panicking.rs:584:5
  15:     0xaaaad635fec0 - core::panicking::panic_fmt::h58c4ca31339ea3fd
                               at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library/core/src/panicking.rs:142:14
  16:     0xaaaad6e51e34 - std::io::stdio::print_to::h9bc1b47bf826d5bf
                               at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library/std/src/io/stdio.rs:1015:9
  17:     0xaaaad6e51e34 - std::io::stdio::_print::h289c5a7b1c4fbf2f
                               at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library/std/src/io/stdio.rs:1027:5
  18:     0xaaaad65a1d7c - deno::tools::test::test_specifiers::{{closure}}::{{closure}}::h5bc01f3ead2e432f
  19:     0xaaaad65a1894 - tokio::runtime::task::harness::poll_future::h27742c278ca015bf
  20:     0xaaaad65a4898 - tokio::runtime::task::raw::poll::hb015e049a96a5e42
  21:     0xaaaad63b7a9c - deno_runtime::tokio_util::run_local::h549c3a54c2cf7083
  22:     0xaaaad63b70a0 - deno::main::hab3a8044ad842722
  23:     0xaaaad63b6938 - std::sys_common::backtrace::__rust_begin_short_backtrace::h0fd13418802ddd8d
  24:     0xaaaad63b6c68 - main
  25:     0xffffb0d673fc - <unknown>
  26:     0xffffb0d674cc - __libc_start_main
  27:     0xaaaad63916e4 - <unknown>
root@c2814216bc11:/sandbox# 
@kitsonk kitsonk added bug Something isn't working testing related to deno test and coverage help wanted community help requested labels Sep 5, 2022
@kitsonk
Copy link
Contributor

kitsonk commented Sep 5, 2022

It shouldn't panic, but obviously it isn't going to work.

@sigmaSd
Copy link
Contributor

sigmaSd commented Nov 26, 2022

This doesn't affect deno test only but all deno commands, "fixing" this would require changing all print! to write! and handling all the errors, I think it's just not worth it.

The only improvement I can see is not printing that message on this kind of situation, but I'm not sure how would one detect this.

@sigmaSd
Copy link
Contributor

sigmaSd commented Nov 26, 2022

On our custom panic hook, we can match on the panic message, and detect if its a broken pipe error and in that case write a better error

image

Do you think this is a reasonable approach ?

@sigmaSd
Copy link
Contributor

sigmaSd commented Nov 26, 2022

The messages stability are not guaranteed by rust API as far as I know, but it should still mostly work, and if it doesn't it just shows the current behavior

@bartlomieju
Copy link
Member

@sigmaSd could you open a PR that implements this solution?

sigmaSd added a commit to sigmaSd/deno that referenced this issue Dec 21, 2022
Currently if we get an error from rust stdio, like `Broken pipe` we print
our usual header and advise the user to report this as a bug.
But this is not a bug in deno, so this pr add a heuristic to detect this
and if its the case (error coming from stdio), just do the normal panic
without our deno header.

Relevant issues:

denoland#15767
denoland#14746
denoland#15045
denoland#15982
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted community help requested testing related to deno test and coverage
Projects
None yet
Development

No branches or pull requests

4 participants