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

Index out of bounds #769

Open
RGBCube opened this issue Mar 11, 2024 · 8 comments
Open

Index out of bounds #769

RGBCube opened this issue Mar 11, 2024 · 8 comments
Labels
bug Something isn't working

Comments

@RGBCube
Copy link

RGBCube commented Mar 11, 2024

Platform: Linux, NixOS
Terminal software: Ghostty

I get this when I do ffmpeg -i RGBCube.gif -crf, assuming ffmpeg is installed.

thread 'main' panicked at /build/rustc-1.75.0-src/library/core/src/str/mod.rs:666:13:
byte index 4 is out of bounds of `dds`
stack backtrace:
   0: rust_begin_unwind
   1: core::panicking::panic_fmt
   2: core::str::slice_error_fail_rt
   3: core::str::slice_error_fail
   4: reedline::menu::columnar_menu::ColumnarMenu::create_string
   5: <core::iter::adapters::map::Map<I,F> as core::iter::traits::iterator::Iterator>::fold
   6: <alloc::string::String as core::iter::traits::collect::FromIterator<alloc::string::String>>::from_iter
   7: <reedline::menu::columnar_menu::ColumnarMenu as reedline::menu::Menu>::menu_string
   8: reedline::painting::painter::Painter::print_menu
   9: reedline::painting::painter::Painter::repaint_buffer
  10: reedline::engine::Reedline::repaint
  11: reedline::engine::Reedline::read_line
  12: nu_cli::repl::evaluate_repl
  13: nu::run::run_repl
  14: nu::main
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

Here is a recording, but it doesn't show the trace as it appears for a split second: https://asciinema.org/a/oO8bzFkNpKFd3aFVq7Bfatr2d

The .cast file has it, though.

Here is my completer config:

$env.config.completions = {
  algorithm:      prefix
  case_sensitive: false
  partial:        true
  quick:          true
  external: {
    enable:      true
    max_results: 100
    completer:   {|tokens: list<string>|
      let expanded = scope aliases | where name == $tokens.0 | get --ignore-errors expansion.0

      mut expanded_tokens = if $expanded != null and $tokens.0 != "cd" {
        $expanded | split row " " | append ($tokens | skip 1)
      } else {
        $tokens
      }

      $expanded_tokens.0 = ($expanded_tokens.0 | str trim --left --char "^")

      fish --command $"complete '--do-complete=($expanded_tokens | str join ' ')'"
      | $"value(char tab)description(char newline)" + $in
      | from tsv --flexible --no-infer
    }
  }
}

Everything is from nixpkgs unstable.

@RGBCube RGBCube added the bug Something isn't working label Mar 11, 2024
@RGBCube
Copy link
Author

RGBCube commented Mar 11, 2024

The output of fish --command "complete '--do-complete=ffmpeg -i RGBCube.gif -crf'" is this:

comfortnoise    RFC 3389 comfort noise generator
dds     DirectDraw Surface image decoder
derf_dpcm       DPCM Xilam DERF
sunrast Sun Rasterfile image

And then you do the pipeline and get this:

╭───┬──────────────┬──────────────────────────────────╮
│ # │    value     │           description            │
├───┼──────────────┼──────────────────────────────────┤
│ 0 │ comfortnoise │ RFC 3389 comfort noise generator │
│ 1 │ dds          │ DirectDraw Surface image decoder │
│ 2 │ derf_dpcm    │ DPCM Xilam DERF                  │
│ 3 │ sunrast      │ Sun Rasterfile image             │
╰───┴──────────────┴──────────────────────────────────╯

Seems normal to me, the issue isn't in the completer?

@fdncred
Copy link
Collaborator

fdncred commented Mar 11, 2024

What version of nushell are you running?

I've seen this ColumnarMenu involved in panics a few times recently. @Tastaturtaste and @maxomatic458 have worked on menus most recently, maybe they have an idea?

@maxomatic458
Copy link
Contributor

i think it might be this line here:

let (match_str, remaining_str) = suggestion.value.split_at(match_len);

we could probably add a check there and if it fails we just dont style (looks like that can fail with some external completers)

ill try to make a PR for this later today

@RGBCube
Copy link
Author

RGBCube commented Mar 11, 2024

What version of nushell are you running?

I've seen this ColumnarMenu involved in panics a few times recently. @Tastaturtaste and @maxomatic458 have worked on menus most recently, maybe they have an idea?

0.90.1

@fdncred
Copy link
Collaborator

fdncred commented Mar 11, 2024

@RGBCube can you try 0.91.1 and see if it's still there?

@RGBCube
Copy link
Author

RGBCube commented Mar 15, 2024

@RGBCube can you try 0.91.1 and see if it's still there?

Yes, the problem persists.

@fdncred
Copy link
Collaborator

fdncred commented Mar 19, 2024

@maxomatic458 do you have time to look into fixing this or did I miss it already?

@maxomatic458
Copy link
Contributor

@fdncred #782 should fix this

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

Successfully merging a pull request may close this issue.

3 participants