Closed n0s4 closed 1 year ago
Putting the cursor on --
doesn't seem to trigger a panic, I suppose it's something else in the date format. Could you upload it as gist and post the link ?
full backtrace:
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Char index out of bounds: char index 61591, Rope/RopeSlice char length 61574', /sources/ropey-1.4.1/src/slice.rs:349:41
stack backtrace:
0: 0x56150e64600c - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h3e2b509ce2ce6007
1: 0x56150dfb5cbc - core::fmt::write::h753c7571fa063ecb
2: 0x56150e63e435 - std::io::Write::write_fmt::h2815c0519c99ba09
3: 0x56150e6491b5 - std::panicking::default_hook::{{closure}}::h78d3e6cf97fc623d
4: 0x56150e648e33 - std::panicking::default_hook::hda898f8d3ad1a5ae
5: 0x56150e50bf83 - helix_term::application::Application::run::{{closure}}::{{closure}}::hc426ef4564b0e6dc
6: 0x56150e649861 - std::panicking::rust_panic_with_hook::h1a5ea2d6c23051aa
7: 0x56150e64952a - std::panicking::begin_panic_handler::{{closure}}::h07f549390938b73f
8: 0x56150e646534 - std::sys_common::backtrace::__rust_end_short_backtrace::h5ec3758a92cfb00d
9: 0x56150e64928d - rust_begin_unwind
10: 0x56150df3ed01 - core::panicking::panic_fmt::h3a79a6a99affe1d5
11: 0x56150df3edf3 - core::result::unwrap_failed::ha0327e3803285d6e
12: 0x56150e0893a6 - ropey::slice::RopeSlice::char_to_byte::h0af44ccbe88700cc
13: 0x56150e08480c - helix_core::graphemes::nth_prev_grapheme_boundary::h5c28fa1317d8600c
14: 0x56150e07c4d6 - helix_core::selection::Range::grapheme_aligned::hf4ffb7d6cb9c3d84
15: 0x56150e07d780 - helix_core::selection::Selection::ensure_invariants::hd5a8655b0c6a9c70
16: 0x56150e4a6fda - helix_view::document::Document::apply_impl::h38f4b5293e7b8ecc
17: 0x56150e4a7ac6 - helix_view::document::Document::apply::hcfa99bb58b977fb3
18: 0x56150e3931b5 - helix_term::commands::increment_impl::had10c25cd4071978
19: 0x56150e2b56c8 - helix_term::ui::editor::EditorView::handle_keymap_event::hf4edf6a934fbb87f
20: 0x56150e2b7700 - <helix_term::ui::editor::EditorView as helix_term::compositor::Component>::handle_event::h0b0e7a1fa2584923
21: 0x56150e2cd04f - helix_term::compositor::Compositor::handle_event::h87dab55883cec336
22: 0x56150e2a6996 - helix_term::application::Application::handle_terminal_events::h130d19f94094b8a4
23: 0x56150e51a738 - <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll::h36ed2d9911f7fb67
24: 0x56150e4e5f5e - tokio::park::thread::CachedParkThread::block_on::hcb853cc0519d735f
25: 0x56150e4de9b9 - tokio::runtime::thread_pool::ThreadPool::block_on::he629f9db7d969a72
26: 0x56150e4fa88c - tokio::runtime::Runtime::block_on::h93d2d6fd504ee5ea
27: 0x56150e4db81a - hx::main::ha4fd9378bdb017e0
28: 0x56150e4e71e3 - std::sys_common::backtrace::__rust_begin_short_backtrace::ha7074b1a8ee7fe5e
29: 0x56150e4fa62d - std::rt::lang_start::{{closure}}::hbdc5c69d8a3ab41d
30: 0x56150e64566e - std::rt::lang_start_internal::h52e73755f77c7dd9
31: 0x56150e4df592 - main
32: 0x7fb37ed4c790 - __libc_start_main
33: 0x56150df6bf2a - _start
34: 0x0 - <unknown>
I managed to reproduce this with a subset of the file (with about 240 lines):
Backtrace:
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Char index out of bounds: char index 5908, Rope/RopeSlice char length 5905', /home/gokul/.cargo/registry/src/github.com-1ecc6299db9ec823/ropey-1.4.1/src/slice.rs:349:41
stack backtrace:
0: rust_begin_unwind
at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/std/src/panicking.rs:498:5
1: core::panicking::panic_fmt
at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/core/src/panicking.rs:116:14
2: core::result::unwrap_failed
at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/core/src/result.rs:1690:5
3: ropey::slice::RopeSlice::char_to_byte
4: helix_core::graphemes::nth_prev_grapheme_boundary
5: helix_core::selection::Range::grapheme_aligned
6: helix_core::selection::Selection::ensure_invariants
7: helix_view::document::Document::apply_impl
8: helix_view::document::Document::apply
9: helix_term::commands::increment_impl
10: helix_term::ui::editor::EditorView::handle_keymap_event
11: <helix_term::ui::editor::EditorView as helix_term::compositor::Component>::handle_event
12: helix_term::compositor::Compositor::handle_event
13: helix_term::application::Application::handle_terminal_events
14: <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll
15: tokio::park::thread::CachedParkThread::block_on
16: tokio::runtime::thread_pool::ThreadPool::block_on
17: tokio::runtime::Runtime::block_on
18: hx::main
Compiling in debug mode also triggered a debug assert:
I have narrowed this further to just 49 lines, cutting out the words, symbols, and the year part of the date:
subset.txt
This still crashes with the following keystrokes:
%
, s
, -
, enter
, l
(L), C-a
Ok, I've pushed this to as small a file as I can, just three lines:
sub.txt
Just selecting the 2nd character of every line and C-a
panics.
Still can't say what causes it though.
Edit, full backtrace:
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Char index out of bounds: char index 10, Rope/RopeSlice char length 7', /home/jm/.cargo/registry/src/github.com-1ecc6299db9ec823/ropey-1.4.1/src/slice.rs:349:41
stack backtrace:
0: 0x556d1768357c - std::backtrace_rs::backtrace::libunwind::trace::h91c465e73bf6c785
at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
1: 0x556d1768357c - std::backtrace_rs::backtrace::trace_unsynchronized::hae9da36f5d58b5f3
at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
2: 0x556d1768357c - std::sys_common::backtrace::_print_fmt::h7f499fa126a7effb
at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/std/src/sys_common/backtrace.rs:67:5
3: 0x556d1768357c - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h3e2b509ce2ce6007
at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/std/src/sys_common/backtrace.rs:46:22
4: 0x556d16fd6c6c - core::fmt::write::h753c7571fa063ecb
at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/core/src/fmt/mod.rs:1168:17
5: 0x556d1767b9a5 - std::io::Write::write_fmt::h2815c0519c99ba09
at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/std/src/io/mod.rs:1660:15
6: 0x556d17686725 - std::sys_common::backtrace::_print::h64941a6fc8b0ed9b
at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/std/src/sys_common/backtrace.rs:49:5
7: 0x556d17686725 - std::sys_common::backtrace::print::hcf25e43e1a9b0766
at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/std/src/sys_common/backtrace.rs:36:9
8: 0x556d17686725 - std::panicking::default_hook::{{closure}}::h78d3e6cf97fc623d
at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/std/src/panicking.rs:211:50
9: 0x556d176863a3 - std::panicking::default_hook::hda898f8d3ad1a5ae
at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/std/src/panicking.rs:228:9
10: 0x556d17547453 - helix_term::application::Application::run::{{closure}}::{{closure}}::h7fba2e9e000873a0
11: 0x556d17686dd1 - std::panicking::rust_panic_with_hook::h1a5ea2d6c23051aa
at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/std/src/panicking.rs:610:17
12: 0x556d17686a9a - std::panicking::begin_panic_handler::{{closure}}::h07f549390938b73f
at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/std/src/panicking.rs:502:13
13: 0x556d17683aa4 - std::sys_common::backtrace::__rust_end_short_backtrace::h5ec3758a92cfb00d
at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/std/src/sys_common/backtrace.rs:139:18
14: 0x556d176867fd - rust_begin_unwind
at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/std/src/panicking.rs:498:5
15: 0x556d16f5fd01 - core::panicking::panic_fmt::h3a79a6a99affe1d5
at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/core/src/panicking.rs:116:14
16: 0x556d16f5fdf3 - core::result::unwrap_failed::ha0327e3803285d6e
at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/core/src/result.rs:1690:5
17: 0x556d170cb3f6 - ropey::slice::RopeSlice::char_to_byte::ha86b76a66055fcaa
18: 0x556d170c720c - helix_core::graphemes::nth_prev_grapheme_boundary::h704daf53b87885f9
19: 0x556d170b9966 - helix_core::selection::Range::grapheme_aligned::h80339e72d9d0845b
20: 0x556d170bc800 - helix_core::selection::Selection::ensure_invariants::h7b4a4bfd12de95c4
21: 0x556d174e264a - helix_view::document::Document::apply_impl::ha65b43cb55bb1c55
22: 0x556d174e3136 - helix_view::document::Document::apply::hf9bf7e10d2ce8d17
23: 0x556d173cc477 - helix_term::commands::increment_impl::he979b06601b5a79f
24: 0x556d172e3d68 - helix_term::ui::editor::EditorView::handle_keymap_event::h6ca6ed20204ecc2c
25: 0x556d172e5da0 - <helix_term::ui::editor::EditorView as helix_term::compositor::Component>::handle_event::h95eda4dddaccdaa6
26: 0x556d172fc13f - helix_term::compositor::Compositor::handle_event::h6baf5e9ddc3de8e5
27: 0x556d172d4a86 - helix_term::application::Application::handle_terminal_events::h868b8f22bdea5c41
28: 0x556d17554168 - <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll::h71cc7bf01ac22b4a
29: 0x556d175213fe - tokio::park::thread::CachedParkThread::block_on::h9c4b5e136af251c7
30: 0x556d17517ef9 - tokio::runtime::thread_pool::ThreadPool::block_on::h712340e0327fa2d4
31: 0x556d17535f5c - tokio::runtime::Runtime::block_on::h23ce243dbb76cfa2
32: 0x556d1752082a - hx::main::h4257d6a18d3e40c1
33: 0x556d17522793 - std::sys_common::backtrace::__rust_begin_short_backtrace::h7c1268abc06e485c
34: 0x556d17535cfd - std::rt::lang_start::{{closure}}::h3ae220954d80377b
35: 0x556d17682bde - core::ops::function::impls::<impl core::ops::function::FnOnce<A> for &F>::call_once::h443f738a8e9f947a
at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/core/src/ops/function.rs:259:13
36: 0x556d17682bde - std::panicking::try::do_call::h1e21ba261ba489ec
at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/std/src/panicking.rs:406:40
37: 0x556d17682bde - std::panicking::try::h6afd48af8b6c96ac
at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/std/src/panicking.rs:370:19
38: 0x556d17682bde - std::panic::catch_unwind::h85dd95e0bab7fb60
at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/std/src/panic.rs:133:14
39: 0x556d17682bde - std::rt::lang_start_internal::{{closure}}::h038455e697c8b03e
at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/std/src/rt.rs:128:48
40: 0x556d17682bde - std::panicking::try::do_call::h6b0ad65979f3077a
at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/std/src/panicking.rs:406:40
41: 0x556d17682bde - std::panicking::try::h010108d314169ac6
at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/std/src/panicking.rs:370:19
42: 0x556d17682bde - std::panic::catch_unwind::hff397f912b1535c2
at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/std/src/panic.rs:133:14
43: 0x556d17682bde - std::rt::lang_start_internal::h52e73755f77c7dd9
at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/std/src/rt.rs:128:20
44: 0x556d17523e52 - main
45: 0x7f0f03671fd0 - <unknown>
46: 0x7f0f0367207d - __libc_start_main
47: 0x556d16f8ced5 - _start
48: 0x0 - <unknown>
It seems to be a problem with changing a -1 to 0 (ctrl-a is increment by one so -1 + 1 = 0) and then calculating the subsequent cursor position; it doesn't have to do anything with dates at all (the original text contained strings like 2021-07--1
and therefore ctrl-a probably didn't change by date anyway).
With this text:
-1
-1
put the cursor on the two minuses (%s-<enter>
) and hit ctrl-a
to cause the panic. Interestingly the panic doesn't happen if there is a newline after the last 1, i.e.
-1
-1
Strange. I am very much new to helix, and I'm not in a position to start looking into the code myself so I can't really help much further.
Summary
The original summary included a lot of context that isn't related. After some discussion this is what has been found.
If you have a file with the following:
And you enter the following keystrokes:
%
s
-
<enter>
C-a
Helix panics.
This doesn't happen when there is a character, space or empty line after the two lines:
(Helix doesn't panic with the above input on this text)
Here is the backtrace with RUST_BACKTRACE=1:
I also now updated the Helix version to my now current version on this issue because this bug still exists at the time of writing.
Helix log
~/.cache/helix/helix.log
``` please provide a copy of `~/.cache/helix/helix.log` here if possible, you may need to redact some of the lines [helix.log](https://github.com/helix-editor/helix/files/8451943/helix.log) ```Platform
Linux
Terminal Emulator
alacritty
Helix Version
22.03-105-gcc68fa85