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

panicked after adding cursor on EOL #2981

Closed
ghost opened this issue Jul 6, 2022 · 5 comments
Closed

panicked after adding cursor on EOL #2981

ghost opened this issue Jul 6, 2022 · 5 comments
Labels
A-helix-term Area: Helix term improvements C-bug Category: This is a bug

Comments

@ghost
Copy link

ghost commented Jul 6, 2022

Summary

Create a blank page, remove the newline, and leave only the EOL.
Then adding a new cursor causes an error.
Not an error in Helix, but I opened it to check.

thread 'main' panicked at 'called Result::unwrap() on an Err value: Char index out of bounds: char index 18446744073709551615, Rope/RopeSlice char length 0'

Reproduction Steps

I tried this:

  1. hx
    make a blank page
  2. d
    Remove newline using d
  3. C(Shift-c) or Alt-C(Alt-Shift-C)
    add new cursor then crashes

Helix log

helix_loader [DEBUG] Located configuration folders: []

Platform

windows10

Terminal Emulator

windows terminal

Helix Version

helix 22.05 (c88d736)

@ghost ghost added the C-bug Category: This is a bug label Jul 6, 2022
@kirawi kirawi added the A-helix-term Area: Helix term improvements label Jul 6, 2022
@the-mikedavis
Copy link
Member

Can you provide a full backtrace by setting the RUST_BACKTRACE environment variable to full? I can't reproduce this on linux even when the line-endings are set to crlf

@ghost
Copy link
Author

ghost commented Jul 6, 2022

thread 'main' panicked at 'attempt to subtract with overflow', helix-term\src\commands.rs:1417:26
stack backtrace:
   0:     0x7ff7ad07104f - std::backtrace_rs::backtrace::dbghelp::trace
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e\/library\std\src\..\..\backtrace\src\backtrace\dbghelp.rs:98
   1:     0x7ff7ad07104f - std::backtrace_rs::backtrace::trace_unsynchronized
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e\/library\std\src\..\..\backtrace\src\backtrace\mod.rs:66
   2:     0x7ff7ad07104f - std::sys_common::backtrace::_print_fmt
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e\/library\std\src\sys_common\backtrace.rs:66
   3:     0x7ff7ad07104f - std::sys_common::backtrace::_print::impl$0::fmt
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e\/library\std\src\sys_common\backtrace.rs:45
   4:     0x7ff7ad0929fa - core::fmt::write
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e\/library\core\src\fmt\mod.rs:1194
   5:     0x7ff7ad068db9 - std::io::Write::write_fmt<std::sys::windows::stdio::Stderr>
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e\/library\std\src\io\mod.rs:1655
   6:     0x7ff7ad073cab - std::sys_common::backtrace::_print
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e\/library\std\src\sys_common\backtrace.rs:48
   7:     0x7ff7ad073cab - std::sys_common::backtrace::print
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e\/library\std\src\sys_common\backtrace.rs:35
   8:     0x7ff7ad073cab - std::panicking::default_hook::closure$1
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e\/library\std\src\panicking.rs:295
   9:     0x7ff7ad07389e - std::panicking::default_hook
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e\/library\std\src\panicking.rs:314
  10:     0x7ff7abcc85d3 - alloc::boxed::impl$46::call<tuple$<ref$<core::panic::panic_info::PanicInfo> >,dyn$<core::ops::function::Fn<tuple$<ref$<core::panic::panic_info::PanicInfo> >,assoc$<Output,tuple$<> > >,core::marker::Send,core::marker::Sync>,alloc::alloc::Global>
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e\library\alloc\src\boxed.rs:1875
  11:     0x7ff7abce0438 - helix_term::application::impl$0::run::async_fn$0::closure$0<crossterm::event::stream::EventStream>
                               at C:\Users\username\Desktop\helix\helix-term\src\application.rs:821
  12:     0x7ff7ad07440a - std::panicking::rust_panic_with_hook
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e\/library\std\src\panicking.rs:702
  13:     0x7ff7ad074122 - std::panicking::begin_panic_handler::closure$0
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e\/library\std\src\panicking.rs:586
  14:     0x7ff7ad071957 - std::sys_common::backtrace::__rust_end_short_backtrace<std::panicking::begin_panic_handler::closure_env$0,never$>
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e\/library\std\src\sys_common\backtrace.rs:138
  15:     0x7ff7ad073e39 - std::panicking::begin_panic_handler
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e\/library\std\src\panicking.rs:584
  16:     0x7ff7ad0c3ef5 - core::panicking::panic_fmt
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e\/library\core\src\panicking.rs:143
  17:     0x7ff7ad0c3d9c - core::panicking::panic
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e\/library\core\src\panicking.rs:48
  18:     0x7ff7ac1525e1 - helix_term::commands::copy_selection_on_line
                               at C:\Users\username\Desktop\helix\helix-term\src\commands.rs:1417
  19:     0x7ff7ac152e7a - helix_term::commands::copy_selection_on_next_line
                               at C:\Users\username\Desktop\helix\helix-term\src\commands.rs:1482
  20:     0x7ff7ac14d619 - enum$<helix_term::commands::MappableCommand>::execute
                               at C:\Users\username\Desktop\helix\helix-term\src\commands.rs:176
  21:     0x7ff7abeebf4d - helix_term::ui::editor::EditorView::handle_keymap_event
                               at C:\Users\username\Desktop\helix\helix-term\src\ui\editor.rs:899
  22:     0x7ff7abeec786 - helix_term::ui::editor::EditorView::command_mode
                               at C:\Users\username\Desktop\helix\helix-term\src\ui\editor.rs:990
  23:     0x7ff7abeeeec0 - helix_term::ui::editor::impl$3::handle_event
                               at C:\Users\username\Desktop\helix\helix-term\src\ui\editor.rs:1317
  24:     0x7ff7abee5da5 - helix_term::compositor::Compositor::handle_event
                               at C:\Users\username\Desktop\helix\helix-term\src\compositor.rs:165
  25:     0x7ff7abee3bcc - helix_term::application::Application::handle_terminal_events
                               at C:\Users\username\Desktop\helix\helix-term\src\application.rs:437
  26:     0x7ff7abcd9b17 - helix_term::application::impl$0::event_loop_until_idle::async_fn$0<crossterm::event::stream::EventStream>
                               at C:\Users\username\Desktop\helix\helix-term\src\application.rs:275
  27:     0x7ff7abcf4a79 - core::future::from_generator::impl$1::poll<enum$<helix_term::application::impl$0::event_loop_until_idle::async_fn_env$0<crossterm::event::stream::EventStream> > >
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e\library\core\src\future\mod.rs:91
  28:     0x7ff7abcd898b - helix_term::application::impl$0::event_loop::async_fn$0<crossterm::event::stream::EventStream>
                               at C:\Users\username\Desktop\helix\helix-term\src\application.rs:251
  29:     0x7ff7abcf5429 - core::future::from_generator::impl$1::poll<enum$<helix_term::application::impl$0::event_loop::async_fn_env$0<crossterm::event::stream::EventStream> > >
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e\library\core\src\future\mod.rs:91
  30:     0x7ff7abcdff0c - helix_term::application::impl$0::run::async_fn$0<crossterm::event::stream::EventStream>
                               at C:\Users\username\Desktop\helix\helix-term\src\application.rs:824
  31:     0x7ff7abcf4891 - core::future::from_generator::impl$1::poll<enum$<helix_term::application::impl$0::run::async_fn_env$0<crossterm::event::stream::EventStream> > >
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e\library\core\src\future\mod.rs:91
  32:     0x7ff7abceee17 - hx::main_impl::async_block$0
                               at C:\Users\username\Desktop\helix\helix-term\src\main.rs:140
  33:     0x7ff7abcf4d61 - core::future::from_generator::impl$1::poll<enum$<hx::main_impl::async_block_env$0> >
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e\library\core\src\future\mod.rs:91
  34:     0x7ff7abccfc16 - tokio::park::thread::impl$5::block_on::closure$0<core::future::from_generator::GenFuture<enum$<hx::main_impl::async_block_env$0> > >
                               at C:\Users\username\.cargo\registry\src\github.com-1ecc6299db9ec823\tokio-1.19.2\src\park\thread.rs:263
  35:     0x7ff7abcb3358 - tokio::coop::with_budget::closure$0<enum$<core::task::poll::Poll<enum$<core::result::Result<i32,anyhow::Error> > >, 0, 1, Ready>,tokio::park::thread::impl$5::block_on::closure_env$0<core::future::from_generator::GenFuture<enum$<hx::main_impl::async_block_
                               at C:\Users\username\.cargo\registry\src\github.com-1ecc6299db9ec823\tokio-1.19.2\src\coop.rs:102
  36:     0x7ff7abcd7d6a - std::thread::local::LocalKey<core::cell::Cell<tokio::coop::Budget> >::try_with<core::cell::Cell<tokio::coop::Budget>,tokio::coop::with_budget::closure_env$0<enum$<core::task::poll::Poll<enum$<core::result::Result<i32,anyhow::Error> > >, 0, 1, Ready>,tokio
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e\library\std\src\thread\local.rs:442
  37:     0x7ff7abcd780c - std::thread::local::LocalKey<core::cell::Cell<tokio::coop::Budget> >::with<core::cell::Cell<tokio::coop::Budget>,tokio::coop::with_budget::closure_env$0<enum$<core::task::poll::Poll<enum$<core::result::Result<i32,anyhow::Error> > >, 0, 1, Ready>,tokio::pa
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e\library\std\src\thread\local.rs:418
  38:     0x7ff7abccf5a5 - tokio::coop::with_budget
                               at C:\Users\username\.cargo\registry\src\github.com-1ecc6299db9ec823\tokio-1.19.2\src\coop.rs:95
  39:     0x7ff7abccf5a5 - tokio::coop::budget
                               at C:\Users\username\.cargo\registry\src\github.com-1ecc6299db9ec823\tokio-1.19.2\src\coop.rs:72
  40:     0x7ff7abccf5a5 - tokio::park::thread::CachedParkThread::block_on<core::future::from_generator::GenFuture<enum$<hx::main_impl::async_block_env$0> > >
                               at C:\Users\username\.cargo\registry\src\github.com-1ecc6299db9ec823\tokio-1.19.2\src\park\thread.rs:263
  41:     0x7ff7abcfae27 - tokio::runtime::enter::Enter::block_on<core::future::from_generator::GenFuture<enum$<hx::main_impl::async_block_env$0> > >
                               at C:\Users\username\.cargo\registry\src\github.com-1ecc6299db9ec823\tokio-1.19.2\src\runtime\enter.rs:151
  42:     0x7ff7abcd57b9 - tokio::runtime::thread_pool::ThreadPool::block_on<core::future::from_generator::GenFuture<enum$<hx::main_impl::async_block_env$0> > >
                               at C:\Users\username\.cargo\registry\src\github.com-1ecc6299db9ec823\tokio-1.19.2\src\runtime\thread_pool\mod.rs:90
  43:     0x7ff7abcabc91 - tokio::runtime::Runtime::block_on<core::future::from_generator::GenFuture<enum$<hx::main_impl::async_block_env$0> > >
                               at C:\Users\username\.cargo\registry\src\github.com-1ecc6299db9ec823\tokio-1.19.2\src\runtime\mod.rs:482
  44:     0x7ff7abcc19b9 - hx::main_impl
                               at C:\Users\username\Desktop\helix\helix-term\src\main.rs:142
  45:     0x7ff7abcc186e - hx::main
                               at C:\Users\username\Desktop\helix\helix-term\src\main.rs:37
  46:     0x7ff7abce906b - core::ops::function::FnOnce::call_once<enum$<core::result::Result<tuple$<>,anyhow::Error>, 1, 18446744073709551615, Err> (*)(),tuple$<> >
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e\library\core\src\ops\function.rs:227
  47:     0x7ff7abce15cb - std::sys_common::backtrace::__rust_begin_short_backtrace<enum$<core::result::Result<tuple$<>,anyhow::Error>, 1, 18446744073709551615, Err> (*)(),enum$<core::result::Result<tuple$<>,anyhow::Error>, 1, 18446744073709551615, Err> >
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e\library\std\src\sys_common\backtrace.rs:122
  48:     0x7ff7abcac441 - std::rt::lang_start::closure$0<enum$<core::result::Result<tuple$<>,anyhow::Error>, 1, 18446744073709551615, Err> >
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e\library\std\src\rt.rs:145
  49:     0x7ff7ad06101e - core::ops::function::impls::impl$2::call_once
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e\library\core\src\ops\function.rs:259
  50:     0x7ff7ad06101e - std::panicking::try::do_call
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e\/library\std\src\panicking.rs:492
  51:     0x7ff7ad06101e - std::panicking::try
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e\/library\std\src\panicking.rs:456
  52:     0x7ff7ad06101e - std::panic::catch_unwind
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e\/library\std\src\panic.rs:137
  53:     0x7ff7ad06101e - std::rt::lang_start_internal::closure$2
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e\/library\std\src\rt.rs:128
  54:     0x7ff7ad06101e - std::panicking::try::do_call
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e\/library\std\src\panicking.rs:492
  55:     0x7ff7ad06101e - std::panicking::try
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e\/library\std\src\panicking.rs:456
  56:     0x7ff7ad06101e - std::panic::catch_unwind
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e\/library\std\src\panic.rs:137
  57:     0x7ff7ad06101e - std::rt::lang_start_internal
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e\/library\std\src\rt.rs:128
  58:     0x7ff7abcac40f - std::rt::lang_start<enum$<core::result::Result<tuple$<>,anyhow::Error>, 1, 18446744073709551615, Err> >
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e\library\std\src\rt.rs:144
  59:     0x7ff7abcc1ae6 - main
  60:     0x7ff7ad0c1c1c - invoke_main
                               at D:\a\_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:78
  61:     0x7ff7ad0c1c1c - __scrt_common_main_seh
                               at D:\a\_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:288
  62:     0x7ffb6fa57034 - BaseThreadInitThunk
  63:     0x7ffb71162651 - RtlUserThreadStart
error: process didn't exit successfully: `target\debug\hx.exe` (exit code: 101)

@ghost
Copy link
Author

ghost commented Jul 6, 2022

I tried to reproduce it on another pc(win, linux), but could not.
I think it is either a problem with my environment or it is happening only with this version.

@ghost ghost changed the title Crashes after adding cursor on EOL pnicked after adding cursor on EOL Jul 6, 2022
@the-mikedavis the-mikedavis changed the title pnicked after adding cursor on EOL panicked after adding cursor on EOL Jul 6, 2022
@the-mikedavis
Copy link
Member

Oh actually I can reproduce this, I was not on a recent enough commit 😅

It was introduced in #2945, specifically the subtraction in this line:

(range.head, range.anchor - 1)

@the-mikedavis
Copy link
Member

Fixed by #3024

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
Development

No branches or pull requests

2 participants