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

Panic when inserting non-ascii character. #58

Closed
pickfire opened this issue Jun 2, 2021 · 2 comments · Fixed by #121
Closed

Panic when inserting non-ascii character. #58

pickfire opened this issue Jun 2, 2021 · 2 comments · Fixed by #121
Labels
C-bug Category: This is a bug

Comments

@pickfire
Copy link
Contributor

pickfire commented Jun 2, 2021

I insert 一a and it paniced. 0a6672c

thread 'main' panicked at 'assertion failed: self.len_after == other.len', helix-core/src/transaction.rs:127:9
stack backtrace:
   0: rust_begin_unwind
             at /rustc/9bc8c42bb2f19e745a63f3445f1ac248fb015e53/library/std/src/panicking.rs:493:5
   1: core::panicking::panic_fmt
             at /rustc/9bc8c42bb2f19e745a63f3445f1ac248fb015e53/library/core/src/panicking.rs:92:14
   2: core::panicking::panic
             at /rustc/9bc8c42bb2f19e745a63f3445f1ac248fb015e53/library/core/src/panicking.rs:50:5
   3: helix_core::transaction::ChangeSet::compose
             at ./helix-core/src/transaction.rs:127:9
   4: helix_view::document::Document::apply::{{closure}}
             at ./helix-view/src/document.rs:331:17
   5: helix_view::document::take_with::{{closure}}
             at ./helix-view/src/document.rs:61:68
   6: <std::panic::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once
             at /home/ivan/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/panic.rs:344:9
   7: std::panicking::try::do_call
             at /home/ivan/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/panicking.rs:379:40
   8: __rust_try
   9: std::panicking::try
             at /home/ivan/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/panicking.rs:343:19
  10: std::panic::catch_unwind
             at /home/ivan/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/panic.rs:431:14
  11: helix_view::document::take_with
             at ./helix-view/src/document.rs:61:21
  12: helix_view::document::Document::apply
             at ./helix-view/src/document.rs:330:13
  13: hx::commands::insert::insert_char
             at ./helix-term/src/commands.rs:1613:17
  14: hx::ui::editor::EditorView::insert_mode
             at ./helix-term/src/ui/editor.rs:476:13
  15: <hx::ui::editor::EditorView as hx::compositor::Component>::handle_event
             at ./helix-term/src/ui/editor.rs:579:33
  16: hx::compositor::Compositor::handle_event
             at ./helix-term/src/compositor.rs:112:19
  17: hx::application::Application::handle_terminal_events
             at ./helix-term/src/application.rs:132:32
  18: hx::application::Application::event_loop::{{closure}}
             at ./helix-term/src/application.rs:96:21
  19: <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll
             at /home/ivan/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/future/mod.rs:80:19
  20: hx::application::Application::run::{{closure}}
             at ./helix-term/src/application.rs:254:9
  21: <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll
             at /home/ivan/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/future/mod.rs:80:19
  22: hx::main::{{closure}}
             at ./helix-term/src/main.rs:121:5
  23: <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll
             at /home/ivan/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/future/mod.rs:80:19
  24: tokio::park::thread::CachedParkThread::block_on::{{closure}}
             at /home/ivan/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.6.1/src/park/thread.rs:263:54
  25: tokio::coop::with_budget::{{closure}}
             at /home/ivan/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.6.1/src/coop.rs:106:9
  26: std::thread::local::LocalKey<T>::try_with
             at /home/ivan/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/thread/local.rs:272:16
  27: std::thread::local::LocalKey<T>::with
             at /home/ivan/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/thread/local.rs:248:9
  28: tokio::coop::with_budget
             at /home/ivan/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.6.1/src/coop.rs:99:5
  29: tokio::coop::budget
             at /home/ivan/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.6.1/src/coop.rs:76:5
  30: tokio::park::thread::CachedParkThread::block_on
             at /home/ivan/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.6.1/src/park/thread.rs:263:31
  31: tokio::runtime::enter::Enter::block_on
             at /home/ivan/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.6.1/src/runtime/enter.rs:151:13
  32: tokio::runtime::thread_pool::ThreadPool::block_on
             at /home/ivan/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.6.1/src/runtime/thread_pool/mod.rs:71:9
  33: tokio::runtime::Runtime::block_on
             at /home/ivan/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.6.1/src/runtime/mod.rs:452:43
  34: hx::main
             at ./helix-term/src/main.rs:123:5
  35: core::ops::function::FnOnce::call_once
             at /home/ivan/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ops/function.rs:227:5
@archseer archseer added the C-bug Category: This is a bug label Jun 3, 2021
@kirawi
Copy link
Member

kirawi commented Jun 3, 2021

In helix-core/src/transaction.rs:485, it looks like this is where the bug is caused? Not completely sure.

@kirawi
Copy link
Member

kirawi commented Jun 3, 2021

Found it. len() was being used on Strings instead of chars().count(). Curiously, it works on 0.0.8 despite not having this.

kirawi added a commit to kirawi/helix that referenced this issue Jun 3, 2021
This was referenced Jun 3, 2021
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

Successfully merging a pull request may close this issue.

3 participants