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

Positions are out of range for changeset length #12582

Open
joelreymont opened this issue Jan 18, 2025 · 25 comments
Open

Positions are out of range for changeset length #12582

joelreymont opened this issue Jan 18, 2025 · 25 comments
Labels
C-bug Category: This is a bug

Comments

@joelreymont
Copy link

Summary

I press a key and then

thread 'main' panicked at helix-core/src/transaction.rs:483:9:
Positions [(56567, After), (56570, Before)] are out of range for changeset len 12513!
stack backtrace:
   0: _rust_begin_unwind
   1: core::panicking::panic_fmt
   2: helix_core::transaction::ChangeSet::update_positions
   3: helix_view::view::View::apply
   4: helix_view::document::Document::append_changes_to_history
   5: <helix_term::ui::editor::EditorView as helix_term::compositor::Component>::handle_event
   6: helix_term::compositor::Compositor::handle_event
   7: helix_term::application::Application::run::{{closure}}
   8: tokio::runtime::park::CachedParkThread::block_on
   9: tokio::runtime::context::runtime::enter_runtime
  10: tokio::runtime::runtime::Runtime::block_on
  11: hx::main

Reproduction Steps

I cannot reproduce this, unfortunately.

It has happened to me several times already, causing me to lose my unsaved changed.

Helix log

Nothing with today's date.

Platform

macOS 15.2

Terminal Emulator

Ghostty 1.0.1

Installation Method

brew

Helix Version

Helix 24.7 (079f544)

@joelreymont joelreymont added the C-bug Category: This is a bug label Jan 18, 2025
@nik-rev
Copy link
Contributor

nik-rev commented Jan 18, 2025

Maybe record a video of your screen then, when it crashes put the video here.

It'll make it easier to find out how to reproduce it

@joelreymont
Copy link
Author

Problem is that the crash happens every few days and I haven't been able to figure out the circumstances.

Constantly recording my screen is not really viable, I think, and I don't know of a system that only keeps the last minute when recording.

I'll see what I can do, though.

@nik-rev
Copy link
Contributor

nik-rev commented Jan 18, 2025

Problem is that the crash happens every few days and I haven't been able to figure out the circumstances.

Constantly recording my screen is not really viable, I think, and I don't know of a system that only keeps the last minute when recording.

I'll see what I can do, though.

I recommend trying Asciinema: https://asciinema.org/

It records your terminal session in an extremely lightweight text format

@joelreymont
Copy link
Author

Here's another one

thread 'main' panicked at helix-core/src/transaction.rs:499:9:
Positions [(24787, AfterSticky), (24788, BeforeSticky)] are out of range for changeset len 8040!
stack backtrace:
   0: _rust_begin_unwind
   1: core::panicking::panic_fmt
   2: helix_core::transaction::ChangeSet::update_positions
   3: helix_view::view::View::apply
   4: helix_view::document::Document::append_changes_to_history
   5: <helix_term::ui::editor::EditorView as helix_term::compositor::Component>::handle_event
   6: helix_term::compositor::Compositor::handle_event
   7: hx::main_impl::{{closure}}
   8: tokio::runtime::park::CachedParkThread::block_on
   9: tokio::runtime::context::runtime::enter_runtime
  10: tokio::runtime::runtime::Runtime::block_on
  11: hx::main
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

How do I cut the last N seconds from the cast file?

Also, how many seconds should I cut out?

@sik1j
Copy link

sik1j commented Jan 30, 2025

Replying to say that I just had the same issue. The crash log was:

thread 'main' panicked at helix-core/src/transaction.rs:499:9:
Positions [(8623, BeforeSticky)] are out of range for changeset len 8622!
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

I'll try record it if this happens again. This seems related to #9830

@RoloEdits
Copy link
Contributor

What have been the actions that you can remember right before the crash? Were there splits open, did a save happen, a command run, inserting text, deleting text, etc.? Are these crashes all on mac? Ive tried looking into this before, to see if I could find anything, but the panic is happing pretty deep in the call stack, and with the entry being handle_event its hard to narrow down the true start.

@sik1j
Copy link

sik1j commented Jan 30, 2025

It was just basic editing, I'm not too certain anymore but I think I was deleting text. I had a vertical split on the left, and 2 horizontal splits on the right, 5-ish buffers open, and the splits themselves were all of the same file.

It was on a M2 chip macOS Sonoma version 14.4, Ghostty, Helix 25.1 installed through brew. It was also inside a tmux session but I assume that's not relevant.

@RoloEdits
Copy link
Contributor

splits themselves were all of the same file

I wonder if this is common for the others here?

@joelreymont
Copy link
Author

I don't split at all!

@joelreymont
Copy link
Author

I have a Asciinema recording of a session with a crash.

How do I cut the last 3-4 seconds from the cast file so that I can attach it here?

@joelreymont
Copy link
Author

I just got another crash.

Navigated to a definition. Scrolled up to the portion of the file I wanted to look at.

Tried to delete a line by selecting it (X) and then deleting (D).

Crashed when pressing D.

@RoloEdits
Copy link
Contributor

@joelreymont https://docs.asciinema.org/faq/#can-i-editpost-process-the-recording

And thanks for the feedback on the steps. Deletion seems to be the common case. Was the deletion done in code that you own(like the code there is part of that repo) or was the definition code from an external library?

@joelreymont
Copy link
Author

Actually, the reasons are all over the place!

My last two crashes have been on selecting with X and trying to insert with O.

@RoloEdits
Copy link
Contributor

But once again with multiple splits of the same file?

@joelreymont
Copy link
Author

No splits, just your regular plain vanilla editing.

@RoloEdits
Copy link
Contributor

Huh, this is really stumping me. I've never experience this crash on windows. What kind of files are you editing? Do they have many non ascii characters? Is it possible you can provide an example of the files? Its getting to the point where the search scope is so large that I might just male a PR to try to add logs along the way to see if we can find anything in them when it happens again.

@joelreymont
Copy link
Author

I'm not the Mac, programming in Zig, it can't get any simpler.

I suggest switching to the Mac for a few days.

I consistently crash a few times per day, losing my edits.

@joelreymont
Copy link
Author

Also, I'll be glad to build from source and run the version with logging.

@RoloEdits
Copy link
Contributor

I made a branch here with some changes to try to see what step its failing on: https://github.com/RoloEdits/helix/tree/log-changeset-panic

We can keep adding more until we find the steps its failing. My feeling is it could have something to do with how it reverts, which is why I added checks there first, but it could be a combination of edgecases when there is a delete right after an insert? Given that I havent ever come across the panic I dont really know how to test any changes. So this will be a very back and forth process.

@joelreymont
Copy link
Author

I've been running 0.25 without issues for a bit now.

I'll keep going until it crashes and then switch to the branch above.

@joelreymont
Copy link
Author

Incredibly stable so far.

I think this issue may have been fixed but I'll give it another week or two before a final judgement.

@joelreymont
Copy link
Author

It took a whole lot longer but it crashed again

thread 'main' panicked at helix-core/src/transaction.rs:499:9:
Positions [(40501, AfterSticky), (40502, BeforeSticky)] are out of range for changeset len 23542!
stack backtrace:
   0: _rust_begin_unwind
   1: core::panicking::panic_fmt
   2: helix_core::transaction::ChangeSet::update_positions
   3: helix_view::view::View::apply
   4: helix_view::document::Document::append_changes_to_history
   5: <helix_term::ui::editor::EditorView as helix_term::compositor::Component>::handle_event
   6: helix_term::compositor::Compositor::handle_event
   7: hx::main_impl::{{closure}}
   8: tokio::runtime::park::CachedParkThread::block_on
   9: tokio::runtime::context::runtime::enter_runtime
  10: tokio::runtime::runtime::Runtime::block_on
  11: hx::main
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

@joelreymont
Copy link
Author

joelreymont commented Feb 21, 2025

I made a branch here with some changes to try to see what step its failing on: https://github.com/RoloEdits/helix/tree/log-changeset-panic

Do you keep it up to date with master?

@joelreymont
Copy link
Author

Today is my lucky day!

By the way, I don't know what snippets are and I'm not using them.

thread 'main' panicked at helix-core/src/snippets/active.rs:117:21:
assertion failed: range.start <= range.end
stack backtrace:
a   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::snippets::active::ActiveSnippet::map::{{closure}}
   4: smallvec::SmallVec<A>::retain
   5: smallvec::SmallVec<A>::retain_mut
   6: helix_core::snippets::active::ActiveSnippet::map
   7: helix_term::handlers::snippet::register_hooks::{{closure}}
   8: helix_event::hook::ErasedHook::new::call
   9: helix_event::hook::ErasedHook::call
  10: helix_event::registry::Registry::dispatch
  11: helix_event::dispatch::{{closure}}
  12: helix_event::registry::with
  13: helix_event::dispatch
  14: helix_view::document::Document::apply_impl
  15: helix_view::document::Document::apply_inner
  16: helix_view::document::Document::apply
  17: helix_term::commands::open
  18: helix_term::commands::open_below
  19: helix_term::commands::MappableCommand::execute
  20: helix_term::ui::editor::EditorView::handle_keymap_event::{{closure}}
  21: helix_term::ui::editor::EditorView::handle_keymap_event
  22: helix_term::ui::editor::EditorView::command_mode
  23: <helix_term::ui::editor::EditorView as helix_term::compositor::Component>::handle_event
  24: helix_term::compositor::Compositor::handle_event
  25: helix_term::application::Application::handle_terminal_events::{{closure}}
  26: helix_term::application::Application::event_loop_until_idle::{{closure}}
  27: helix_term::application::Application::event_loop::{{closure}}
  28: helix_term::application::Application::run::{{closure}}
  29: hx::main_impl::{{closure}}
  30: <core::pin::Pin<P> as core::future::future::Future>::poll
  31: tokio::runtime::park::CachedParkThread::block_on::{{closure}}
  32: tokio::runtime::park::CachedParkThread::block_on
  33: tokio::runtime::context::blocking::BlockingRegionGuard::block_on
  34: tokio::runtime::scheduler::multi_thread::MultiThread::block_on::{{closure}}
  35: tokio::runtime::context::runtime::enter_runtime
  36: tokio::runtime::scheduler::multi_thread::MultiThread::block_on
  37: tokio::runtime::runtime::Runtime::block_on_inner
  38: tokio::runtime::runtime::Runtime::block_on
  39: hx::main_impl
  40: hx::main
  41: core::ops::function::FnOnce::call_once
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

@siegfried
Copy link

Just had one crash. Unfortunately I cannot reproduce it. It happened when I tried to add a () to the selection. I'm using helix 25.01.1 (e7ac2fcd) on macOS 15.2.

thread 'main' panicked at helix-core/src/transaction.rs:499:9:
Positions [(6780, AfterSticky), (6781, BeforeSticky)] are out of range for changeset len 1897!
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

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

5 participants