Skip to content

Panic in reedline when a completion suggestion is shorter than the token-being-completed #406

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

Closed
reubeno opened this issue Mar 12, 2025 · 3 comments · Fixed by #415
Closed
Labels
bug Something isn't working

Comments

@reubeno
Copy link
Owner

reubeno commented Mar 12, 2025

To reproduce:

$ git push origin:<TAB>

This will likely need to be turned into an issue against reedline, but here's the crash report for now until we can triage it:

"name" = "brush"
"operating_system" = "Linux [64-bit]"
"crate_version" = "0.2.15"
"explanation" = """
Panic occurred in file '/usr/src/azl/BUILD/rustc-1.75.0-src/library/core/src/str/mod.rs' at line 666
"""
"cause" = "byte index 8 is out of bounds of `HEAD`"
"method" = "Panic"
"backtrace" = """
   0:     0x564a7fcc11c1 - rust_begin_unwind
   1:     0x564a7f834fd4 - core::panicking::panic_fmt::h276b49f6e7fd64eb
   2:     0x564a7fb5e984 - core::str::slice_error_fail_rt::hc2871e65f6151ea9
   3:     0x564a7f835816 - core::str::slice_error_fail::h2ef53d322f653805
   4:     0x564a7fbca84e - <reedline::menu::columnar_menu::ColumnarMenu as reedline::menu::Menu>::menu_string::{{closure}}::hbe4dad6f085cc81f
   5:     0x564a7fbca533 - <reedline::menu::columnar_menu::ColumnarMenu as reedline::menu::Menu>::menu_string::ha4be51426522791a
   6:     0x564a7fbc6d61 - reedline::painting::painter::Painter::print_menu::hf40e645ee9b6af10
   7:     0x564a7fbc4cc2 - reedline::painting::painter::Painter::repaint_buffer::h1c438ac78621e831
   8:     0x564a7fbb928d - reedline::engine::Reedline::repaint::h826a723c97f824e5
   9:     0x564a7f86c78f - brush_interactive::interactive_shell::InteractiveShell::run_interactively::{{closure}}::h99a72d711537d8bd
  10:     0x564a7f888484 - brush::run::{{closure}}::hbd6ebc62368de427
  11:     0x564a7f884429 - brush::main::h0992de706ebf0320
  12:     0x564a7f8700b3 - std::sys_common::backtrace::__rust_begin_short_backtrace::h0c523aa2ecf8b50d
@reubeno reubeno added the bug Something isn't working label Mar 12, 2025
@reubeno
Copy link
Owner Author

reubeno commented Mar 12, 2025

A debug stack trace shows that the panic happens under a call to str::split_at under ColumnarMenu::create_string():

Image

@reubeno
Copy link
Owner Author

reubeno commented Mar 13, 2025

This seems to happen anytime there's a generated completion that's shorter than the token-being-completed.

Here's a case that consistently reproduces the panic:

brush$ function myfunc() {
    COMPREPLY=("abc" "def")
}
brush$ complete -F myfunc mycmd
brush$ mycmd something<TAB>

@reubeno
Copy link
Owner Author

reubeno commented Mar 13, 2025

Well, it turns out that the panic was (serendipitously?) fixed by nushell/reedline#886! The fix was merged into reedline and the panic will get resolved when we pull the release with this fix.

As a tangent, the specific issue with git completion was also running afoul of brush's tokenization of the command line to be completed. #407 aims to address that, but we need to test it a fair bit more before merging.

@reubeno reubeno changed the title Panic under reedline::menu::columnar_menu::ColumnarMenu Panic in reedline when a completion suggestion is shorter than the token-being-completed Mar 13, 2025
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.

1 participant