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

LSP: index out of bounds: the len is 1 but the index is 1 #11269

Closed
dmorn opened this issue Jul 22, 2024 · 1 comment · Fixed by #11825
Closed

LSP: index out of bounds: the len is 1 but the index is 1 #11269

dmorn opened this issue Jul 22, 2024 · 1 comment · Fixed by #11825
Labels
A-language-server Area: Language server client C-bug Category: This is a bug E-has-instructions Call for participation: Has instructions for fixing the issue and opening a PR

Comments

@dmorn
Copy link

dmorn commented Jul 22, 2024

Summary

Erlang project with elp. helix randomly panics!

Trace:

thread 'main' panicked at helix-term/src/ui/lsp.rs:163:35:
index out of bounds: the len is 1 but the index is 1
stack backtrace:
   0:        0x1019ce458 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h4bff038afc05d0ab
   1:        0x100df7698 - core::fmt::write::he9fa43146d420946
   2:        0x1019ca2d8 - std::io::Write::write_fmt::hf4fd30c8192b15d9
   3:        0x1019ce298 - std::sys_common::backtrace::print::h5d71f7b09493fc9b
   4:        0x1019cfe68 - std::panicking::default_hook::{{closure}}::hb75620628e95e648
   5:        0x1019cfbac - std::panicking::default_hook::h4ac4acc64d21c4ad
   6:        0x1019d045c - std::panicking::rust_panic_with_hook::h81dc715fa5de32cf
   7:        0x1019d0234 - std::panicking::begin_panic_handler::{{closure}}::h26c73eb75670321f
   8:        0x1019ce8ac - std::sys_common::backtrace::__rust_end_short_backtrace::hef4773cf0f80485b
   9:        0x1019cffe8 - _rust_begin_unwind
  10:        0x101a92620 - core::panicking::panic_fmt::h10bd3bfe5bb30d67
  11:        0x101a92764 - core::panicking::panic_bounds_check::h0059132d60d26813
  12:        0x1013e68d4 - <helix_term::ui::lsp::SignatureHelp as helix_term::compositor::Component>::required_size::hcedf4e7ddb24c3d7
  13:        0x10153578c - helix_term::ui::popup::Popup<T>::render_info::h3d72aeab9a0803cc
  14:        0x1015380f4 - <helix_term::ui::popup::Popup<T> as helix_term::compositor::Component>::render::h9b998179b28c9188
  15:        0x10178b498 - helix_term::application::Application::render::{{closure}}::hd9cb597a36e0ecf8
  16:        0x10178963c - helix_term::application::Application::run::{{closure}}::h7c093398c458d3a0
  17:        0x10179b47c - tokio::runtime::park::CachedParkThread::block_on::h2a5eb8c2a2745328
  18:        0x101804688 - hx::main::h40afa6c5c39a856d
  19:        0x1017f4984 - std::sys_common::backtrace::__rust_begin_short_backtrace::hf2c8060bb84d5bac
  20:        0x1017f8e34 - std::rt::lang_start::{{closure}}::h6934599efcb3bcb2
  21:        0x1019c3b38 - std::rt::lang_start_internal::haeade8bb0e866fa6
  22:        0x101804c84 - _main

Reproduction Steps

I tried this:

  1. hx
  2. Coding

I expected this to happen:
Helix keeps on working.

Instead, this happened:
Helix panics!

Helix log

~/.cache/helix/helix.log
2024-07-22T10:20:50.108 helix_term::application [WARN] unhandled window/showMessage: ShowMessageParams { typ: Info, message: "ELP version: 1.1.0+build-2024-07-16" }
2024-07-22T10:20:51.262 helix_term::application [ERROR] Language Server: Method workspace/codeLens/refresh not found in request 3
2024-07-22T11:02:59.314 helix_term::application [WARN] unhandled window/showMessage: ShowMessageParams { typ: Info, message: "ELP version: 1.1.0+build-2024-07-16" }
2024-07-22T11:02:59.331 helix_lsp [ERROR] client was already removed
2024-07-22T11:02:59.335 helix_lsp::transport [ERROR] elp err: <- StreamClosed
2024-07-22T11:03:00.366 helix_term::application [ERROR] Language Server: Method workspace/codeLens/refresh not found in request 3
2024-07-22T11:15:23.245 helix_term::application [WARN] unhandled window/showMessage: ShowMessageParams { typ: Info, message: "ELP version: 1.1.0+build-2024-07-16" }
2024-07-22T11:15:24.374 helix_term::application [ERROR] Language Server: Method workspace/codeLens/refresh not found in request 3
2024-07-22T11:19:38.839 helix_term::application [WARN] unhandled window/showMessage: ShowMessageParams { typ: Info, message: "ELP version: 1.1.0+build-2024-07-16" }
2024-07-22T11:19:39.864 helix_term::application [ERROR] Language Server: Method workspace/codeLens/refresh not found in request 3
2024-07-22T11:20:38.191 helix_term::application [WARN] unhandled window/showMessage: ShowMessageParams { typ: Info, message: "ELP version: 1.1.0+build-2024-07-16" }
2024-07-22T11:20:39.034 helix_term::application [ERROR] Language Server: Method workspace/codeLens/refresh not found in request 3

Platform

macOS

Terminal Emulator

iTerm2

Installation Method

source

Helix Version

helix 24.7 (dbaa636)

@dmorn dmorn added the C-bug Category: This is a bug label Jul 22, 2024
@the-mikedavis
Copy link
Member

The backtrace comes from the signature help component: the popup that shows the spec of the function you're typing out and which parameter you're on. ELP is sending an active_signature of 1 even though there is only one signature (0-indexed). We need to be more defensive and as the spec says:

If omitted or the value lies outside the range of signatures the value defaults to zero or is ignore[d] if the SignatureHelp as no signatures

But if you have an easy reproduction case you should report this to ELP as well - this is the only instance of a language server sending an out-of-bound index I've seen so far. The spec does allow it but I suspect it may be a bug in ELP anyways.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-language-server Area: Language server client C-bug Category: This is a bug E-has-instructions Call for participation: Has instructions for fixing the issue and opening a PR
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants