Skip to content

nushell panic on command: nu --testbin cococo 1 2 3 | first #12558

Closed

Description

@WindSoilder

Describe the bug

As title, while looking into an issue, I suddenly find out nushell panic when running testbin with first or last.

How to reproduce

run the given command: nu --testbin cococo 1 2 3 | first or nu --testbin cococo 1 2 3 | last

Expected behavior

I expect nu to show error message and not panic.

Screenshots

image

Configuration

key value
version 0.92.3
branch main
commit_hash 57b0c72
build_os linux-x86_64
build_target x86_64-unknown-linux-gnu
rust_version rustc 1.77.2 (25ef9e3d8 2024-04-09)
rust_channel stable-x86_64-unknown-linux-gnu
cargo_version cargo 1.77.2 (e52e36006 2024-03-26)
build_time 2024-04-18 06:26:33 +08:00
build_rust_channel debug
allocator mimalloc
features default, sqlite, trash, which
installed_plugins

Additional context

Here is the backtrace I get:

Error:   × Main thread panicked.
├─▶ at library/std/src/io/stdio.rs:1030:9
 ╰─▶ failed printing to stdout: Broken pipe (os error 32)
0: 0x5648a8039e14 - rust_begin_unwind at /rustc/25ef9e3d85d934b27d9dada2f9dd52b1dc63bb04/library/std/src/panicking.rs:647
1: 0x5648a806ab65 - core::panicking::panic_fmt::ha6effc2775a0749 
    at /rustc/25ef9e3d85d934b27d9dada2f9dd52b1dc63bb04/library/core/src/panicking.rs:72
2: 0x5648a802fc98 - std::io::stdio::print_to::hec970441a5e8c603 
    at /rustc/25ef9e3d85d934b27d9dada2f9dd52b1dc63bb04/library/std/src/io/stdio.rs:1030
- std::io::stdio::_print::h289ecbd691b224da
    at /rustc/25ef9e3d85d934b27d9dada2f9dd52b1dc63bb04/library/std/src/io/stdio.rs:1106
3: 0x5648a4f1b966 - nu::test_bins::cococo::hb38ee0f9c07a0471
    at /home/windsoilder/projects/nushell/src/test_bins.rs:82
4: 0x5648a4f0ad13 - nu::main::hc234e957e379aef3
    at /home/windsoilder/projects/nushell/src/main.rs:316
5: 0x5648a4f2c14b - core::ops::function::FnOnce::call_once::hcc040c3051d4cb6d
   at /rustc/25ef9e3d85d934b27d9dada2f9dd52b1dc63bb04/library/core/src/ops/function.rs:250

Activity

  1. added
    status:needs-triage
    on Apr 17, 2024
  2. WindSoilder commented on Apr 17, 2024

    @WindSoilder
    ContributorAuthor

    Nushell also shows a strangely BrokenPipe message if I run a script with first command:

    # test.nu
    print asdf
    

    Then running nu test.nu | first gives me this output:

    ❯ nu test.nu | first
    Error: nu::shell::only_supports_this_input_type
    
      × Input type not supported.
       ╭─[entry #1:1:1]
     1 │ nu test.nu | first
       · ─┬           ──┬──
       ·  │             ╰── only list, binary or range input data is supported
       ·  ╰── input type: raw data
       ╰────
    
    Error: nu::shell::io_error
    
      × I/O error
      help: Os { code: 32, kind: BrokenPipe, message: "Broken pipe" }
    
  3. devyn commented on Apr 18, 2024

    @devyn
    Contributor

    I think this is just because the testbins are not written with proper error handling. Writing to a pipe that's closed will cause an error, but nushell usually just exits silently in that case. It requires explicit handling though. This is a panic in the testbins, not in the engine itself

  4. WindSoilder commented on Apr 18, 2024

    @WindSoilder
    ContributorAuthor

    This is a panic in the testbins, not in the engine itself

    Hmm...I'm not totally agree with it, I still think there is something not right in engine.
    For the given example in my comment: nu test.nu | first
    It should not print out these error message:

    Error: nu::shell::io_error
    
      × I/O error
      help: Os { code: 32, kind: BrokenPipe, message: "Broken pipe" }
    

    It works fine on 0.91.

    And strangely enough, if I'm in 0.91, and I run nu --testbin cococo a b c | first(the nu is 0.92 or latest main), it doesn't panic either
    img

  5. added
    tests
    category:regression
    and removed
    status:needs-triage
    on Apr 18, 2024
  6. devyn commented on Apr 19, 2024

    @devyn
    Contributor

    That's interesting, I'll have a look then.

  7. weirdan commented on Aug 26, 2024

    @weirdan
    Contributor

    This doesn't seem to be happening anymore

  8. devyn commented on Aug 26, 2024

    @devyn
    Contributor

    There have been a lot of changes since then, so I assume it's probably been fixed

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

    category:regressionpanictests

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions