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

reproducible panic in core (transaction.rs) on multicursor newline insert #12662

Open
magackame opened this issue Jan 24, 2025 · 7 comments
Open
Labels
C-bug Category: This is a bug

Comments

@magackame
Copy link
Contributor

magackame commented Jan 24, 2025

Summary

Typing in a key sequence that ends in multicursor newline insert leads to reproducible panic in core (transaction.rs) on assertion failure.

Reproduction Steps

I tried this :

  1. ./target/debug/hx
  2. Type in the key sequence
  3. Panic in core

Key sequence:

iba a a<ESC>%sa<CR>di<CR>

Insert ba a a, select everything %, select all as (s), delete (d), insert newlines (i + <CR>).

asciinema recording.

Helix log

stderr
thread 'main' panicked at /home/magackame/src/thirdparty/helix/helix-core/src/transaction.rs:618:13:
assertion failed: last <= from
stack backtrace:
   0: rust_begin_unwind
             at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/std/src/panicking.rs:645:5
   1: core::panicking::panic_fmt
             at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/core/src/panicking.rs:72:14
   2: core::panicking::panic
             at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/core/src/panicking.rs:144:5
   3: helix_core::transaction::Transaction::change
             at ./helix-core/src/transaction.rs:618:13
   4: helix_core::transaction::Transaction::change_by_selection
             at ./helix-core/src/transaction.rs:688:9
   5: helix_term::commands::insert::insert_newline
             at ./helix-term/src/commands.rs:4079:31
   6: helix_term::commands::MappableCommand::execute
             at ./helix-term/src/commands.rs:257:41
   7: helix_term::ui::editor::EditorView::handle_keymap_event::{{closure}}
             at ./helix-term/src/ui/editor.rs:893:13
   8: helix_term::ui::editor::EditorView::handle_keymap_event
             at ./helix-term/src/ui/editor.rs:919:17
   9: helix_term::ui::editor::EditorView::insert_mode
             at ./helix-term/src/ui/editor.rs:933:34
  10: <helix_term::ui::editor::EditorView as helix_term::compositor::Component>::handle_event
             at ./helix-term/src/ui/editor.rs:1466:33
  11: helix_term::compositor::Compositor::handle_event
             at ./helix-term/src/compositor.rs:152:19
  12: helix_term::application::Application::handle_terminal_events::{{closure}}
             at ./helix-term/src/application.rs:673:22
  13: helix_term::application::Application::event_loop_until_idle::{{closure}}
             at ./helix-term/src/application.rs:346:56
  14: helix_term::application::Application::event_loop::{{closure}}
             at ./helix-term/src/application.rs:320:58
  15: helix_term::application::Application::run::{{closure}}
             at ./helix-term/src/application.rs:1235:39
  16: hx::main_impl::{{closure}}
             at ./helix-term/src/main.rs:153:54
  17: <core::pin::Pin<P> as core::future::future::Future>::poll
             at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/core/src/future/future.rs:124:9
  18: tokio::runtime::park::CachedParkThread::block_on::{{closure}}
             at /home/magackame/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.43.0/src/runtime/park.rs:284:63
  19: tokio::runtime::coop::with_budget
             at /home/magackame/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.43.0/src/runtime/coop.rs:107:5
  20: tokio::runtime::coop::budget
             at /home/magackame/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.43.0/src/runtime/coop.rs:73:5
  21: tokio::runtime::park::CachedParkThread::block_on
             at /home/magackame/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.43.0/src/runtime/park.rs:284:31
  22: tokio::runtime::context::blocking::BlockingRegionGuard::block_on
             at /home/magackame/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.43.0/src/runtime/context/blocking.rs:66:9
  23: tokio::runtime::scheduler::multi_thread::MultiThread::block_on::{{closure}}
             at /home/magackame/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.43.0/src/runtime/scheduler/multi_thread/mod.rs:87:13
  24: tokio::runtime::context::runtime::enter_runtime
             at /home/magackame/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.43.0/src/runtime/context/runtime.rs:65:16
  25: tokio::runtime::scheduler::multi_thread::MultiThread::block_on
             at /home/magackame/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.43.0/src/runtime/scheduler/multi_thread/mod.rs:86:9
  26: tokio::runtime::runtime::Runtime::block_on_inner
             at /home/magackame/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.43.0/src/runtime/runtime.rs:370:45
  27: tokio::runtime::runtime::Runtime::block_on
             at /home/magackame/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.43.0/src/runtime/runtime.rs:340:13
  28: hx::main_impl
             at ./helix-term/src/main.rs:155:5
  29: hx::main
             at ./helix-term/src/main.rs:37:21
  30: core::ops::function::FnOnce::call_once
             at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/core/src/ops/function.rs:250:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

helix.log

Platform

Linux

Terminal Emulator

kitty 0.38.1 created by Kovid Goyal

Installation Method

source

Helix Version

25.01.1-39-g9088f8a5

@magackame magackame added the C-bug Category: This is a bug label Jan 24, 2025
@magackame
Copy link
Contributor Author

Ok, so I originally found this on helix 25.01.1 (e7ac2fcd) (nix package) while editing a big html string trying to replace \n with actual newlines. Then I started building from source and minifying the example until i ended up with ba a a, but ba a a doesn't cause the crash on 25.01.1 and I also somehow lost the original html and cannot reproduce it anymore. I have some similar html and while it doesn't crash on 25.01.1 (but does on 25.01.1-39-g9088f8a5) the undo of the newline insert doesn't yield back the original string (asciinema).

@TornaxO7
Copy link
Contributor

Does this maybe have something to do with #12510 ?

@magackame
Copy link
Contributor Author

magackame commented Jan 24, 2025

Bisected. 1e6fe00 is the culprit.

Also this is a debug_assert panic, that's why the packaged version doesn't panic. But I found the bug on the packaged version, so maybe this one is something separate that I just stumbled upon and there is one more issue somewhere.

@nik-rev
Copy link
Contributor

nik-rev commented Jan 24, 2025

Bisected. 1e6fe00 is the culprit.

Also this is a debug_assert panic, that's why the packaged version doesn't panic. But I found the bug on the packaged version, so maybe this one is something separate that I just stumbled upon and there is one more issue somewhere.

This issue was fixed in 25.01.1

@magackame
Copy link
Contributor Author

Bisected. 1e6fe00 is the culprit.
Also this is a debug_assert panic, that's why the packaged version doesn't panic. But I found the bug on the packaged version, so maybe this one is something separate that I just stumbled upon and there is one more issue somewhere.

This issue was fixed in 25.01.1

It does panic in 25.01.1 in debug and results in incorrect edits in release (cursors collapse when they shouldn't).

@nik-rev
Copy link
Contributor

nik-rev commented Jan 24, 2025

Bisected. 1e6fe00 is the culprit.
Also this is a debug_assert panic, that's why the packaged version doesn't panic. But I found the bug on the packaged version, so maybe this one is something separate that I just stumbled upon and there is one more issue somewhere.

This issue was fixed in 25.01.1

It does panic in 25.01.1 in debug and results in incorrect edits in release (cursors collapse when they shouldn't).

Oh alright, was thinking of a different issue

@nik-rev
Copy link
Contributor

nik-rev commented Jan 24, 2025

But what's strange is the commit you pointed out is exactly the same one that caused caused panics earlier for a bug which was fixed in 25.01.1 when you inserted newlines

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

3 participants