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

Adding a jumplist entry when exiting insert mode causes a crash #10297

Closed
SecretPocketCat opened this issue Apr 8, 2024 · 1 comment
Closed
Labels
C-bug Category: This is a bug

Comments

@SecretPocketCat
Copy link

SecretPocketCat commented Apr 8, 2024

Summary

Setting bind to add a jumplist entry causes a panic when exiting insert mode after adding new text to a buffer.

This is possibly the same as #9830

Reproduction Steps

  1. create the following config
# repro_config.toml
[keys.insert]
esc = ["normal_mode", "save_selection"]
  1. hx -c 'repro_config.toml'
  2. i to enter insert mode
  3. type a (typing anything should do actuall)
  4. ESC to exit back to normal mode
  5. panic

I expected this to happen:
Helix enters normal mode and a jumplist entry is added.

Instead, this happened:
Helix crashes with the following panic

thread 'main' panicked at 'Positions [(2, Before)] are out of range for changeset len 1!', helix-core/src/transaction.rs:478:9
stack backtrace:
   0:     0x593afdfd94ad - std::backtrace_rs::backtrace::libunwind::trace::h9a6b80bbf328ba5d
                               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
   1:     0x593afdfd94ad - std::backtrace_rs::backtrace::trace_unsynchronized::hd162ec543a11886b
                               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x593afdfd94ad - std::sys_common::backtrace::_print_fmt::h78a5099be12f51a6
                               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/sys_common/backtrace.rs:65:5
   3:     0x593afdfd94ad - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::ha1c5390454d74f71
                               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x593afd38d02f - core::fmt::write::h9ffde816c577717b
                               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/core/src/fmt/mod.rs:1254:17
   5:     0x593afdfd5425 - std::io::Write::write_fmt::h88186074961638e4
                               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/io/mod.rs:1698:15
   6:     0x593afdfd9285 - std::sys_common::backtrace::_print::h184198273ed08d59
                               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/sys_common/backtrace.rs:47:5
   7:     0x593afdfd9285 - std::sys_common::backtrace::print::h1b4d8e7add699453
                               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/sys_common/backtrace.rs:34:9
   8:     0x593afdfdaf9e - std::panicking::default_hook::{{closure}}::h393bcea75423915a
                               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/panicking.rs:269:22
   9:     0x593afdfdad7e - std::panicking::default_hook::h48c64f31d8b3fd03
                               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/panicking.rs:288:9
  10:     0x593afdfdb5df - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::hb9b860f5a1175bda
                               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/alloc/src/boxed.rs:1987:9
  11:     0x593afdfdb5df - std::panicking::rust_panic_with_hook::hafdc493a79370062
                               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/panicking.rs:695:13
  12:     0x593afdfdb376 - std::panicking::begin_panic_handler::{{closure}}::h0a64bc82e36bedc7
                               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/panicking.rs:582:13
  13:     0x593afdfd98c6 - std::sys_common::backtrace::__rust_end_short_backtrace::hc203444fb7416a16
                               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/sys_common/backtrace.rs:150:18
  14:     0x593afdfdb112 - rust_begin_unwind
                               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/panicking.rs:578:5
  15:     0x593afd2a7653 - core::panicking::panic_fmt::h0f6ef0178afce4f2
                               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/core/src/panicking.rs:67:14
  16:     0x593afd5ab159 - helix_core::transaction::ChangeSet::update_positions::hc5afec3751352716
  17:     0x593afd5d88e9 - helix_core::selection::Selection::map_no_normalize::h7221bc46378c7586
  18:     0x593afdccadb5 - helix_view::view::View::apply::hbe1eb32d45314f63
  19:     0x593afdd202cf - helix_view::document::Document::append_changes_to_history::h24725984e0699cfd
  20:     0x593afd8b0672 - <helix_term::ui::editor::EditorView as helix_term::compositor::Component>::handle_event::h0f87bd65e7731248
  21:     0x593afd87b509 - helix_term::compositor::Compositor::handle_event::h84cf5e64664ee5f6
  22:     0x593afddd0cff - helix_term::application::Application::run::{{closure}}::h5eeb128298ff9ffb
  23:     0x593afdde774d - tokio::runtime::park::CachedParkThread::block_on::hdc9f9418becc4738
  24:     0x593afdd7b299 - tokio::runtime::context::runtime::enter_runtime::he26bedc0138b8147
  25:     0x593afdd65441 - tokio::runtime::runtime::Runtime::block_on::hd2b45e867e5b7e88
  26:     0x593afdd8e5c3 - hx::main::h29d333e114c37fea
  27:     0x593afdddb6a3 - std::sys_common::backtrace::__rust_begin_short_backtrace::h1fad9168d2d5094a
  28:     0x593afddb348d - std::rt::lang_start::{{closure}}::h734309045634deee
  29:     0x593afdfcd355 - core::ops::function::impls::<impl core::ops::function::FnOnce<A> for &F>::call_once::hb1327dc2ef3fecdf
                               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/core/src/ops/function.rs:287:13
  30:     0x593afdfcd355 - std::panicking::try::do_call::h4044173225fe83dd
                               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/panicking.rs:485:40
  31:     0x593afdfcd355 - std::panicking::try::hd8a722c09d156a53
                               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/panicking.rs:449:19
  32:     0x593afdfcd355 - std::panic::catch_unwind::hd2ca07971cf0119b
                               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/panic.rs:140:14
  33:     0x593afdfcd355 - std::rt::lang_start_internal::{{closure}}::h26d89d595cf47b70
                               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/rt.rs:148:48
  34:     0x593afdfcd355 - std::panicking::try::do_call::hf47aa1aa005e5f1a
                               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/panicking.rs:485:40
  35:     0x593afdfcd355 - std::panicking::try::h73d246b2423eaf4e
                               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/panicking.rs:449:19
  36:     0x593afdfcd355 - std::panic::catch_unwind::hbaaeae8f1b2f9915
                               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/panic.rs:140:14
  37:     0x593afdfcd355 - std::rt::lang_start_internal::h76f3e81e6b8f13f9
                               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/rt.rs:148:20
  38:     0x593afdd8e6b5 - main
  39:     0x73f6983abcd0 - <unknown>
  40:     0x73f6983abd8a - __libc_start_main
  41:     0x593afd30fb35 - _start
  42:                0x0 - <unknown>

Helix log

~/.cache/helix/helix.log
2024-04-08T12:55:58.480 globset [DEBUG] glob converted to regex: Glob { glob: "*/Dockerfile.*", re: "(?-u)^.*/Dockerfile\\..*$", opts: GlobOptions { case_insensitive: false, literal_separator: false, backslash_escape: true, empty_alternates: false }, tokens: Tokens([ZeroOrMore, Literal('/'), Literal('D'), Literal('o'), Literal('c'), Literal('k'), Literal('e'), Literal('r'), Literal('f'), Literal('i'), Literal('l'), Literal('e'), Literal('.'), ZeroOrMore]) }
2024-04-08T12:55:58.480 globset [DEBUG] glob converted to regex: Glob { glob: "*/dockerfile.*", re: "(?-u)^.*/dockerfile\\..*$", opts: GlobOptions { case_insensitive: false, literal_separator: false, backslash_escape: true, empty_alternates: false }, tokens: Tokens([ZeroOrMore, Literal('/'), Literal('d'), Literal('o'), Literal('c'), Literal('k'), Literal('e'), Literal('r'), Literal('f'), Literal('i'), Literal('l'), Literal('e'), Literal('.'), ZeroOrMore]) }
2024-04-08T12:55:58.480 globset [DEBUG] glob converted to regex: Glob { glob: "*/Containerfile.*", re: "(?-u)^.*/Containerfile\\..*$", opts: GlobOptions { case_insensitive: false, literal_separator: false, backslash_escape: true, empty_alternates: false }, tokens: Tokens([ZeroOrMore, Literal('/'), Literal('C'), Literal('o'), Literal('n'), Literal('t'), Literal('a'), Literal('i'), Literal('n'), Literal('e'), Literal('r'), Literal('f'), Literal('i'), Literal('l'), Literal('e'), Literal('.'), ZeroOrMore]) }
2024-04-08T12:55:58.480 globset [DEBUG] glob converted to regex: Glob { glob: "*/containerfile.*", re: "(?-u)^.*/containerfile\\..*$", opts: GlobOptions { case_insensitive: false, literal_separator: false, backslash_escape: true, empty_alternates: false }, tokens: Tokens([ZeroOrMore, Literal('/'), Literal('c'), Literal('o'), Literal('n'), Literal('t'), Literal('a'), Literal('i'), Literal('n'), Literal('e'), Literal('r'), Literal('f'), Literal('i'), Literal('l'), Literal('e'), Literal('.'), ZeroOrMore]) }
2024-04-08T12:55:58.480 globset [DEBUG] glob converted to regex: Glob { glob: "*/BUILD.*", re: "(?-u)^.*/BUILD\\..*$", opts: GlobOptions { case_insensitive: false, literal_separator: false, backslash_escape: true, empty_alternates: false }, tokens: Tokens([ZeroOrMore, Literal('/'), Literal('B'), Literal('U'), Literal('I'), Literal('L'), Literal('D'), Literal('.'), ZeroOrMore]) }
2024-04-08T12:55:58.480 globset [DEBUG] glob converted to regex: Glob { glob: "*/.env.*", re: "(?-u)^.*/\\.env\\..*$", opts: GlobOptions { case_insensitive: false, literal_separator: false, backslash_escape: true, empty_alternates: false }, tokens: Tokens([ZeroOrMore, Literal('/'), Literal('.'), Literal('e'), Literal('n'), Literal('v'), Literal('.'), ZeroOrMore]) }
2024-04-08T12:55:58.480 globset [DEBUG] glob converted to regex: Glob { glob: "*/.envrc.*", re: "(?-u)^.*/\\.envrc\\..*$", opts: GlobOptions { case_insensitive: false, literal_separator: false, backslash_escape: true, empty_alternates: false }, tokens: Tokens([ZeroOrMore, Literal('/'), Literal('.'), Literal('e'), Literal('n'), Literal('v'), Literal('r'), Literal('c'), Literal('.'), ZeroOrMore]) }
2024-04-08T12:55:58.480 globset [DEBUG] glob converted to regex: Glob { glob: "*/Jenkinsfile.*", re: "(?-u)^.*/Jenkinsfile\\..*$", opts: GlobOptions { case_insensitive: false, literal_separator: false, backslash_escape: true, empty_alternates: false }, tokens: Tokens([ZeroOrMore, Literal('/'), Literal('J'), Literal('e'), Literal('n'), Literal('k'), Literal('i'), Literal('n'), Literal('s'), Literal('f'), Literal('i'), Literal('l'), Literal('e'), Literal('.'), ZeroOrMore]) }
2024-04-08T12:55:58.480 globset [DEBUG] built glob set; 1 literals, 0 basenames, 0 extensions, 0 prefixes, 121 suffixes, 5 required extensions, 8 regexes
2024-04-08T12:55:58.481 helix_view::clipboard [DEBUG] Using wl-copy+wl-paste to interact with the system and selection (primary) clipboard
2024-04-08T12:55:58.481 helix_tui::backend::crossterm [DEBUG] The keyboard enhancement protocol is supported in this terminal (checked in 37.05µs)
2024-04-08T12:55:58.481 helix_view::document [DEBUG] id 1 modified - last saved: 0, current: 0
2024-04-08T12:55:58.732 helix_term::application [DEBUG] received editor event: IdleTimer
2024-04-08T12:55:59.287 helix_view::document [DEBUG] id 1 modified - last saved: 0, current: 0
2024-04-08T12:55:59.408 helix_view::document [DEBUG] id 1 modified - last saved: 0, current: 0
2024-04-08T12:55:59.539 helix_view::document [DEBUG] id 1 modified - last saved: 0, current: 0
2024-04-08T12:55:59.539 helix_term::application [DEBUG] received editor event: IdleTimer
2024-04-08T12:55:59.584 helix_view::document [DEBUG] id 1 modified - last saved: 0, current: 0
2024-04-08T12:55:59.706 helix_view::document [DEBUG] id 1 modified - last saved: 0, current: 0
2024-04-08T12:55:59.836 helix_view::document [DEBUG] id 1 modified - last saved: 0, current: 0
2024-04-08T12:55:59.836 helix_term::application [DEBUG] received editor event: IdleTimer
2024-04-08T12:56:00.088 helix_view::editor [DEBUG] editor status: Selection saved to jumplist

Platform

Linux (Arch)

Terminal Emulator

foot (version: 1.16.2)

Installation Method

built from source

Helix Version

24.03-12-g6a214af1

@SecretPocketCat SecretPocketCat added the C-bug Category: This is a bug label Apr 8, 2024
@pascalkuthe
Copy link
Member

Duplicate of #3501

@pascalkuthe pascalkuthe closed this as not planned Won't fix, can't repro, duplicate, stale Apr 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug
Projects
None yet
Development

No branches or pull requests

2 participants