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

Helix crash on Ctrl-o #2489

Closed
Zoybean opened this issue May 17, 2022 · 10 comments · Fixed by #4186
Closed

Helix crash on Ctrl-o #2489

Zoybean opened this issue May 17, 2022 · 10 comments · Fixed by #4186
Labels
A-helix-term Area: Helix term improvements C-bug Category: This is a bug

Comments

@Zoybean
Copy link
Contributor

Zoybean commented May 17, 2022

Summary

When pressing ctrl-o after deleting selection contents, helix crashes.

thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Char index out of bounds: char index 1794223, Rope/RopeSlice char length 1776214', C:\Users\runneradmin\.cargo\registry\src\github.com-1ecc6299db9ec823\ropey-1.4.1\src\slice.rs:349:41
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Reproduction Steps

I tried this:

  1. select the whole file
  2. select some subset of the file, and delete that subset
  3. press ctrl-o

I expected this to happen:

  • Either an error message, or the previously selected region of the file is reselected

Instead, this happened:

  • helix crashed

Helix log

No log available

Platform

Windows 10

Terminal Emulator

ConEmu 160914 [64] {Stable}

Helix Version

helix 22.03 (d4e45fd)

@Zoybean Zoybean added the C-bug Category: This is a bug label May 17, 2022
@pickfire
Copy link
Contributor

pickfire commented May 17, 2022

I noticed it too but I don't have exact step to reproduce, basically I just press ctrl-o many times (across different files and edits) when editing halfway then it crashed.

@the-mikedavis the-mikedavis added the A-helix-term Area: Helix term improvements label May 17, 2022
@the-mikedavis
Copy link
Member

There was a similar panic fixed in #1397 around jumping to a buffer that was closed with :buffer-close (#2107). For this one

Char index out of bounds: char index 1794223, Rope/RopeSlice char length 1776214

we might be able to reproduce by saving to the jumplist at the end of a file and then shortening the file by deleting some lines and jumping backwards.

@archseer
Copy link
Member

This indeed looks like #2107 so it should be addressed on latest master (but not 22.03).

@pickfire
Copy link
Contributor

pickfire commented May 18, 2022

This indeed looks like #2107 so it should be addressed on latest master (but not 22.03).

I just faced it last week on latest master, but the issue I faced with ctrl-o could be a different issue.

@David-Else
Copy link
Contributor

I just had this on pressing ctrl-o:

thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Char index out of bounds: char index 4081, Rope/RopeSlice char length 4079', /home/david/.cargo/registry/src/github.com-1ecc6299db9ec823/ropey-1.5.0/src/slice.rs:349:41
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

helix 22.08.1 (038ad62)

@softmoth
Copy link
Contributor

softmoth commented Oct 10, 2022

I was able to repeat this on master (9b7f349). Here is a backtrace:

RUST_BACKTRACE=1 ./target/debug/hx README.md
  87 oin·`#helix-editor:matrix.org`·if·you're·on·a·client·that·doesn't·support·Matrix·Spaces·yet).thread 'main' panicked at 'assertion failed: char_idx <= slice.len_chars()', helix-core/src/graphemes.rs:37:5
stack backtrace:
 0: rust_begin_unwind
           at /rustc/c2804e6ec2c29a5c7368600ea173b890e2655c3d/library/std/src/panicking.rs:584:5
 1: core::panicking::panic_fmt
           at /rustc/c2804e6ec2c29a5c7368600ea173b890e2655c3d/library/core/src/panicking.rs:142:14
 2: core::panicking::panic
           at /rustc/c2804e6ec2c29a5c7368600ea173b890e2655c3d/library/core/src/panicking.rs:48:5
 3: helix_core::graphemes::nth_prev_grapheme_boundary
           at ./helix-core/src/graphemes.rs:37:5
 4: helix_core::graphemes::prev_grapheme_boundary
           at ./helix-core/src/graphemes.rs:79:5
 5: helix_core::graphemes::ensure_grapheme_boundary_prev
           at ./helix-core/src/graphemes.rs:194:9
 6: helix_core::selection::Range::grapheme_aligned
           at ./helix-core/src/selection.rs:271:17
 7: helix_core::selection::Selection::ensure_invariants::{{closure}}
           at ./helix-core/src/selection.rs:561:28
 8: helix_core::selection::Selection::transform
           at ./helix-core/src/selection.rs:549:22
 9: helix_core::selection::Selection::ensure_invariants
           at ./helix-core/src/selection.rs:561:9
10: helix_view::document::Document::set_selection                                         1 sel  87:210
           at ./helix-view/src/document.rs:704:30
11: helix_term::commands::jump_forward
           at ./helix-term/src/commands.rs:4116:9
12: helix_term::commands::MappableCommand::execute
           at ./helix-term/src/commands.rs:177:41
13: helix_term::ui::editor::EditorView::handle_keymap_event::{{closure}}
           at ./helix-term/src/ui/editor.rs:899:13
14: helix_term::ui::editor::EditorView::handle_keymap_event
           at ./helix-term/src/ui/editor.rs:932:17
15: helix_term::ui::editor::EditorView::command_mode
           at ./helix-term/src/ui/editor.rs:1024:17
16: <helix_term::ui::editor::EditorView as helix_term::compositor::Component>::handle_event
           at ./helix-term/src/ui/editor.rs:1367:33
17: helix_term::compositor::Compositor::handle_event
           at ./helix-term/src/compositor.rs:172:19
18: helix_term::application::Application::handle_terminal_events
           at ./helix-term/src/application.rs:467:22
19: helix_term::application::Application::event_loop_until_idle::{{closure}}
           at ./helix-term/src/application.rs:292:21
20: <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll
           at /rustc/c2804e6ec2c29a5c7368600ea173b890e2655c3d/library/core/src/future/mod.rs:91:19
21: helix_term::application::Application::event_loop::{{closure}}
           at ./helix-term/src/application.rs:268:57
22: <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll
           at /rustc/c2804e6ec2c29a5c7368600ea173b890e2655c3d/library/core/src/future/mod.rs:91:19
23: helix_term::application::Application::run::{{closure}}
           at ./helix-term/src/application.rs:872:38
24: <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll
           at /rustc/c2804e6ec2c29a5c7368600ea173b890e2655c3d/library/core/src/future/mod.rs:91:19
25: hx::main_impl::{{closure}}
           at ./helix-term/src/main.rs:145:53
26: <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll
           at /rustc/c2804e6ec2c29a5c7368600ea173b890e2655c3d/library/core/src/future/mod.rs:91:19
27: tokio::park::thread::CachedParkThread::block_on::{{closure}}
           at /home/trs/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.21.2/src/park/thread.rs:267:54
28: tokio::coop::with_budget::{{closure}}
           at /home/trs/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.21.2/src/coop.rs:102:9
29: std::thread::local::LocalKey<T>::try_with
           at /rustc/c2804e6ec2c29a5c7368600ea173b890e2655c3d/library/std/src/thread/local.rs:445:16
30: std::thread::local::LocalKey<T>::with
           at /rustc/c2804e6ec2c29a5c7368600ea173b890e2655c3d/library/std/src/thread/local.rs:421:9
31: tokio::coop::with_budget
           at /home/trs/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.21.2/src/coop.rs:95:5
32: tokio::coop::budget
           at /home/trs/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.21.2/src/coop.rs:72:5
33: tokio::park::thread::CachedParkThread::block_on
           at /home/trs/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.21.2/src/park/thread.rs:267:31
34: tokio::runtime::enter::Enter::block_on
           at /home/trs/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.21.2/src/runtime/enter.rs:152:13
35: tokio::runtime::scheduler::multi_thread::MultiThread::block_on
           at /home/trs/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.21.2/src/runtime/scheduler/multi_thread/mod.rs:79:9
36: tokio::runtime::Runtime::block_on
           at /home/trs/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.21.2/src/runtime/mod.rs:492:44
37: hx::main_impl
           at ./helix-term/src/main.rs:147:5
38: hx::main
           at ./helix-term/src/main.rs:37:21
39: core::ops::function::FnOnce::call_once
           at /rustc/c2804e6ec2c29a5c7368600ea173b890e2655c3d/library/core/src/ops/function.rs:248:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

I typed %s\n<Enter>c THE END<Enter> and then hit C-o and C-i several times. I can't seem to repeat it consistently, though.

@jtrees
Copy link

jtrees commented Oct 12, 2022

Thanks so much for fixing this. Any chance we could get a bugfix release with the changes?

@zuixalias
Copy link

thread 'main' panicked at 'called 'Result::unwrap()' on an 'Err' value: Char index out of bounds: char index 14025, Rope/RopeSlice char length 14014', C:\Users\runneradmin\.cargo\registry\src\github.com-1ecc6299db9ec823\ropey-1.5.1-alpha\src\slice.rs:360:41

I have encountered this or a similar crash multiple time across multiple helix versions.
I was editing and got it again, not sure what the trigger was though.

Helix Version: helix 22.12 (96ff64a8)

@pascalkuthe
Copy link
Member

thread 'main' panicked at 'called 'Result::unwrap()' on an 'Err' value: Char index out of bounds: char index 14025, Rope/RopeSlice char length 14014', C:\Users\runneradmin\.cargo\registry\src\github.com-1ecc6299db9ec823\ropey-1.5.1-alpha\src\slice.rs:360:41

I have encountered this or a similar crash multiple time across multiple helix versions. I was editing and got it again, not sure what the trigger was though.

Helix Version: helix 22.12 (96ff64a8)

I have not encountered this ever since it was fixed. The ubderlying problem was definitly fixed. If you can provide a reproduction case or a backtrace (ideally both) with the new version open a new issues

@zuixalias
Copy link

zuixalias commented Jan 28, 2023

Okay, will keep that in mind.
(btw the key bind that triggered it was most probably not the one mentioned in the title of this issue...also, i think it was in Insert mode)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-helix-term Area: Helix term improvements C-bug Category: This is a bug
Projects
None yet
9 participants