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 when Ctrl+n is pressed on LSP suggestions #1256

Closed
matszczygiel opened this issue Dec 13, 2021 · 2 comments
Closed

Panic when Ctrl+n is pressed on LSP suggestions #1256

matszczygiel opened this issue Dec 13, 2021 · 2 comments
Labels
A-language-server Area: Language server client C-bug Category: This is a bug

Comments

@matszczygiel
Copy link
Contributor

Hello,
I repeatedly get a panic when scrolling down the suggestions.

Backtrace:

└ 09:38:53 ✖127 ❯ RUST_BACKTRACE=full HELIX_RUNTIME=/home/msz/workspace/github/helix/runtime/ /home/msz/workspace/github/helix/target/debug/hx
thread 'main' panicked at 'Trying to access position outside the buffer: x=48, y=74, area=Rect { x: 0, y: 0, width: 271, height: 74 }', helix-tui/src/buffer.rs:195:9
stack backtrace:
   0:     0x562c1d1cb0cc - std::backtrace_rs::backtrace::libunwind::trace::hf6a6dfd7da937cb0
                               at /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c/library/std/src/../../backtrace/src/backtrace/libunwind.rs:90:5
   1:     0x562c1d1cb0cc - std::backtrace_rs::backtrace::trace_unsynchronized::hc596a19e4891f7f3
                               at /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x562c1d1cb0cc - std::sys_common::backtrace::_print_fmt::hb16700db31584325
                               at /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c/library/std/src/sys_common/backtrace.rs:67:5
   3:     0x562c1d1cb0cc - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h231c4190cfa75162
                               at /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c/library/std/src/sys_common/backtrace.rs:46:22
   4:     0x562c1d1f2f9c - core::fmt::write::h2a1462b5f8eea807
                               at /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c/library/core/src/fmt/mod.rs:1163:17
   5:     0x562c1d1c48c5 - std::io::Write::write_fmt::h71ddfebc68685972
                               at /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c/library/std/src/io/mod.rs:1696:15
   6:     0x562c1d1cd360 - std::sys_common::backtrace::_print::hcc197d4bebf2b369
                               at /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c/library/std/src/sys_common/backtrace.rs:49:5
   7:     0x562c1d1cd360 - std::sys_common::backtrace::print::h335a66af06738c7c
                               at /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c/library/std/src/sys_common/backtrace.rs:36:9
   8:     0x562c1d1cd360 - std::panicking::default_hook::{{closure}}::h6fac9ac9c8b79e52
                               at /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c/library/std/src/panicking.rs:210:50
   9:     0x562c1d1ccf15 - std::panicking::default_hook::h341c1030c6a1161b
                               at /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c/library/std/src/panicking.rs:227:9
  10:     0x562c1c135d33 - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::h232cfe248b80c1f7
                               at /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c/library/alloc/src/boxed.rs:1705:9
  11:     0x562c1c154453 - helix_term::application::Application::run::{{closure}}::{{closure}}::h92abb18189fbcda1
                               at /home/msz/workspace/github/helix/helix-term/src/application.rs:602:13
  12:     0x562c1d1cdba9 - std::panicking::rust_panic_with_hook::h50680ff4b44510c6
                               at /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c/library/std/src/panicking.rs:628:17
  13:     0x562c1d1cd630 - std::panicking::begin_panic_handler::{{closure}}::h9371c0fbb1e8465a
                               at /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c/library/std/src/panicking.rs:521:13
  14:     0x562c1d1cb574 - std::sys_common::backtrace::__rust_end_short_backtrace::h9b3efa22a5768c0f
                               at /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c/library/std/src/sys_common/backtrace.rs:139:18
  15:     0x562c1d1cd599 - rust_begin_unwind
                               at /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c/library/std/src/panicking.rs:517:5
  16:     0x562c1d1f1621 - core::panicking::panic_fmt::h23b9203e89cc61cf
                               at /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c/library/core/src/panicking.rs:100:14
  17:     0x562c1c6775d7 - helix_tui::buffer::Buffer::index_of::h82e8020eadca19d8
                               at /home/msz/workspace/github/helix/helix-tui/src/buffer.rs:195:9
  18:     0x562c1c6772fa - helix_tui::buffer::Buffer::get_mut::hc3743ff364958692
                               at /home/msz/workspace/github/helix/helix-tui/src/buffer.rs:172:17
  19:     0x562c1c677e9c - helix_tui::buffer::Buffer::clear_with::h8d5b4cd01d6c5287
                               at /home/msz/workspace/github/helix/helix-tui/src/buffer.rs:420:28
  20:     0x562c1c5296b3 - <helix_term::ui::completion::Completion as helix_term::compositor::Component>::render::hcea60fb3e2369d2f
                               at /home/msz/workspace/github/helix/helix-term/src/ui/completion.rs:353:13
  21:     0x562c1c5cec76 - <helix_term::ui::editor::EditorView as helix_term::compositor::Component>::render::hf3d8137080bf8fb9
                               at /home/msz/workspace/github/helix/helix-term/src/ui/editor.rs:1131:13
  22:     0x562c1c419e16 - helix_term::compositor::Compositor::render::hd636ce091a924166
                               at /home/msz/workspace/github/helix/helix-term/src/compositor.rs:166:13
  23:     0x562c1c2a7cb0 - helix_term::application::Application::render::h0aa801d49f713a3f
                               at /home/msz/workspace/github/helix/helix-term/src/application.rs:186:9
  24:     0x562c1c2a81a9 - helix_term::application::Application::handle_terminal_events::h3193439b5225672e
                               at /home/msz/workspace/github/helix/helix-term/src/application.rs:312:13
  25:     0x562c1c14dcab - helix_term::application::Application::event_loop::{{closure}}::h5ed7e8e849798c04
                               at /home/msz/workspace/github/helix/helix-term/src/application.rs:208:21
  26:     0x562c1c18121b - <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll::h25886de6b19f1f07
                               at /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c/library/core/src/future/mod.rs:80:19
  27:     0x562c1c153e53 - helix_term::application::Application::run::{{closure}}::hced5b60e0aff1076
                               at /home/msz/workspace/github/helix/helix-term/src/application.rs:605:9
  28:     0x562c1c1818d1 - <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll::hee9f0ebd93ea09d0
                               at /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c/library/core/src/future/mod.rs:80:19
  29:     0x562c1c186dfd - hx::main_impl::{{closure}}::hf1192e6569d9d701
                               at /home/msz/workspace/github/helix/helix-term/src/main.rs:113:21
  30:     0x562c1c181121 - <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll::h1bde113014667c4e
                               at /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c/library/core/src/future/mod.rs:80:19
  31:     0x562c1c18999e - tokio::park::thread::CachedParkThread::block_on::{{closure}}::h10df12709f0188ec
                               at /home/msz/.cargo/registry/src/github.aaakk.us.kg-1ecc6299db9ec823/tokio-1.14.0/src/park/thread.rs:263:54
  32:     0x562c1c189cc9 - tokio::coop::with_budget::{{closure}}::h4baf608f544c06cf
                               at /home/msz/.cargo/registry/src/github.aaakk.us.kg-1ecc6299db9ec823/tokio-1.14.0/src/coop.rs:106:9
  33:     0x562c1c19cf23 - std::thread::local::LocalKey<T>::try_with::hd71b808e02ced0dd
                               at /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c/library/std/src/thread/local.rs:399:16
  34:     0x562c1c19c844 - std::thread::local::LocalKey<T>::with::h1594545f65316a17
                               at /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c/library/std/src/thread/local.rs:375:9
  35:     0x562c1c189119 - tokio::coop::with_budget::h83f41b51467c3625
                               at /home/msz/.cargo/registry/src/github.aaakk.us.kg-1ecc6299db9ec823/tokio-1.14.0/src/coop.rs:99:5
  36:     0x562c1c189119 - tokio::coop::budget::h3db43e241a8c37f1
                               at /home/msz/.cargo/registry/src/github.aaakk.us.kg-1ecc6299db9ec823/tokio-1.14.0/src/coop.rs:76:5
  37:     0x562c1c189119 - tokio::park::thread::CachedParkThread::block_on::h02bbd19ad19ecce8
                               at /home/msz/.cargo/registry/src/github.aaakk.us.kg-1ecc6299db9ec823/tokio-1.14.0/src/park/thread.rs:263:31
  38:     0x562c1c14581e - tokio::runtime::enter::Enter::block_on::hb707082afe1aaf72
                               at /home/msz/.cargo/registry/src/github.aaakk.us.kg-1ecc6299db9ec823/tokio-1.14.0/src/runtime/enter.rs:151:13
  39:     0x562c1c141823 - tokio::runtime::thread_pool::ThreadPool::block_on::hd4b33b2ef5278a78
                               at /home/msz/.cargo/registry/src/github.aaakk.us.kg-1ecc6299db9ec823/tokio-1.14.0/src/runtime/thread_pool/mod.rs:77:9
  40:     0x562c1c14b974 - tokio::runtime::Runtime::block_on::hfa2aaa2f5640cbba
                               at /home/msz/.cargo/registry/src/github.aaakk.us.kg-1ecc6299db9ec823/tokio-1.14.0/src/runtime/mod.rs:463:43
  41:     0x562c1c146267 - hx::main_impl::h0dc87d3d0b997b0a
                               at /home/msz/workspace/github/helix/helix-term/src/main.rs:115:5
  42:     0x562c1c146099 - hx::main::hfb8bd0d1f2b7b878
                               at /home/msz/workspace/github/helix/helix-term/src/main.rs:37:21
  43:     0x562c1c19854b - core::ops::function::FnOnce::call_once::h5f37e7bcf904f492
                               at /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c/library/core/src/ops/function.rs:227:5
  44:     0x562c1c19d8fe - std::sys_common::backtrace::__rust_begin_short_backtrace::hac766f6d5b6920a1
                               at /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c/library/std/src/sys_common/backtrace.rs:123:18
  45:     0x562c1c180ba1 - std::rt::lang_start::{{closure}}::hcd298172dab0e9fe
                               at /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c/library/std/src/rt.rs:146:18
  46:     0x562c1d1cadab - core::ops::function::impls::<impl core::ops::function::FnOnce<A> for &F>::call_once::hc56adab7a77ec6e3
                               at /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c/library/core/src/ops/function.rs:259:13
  47:     0x562c1d1cadab - std::panicking::try::do_call::h29f013120c5abc65
                               at /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c/library/std/src/panicking.rs:403:40
  48:     0x562c1d1cadab - std::panicking::try::h86d5b2b66caec4cf
                               at /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c/library/std/src/panicking.rs:367:19
  49:     0x562c1d1cadab - std::panic::catch_unwind::h7dd136d787f51397
                               at /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c/library/std/src/panic.rs:133:14
  50:     0x562c1d1cadab - std::rt::lang_start_internal::{{closure}}::h4a199351e630a8a5
                               at /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c/library/std/src/rt.rs:128:48
  51:     0x562c1d1cadab - std::panicking::try::do_call::h20ceb9e5dff838c6
                               at /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c/library/std/src/panicking.rs:403:40
  52:     0x562c1d1cadab - std::panicking::try::hc2abb46a5e41bd43
                               at /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c/library/std/src/panicking.rs:367:19
  53:     0x562c1d1cadab - std::panic::catch_unwind::h52c3eb4408ad6dfb
                               at /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c/library/std/src/panic.rs:133:14
  54:     0x562c1d1cadab - std::rt::lang_start_internal::hd15a47be08101c28
                               at /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c/library/std/src/rt.rs:128:20
  55:     0x562c1c180b70 - std::rt::lang_start::ha9bad766014cffc3
                               at /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c/library/std/src/rt.rs:145:17
  56:     0x562c1c14633c - main
  57:     0x7f92f14eab25 - __libc_start_main
  58:     0x562c1c1312be - _start
  59:                0x0 - <unknown>
@matszczygiel matszczygiel changed the title Panic when Ctrl+n is pressed on suggestions Panic when Ctrl+n is pressed on LSP suggestions Dec 13, 2021
@midnightexigent
Copy link
Contributor

midnightexigent commented Dec 13, 2021

Looks like this was the offending change. This made it so that required_size() on markdown doesn't care if the returned height is more than the buffer can handle.

Also, since there aren't any checks performed on the returned values, height is passed regardless whether the buffer can handle it or not, causing the panic.

                if let Some((rel_width, rel_height)) = markdown_doc.required_size((width, height)) {
                    // no checks are made
                    width = rel_width; 
                    height = rel_height;
                }

@archseer
Copy link
Member

Ah right, I forgot the completion popups also use the markdown component. I expanded required_sizeso that the inputs that are passed in indicate the max area available, but the component can return larger values if it's scrollable.

archseer added a commit that referenced this issue Dec 21, 2021
* allow language.config (in languages.toml) to be passed in as a toml object

* Change config field for languages from json string to toml object

* remove indents on languages.toml config

* fix: remove patch version from serde_json import in helix-core

* Use same tree-sitter-zig as upstream/master

* fix(completion_popup): Fixes #1256

* Update helix-term/src/ui/completion.rs

* feat(languages): Add support for `Dockerfile`s

* docs(cargo-xtask-docgen):

* improvement(langs-dockerfile): Add `injection-regex` to `languages.toml` for
`Dockerfile`

* improvement(langs-dockerfile): Add injections.scm

* Update .gitmodules

Co-authored-by: Blaž Hrastnik <[email protected]>
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
Projects
None yet
Development

No branches or pull requests

4 participants