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

Unreachable Code on Multiple Select #5272

Closed
creikey opened this issue Dec 23, 2022 · 3 comments · Fixed by #6024
Closed

Unreachable Code on Multiple Select #5272

creikey opened this issue Dec 23, 2022 · 3 comments · Fixed by #6024
Labels
C-bug Category: This is a bug

Comments

@creikey
Copy link

creikey commented Dec 23, 2022

Summary

thread 'main' panicked at 'internal error: entered unreachable code: (Some(Retain(18446744073709550874)))', helix-core\src\transaction.rs:157:46

Reproduction Steps

-I"thirdparty" -I"thirdparty\minilzo" -I"thirdparty\enet\include" -I"thirdparty\Chipmunk2D\include\chipmunk" -I"thirdparty\Chipmunk2D\include" -I"thirdparty\opus\include" -I"thirdparty\opus\src"^

With this line in a file, I selected it with x then selected all spaces with s<space><enter>, moved the cursor right once, then moved into insert mode, then pressed backspace. Then I pressed enter, which causes this crash reliably.

Helix log

~/.cache/helix/helix.log
2022-12-23T11:59:43.065 helix_lsp::transport [ERROR] err <- "I[11:59:43.065] <-- initialize(0)\r\n"
2022-12-23T11:59:43.067 helix_lsp::transport [ERROR] err <- "I[11:59:43.067] --> reply:initialize(0) 1 ms\r\n"
2022-12-23T11:59:43.068 helix_lsp::transport [ERROR] err <- "I[11:59:43.068] <-- initialized\r\n"
2022-12-23T11:59:43.093 helix_lsp::transport [ERROR] err <- "I[11:59:43.093] <-- textDocument/didOpen\r\n"
2022-12-23T11:59:43.097 helix_lsp::transport [ERROR] err <- "I[11:59:43.097] Loaded compilation database from C:\\Users\\Cameron\\Documents\\flight\\compile_commands.json\r\n"
2022-12-23T11:59:43.097 helix_lsp::transport [ERROR] err <- "I[11:59:43.097] ASTWorker building file C:\\Users\\Cameron\\Documents\\flight\\main.c version 0 with command \r\n"
2022-12-23T11:59:43.097 helix_lsp::transport [ERROR] err <- "[C:/Users/Cameron/Documents/flight/]\r\n"
2022-12-23T11:59:43.097 helix_lsp::transport [ERROR] err <- "\"C:\\\\Users\\\\Cameron\\\\AppData\\\\Roaming\\\\ClangPowerTools\\\\LLVM_Lite\\\\Bin\\\\clang++.exe\" --driver-mode=g++ -x c -Wall -fms-compatibility-version=19.10 -Wmicrosoft -Wno-invalid-token-paste -Wno-unknown-pragmas -Wno-unused-value -fsyntax-only -DUNICODE -D_UNICODE -D_MT -D_DEBUG -DDEBUG -D_CONSOLE -D_DEBUG_FUNCTIONAL_MACHINERY \"-isystemC:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.33.31629/include\" \"-isystemC:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.33.31629/atlmfc/include\" \"-isystemC:/Program Files/Microsoft Visual Studio/2022/Community/VC/Auxiliary/VS/include\" \"-isystemC:/Program Files (x86)/Windows Kits/10/Include/10.0.22000.0/ucrt\" \"-isystemC:/Program Files (x86)/Windows Kits/10/Include/10.0.22000.0/um\" \"-isystemC:/Program Files (x86)/Windows Kits/10/Include/10.0.22000.0/shared\" \"-isystemC:/Program Files (x86)/Windows Kits/10/Include/10.0.22000.0/winrt\" \"-isystemC:/Program Files (x86)/Windows Kits/10/Include/10.0.22000.0/cppwinrt\" -Ithirdparty/enet/include -Ithirdparty/Chipmunk2D/include/chipmunk -Ithirdparty -Ithirdparty/Chipmunk2D/include -Ithirdparty/minilzo -Ithirdparty/opus/include \"-resource-dir=C:\\\\Program Files\\\\LLVM\\\\lib\\\\clang\\\\15.0.4\" -- \"C:\\\\Users\\\\Cameron\\\\Documents\\\\flight\\\\main.c\"\r\n"
2022-12-23T11:59:43.100 helix_lsp::transport [ERROR] err <- "I[11:59:43.099] --> window/workDoneProgress/create(0)\r\n"
2022-12-23T11:59:43.100 helix_lsp::transport [ERROR] err <- "I[11:59:43.100] Enqueueing 46 commands for indexing\r\n"
2022-12-23T11:59:43.100 helix_lsp::transport [ERROR] err <- "I[11:59:43.100] <-- reply(0)\r\n"
2022-12-23T11:59:43.100 helix_lsp::transport [ERROR] err <- "I[11:59:43.100] --> $/progress\r\n"
2022-12-23T11:59:43.100 helix_lsp::transport [ERROR] err <- "I[11:59:43.100] --> $/progress\r\n"
2022-12-23T11:59:44.305 helix_lsp::transport [ERROR] err <- "I[11:59:44.305] --> $/progress\r\n"
2022-12-23T11:59:44.305 helix_lsp::transport [ERROR] err <- "I[11:59:44.305] --> $/progress\r\n"
2022-12-23T11:59:47.816 helix_lsp::transport [ERROR] err <- "I[11:59:47.816] --> textDocument/publishDiagnostics\r\n"

Platform

Windows 11

Terminal Emulator

Windows Terminal

Helix Version

22.12-47-g4acdc03b

@creikey creikey added the C-bug Category: This is a bug label Dec 23, 2022
@gabydd
Copy link
Member

gabydd commented Dec 24, 2022

following those steps I can't reproduce that exact panic(edit I can if there is text before the affected line) but if you do this in a scratch buffer and follow those steps it panics at the <backspace> step:

minimal reproduction
:new<enter>i<space><space>a<space>a<esc>xs<space><enter>li<backspace>
or
xs<space><enter>li<backspace> on a a if there are no lines above

full backtrace
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Char range out of bounds: char range 18446744073709551615..1, Rope/RopeSlice char length 5', /home/gaby/.cargo/registry/src/git.luolix.top-1ecc6299db9ec823/ropey-1.5.1-alpha/src/rope.rs:546:37
stack backtrace:
   0:     0x55afa1f47ad4 - std::backtrace_rs::backtrace::libunwind::trace::h22893a5306c091b4
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
   1:     0x55afa1f47ad4 - std::backtrace_rs::backtrace::trace_unsynchronized::h29c3bc6f9e91819d
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x55afa1f47ad4 - std::sys_common::backtrace::_print_fmt::he497d8a0ec903793
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/std/src/sys_common/backtrace.rs:66:5
   3:     0x55afa1f47ad4 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h9c2a9d2774d81873
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/std/src/sys_common/backtrace.rs:45:22
   4:     0x55afa15f23ac - core::fmt::write::hba4337c43d992f49
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/core/src/fmt/mod.rs:1194:17
   5:     0x55afa1f40895 - std::io::Write::write_fmt::heb73de6e02cfabed
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/std/src/io/mod.rs:1655:15
   6:     0x55afa1f4997e - std::sys_common::backtrace::_print::h63c8b24acdd8e8ce
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/std/src/sys_common/backtrace.rs:48:5
   7:     0x55afa1f4997e - std::sys_common::backtrace::print::h426700d6240cdcc2
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/std/src/sys_common/backtrace.rs:35:9
   8:     0x55afa1f4997e - std::panicking::default_hook::{{closure}}::hc9a76eed0b18f82b
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/std/src/panicking.rs:295:22
   9:     0x55afa1f496ad - std::panicking::default_hook::h2e88d02087fae196
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/std/src/panicking.rs:314:9
  10:     0x55afa1f4a0bb - std::panicking::rust_panic_with_hook::habfdcc2e90f9fd4c
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/std/src/panicking.rs:702:17
  11:     0x55afa1f49ee4 - std::panicking::begin_panic_handler::{{closure}}::he054b2a83a51d2cd
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/std/src/panicking.rs:588:13
  12:     0x55afa1f48004 - std::sys_common::backtrace::__rust_end_short_backtrace::ha48b94ab49b30915
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/std/src/sys_common/backtrace.rs:138:18
  13:     0x55afa1f49c4d - rust_begin_unwind
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/std/src/panicking.rs:584:5
  14:     0x55afa15f0d03 - core::panicking::panic_fmt::h366d3a309ae17c94
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/core/src/panicking.rs:143:14
  15:     0x55afa15f0fb3 - core::result::unwrap_failed::hddd78f4658ac7d0f
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/core/src/result.rs:1785:5
  16:     0x55afa175f605 - ropey::rope::Rope::remove::ha66e170710db2d98
  17:     0x55afa176e169 - helix_core::transaction::ChangeSet::apply::h6d2a09452bf483f9
  18:     0x55afa1ceb9a1 - helix_view::document::Document::apply_impl::h1166945ecc4a6dbd
  19:     0x55afa1ced097 - helix_view::document::Document::apply::h0d5308ad4abdccb0
  20:     0x55afa1a73ab3 - helix_term::commands::insert::delete_char_backward::ha611f6d91236d0b7
  21:     0x55afa19d3323 - helix_term::ui::editor::EditorView::handle_keymap_event::{{closure}}::he1eb2f5a8bda7929
  22:     0x55afa19d324a - helix_term::ui::editor::EditorView::handle_keymap_event::h8f140bececad49a1
  23:     0x55afa19d36af - helix_term::ui::editor::EditorView::insert_mode::h2f0b1ce9f4742be3
  24:     0x55afa19d5e1a - <helix_term::ui::editor::EditorView as helix_term::compositor::Component>::handle_event::h5cd0103a680bf9cc
  25:     0x55afa196f2d6 - helix_term::compositor::Compositor::handle_event::hc70763982578bd08
  26:     0x55afa1da5623 - helix_term::application::Application::run::{{closure}}::h7fbe376ebcef3a7f
  27:     0x55afa1dc8a79 - <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll::hb2cfa6140ccb53cc
  28:     0x55afa1dd5c63 - tokio::runtime::park::CachedParkThread::block_on::h6677c1f1a9db0b20
  29:     0x55afa1d87277 - tokio::runtime::scheduler::multi_thread::MultiThread::block_on::h0de39563e8c25763
  30:     0x55afa1d9e7c6 - hx::main::he49c0fc0db18b7c1
  31:     0x55afa1d8e643 - std::sys_common::backtrace::__rust_begin_short_backtrace::ha6aa969ebab9e75d
  32:     0x55afa1ddb49d - std::rt::lang_start::{{closure}}::h80b7db8192fdec63
  33:     0x55afa1f3afdb - core::ops::function::impls::<impl core::ops::function::FnOnce<A> for &F>::call_once::had4f69b3aefb47a8
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/core/src/ops/function.rs:259:13
  34:     0x55afa1f3afdb - std::panicking::try::do_call::hf2ad5355fcafe775
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/std/src/panicking.rs:492:40
  35:     0x55afa1f3afdb - std::panicking::try::h0a63ac363423e61e
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/std/src/panicking.rs:456:19
  36:     0x55afa1f3afdb - std::panic::catch_unwind::h18088edcecb8693a
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/std/src/panic.rs:137:14
  37:     0x55afa1f3afdb - std::rt::lang_start_internal::{{closure}}::ha7dad166dc711761
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/std/src/rt.rs:128:48
  38:     0x55afa1f3afdb - std::panicking::try::do_call::hda0c61bf3a57d6e6
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/std/src/panicking.rs:492:40
  39:     0x55afa1f3afdb - std::panicking::try::hbc940e68560040a9
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/std/src/panicking.rs:456:19
  40:     0x55afa1f3afdb - std::panic::catch_unwind::haed0df2aeb3fa368
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/std/src/panic.rs:137:14
  41:     0x55afa1f3afdb - std::rt::lang_start_internal::h9c06694362b5b80c
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/std/src/rt.rs:128:20
  42:     0x55afa1d9e9a2 - main
  43:     0x7f982f869290 - <unknown>
  44:     0x7f982f86934a - __libc_start_main
  45:     0x55afa1598e55 - _start
                               at /build/glibc/src/glibc/csu/../sysdeps/x86_64/start.S:115
  46:                0x0 - <unknown>

panic from issue(above one might be closer to the problem)

:new<enter>ia<enter><space><space>a<space>a<esc>xs<space><enter>li<backspace><enter>
or
xs<space><enter>li<backspace><enter> on

a
  a a
full backtrace
thread 'main' panicked at 'internal error: entered unreachable code: (Some(Retain(18446744073709551613)))', helix-core/src/transaction.rs:157:46
stack backtrace:
   0:     0x564212681ad4 - std::backtrace_rs::backtrace::libunwind::trace::h22893a5306c091b4
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
   1:     0x564212681ad4 - std::backtrace_rs::backtrace::trace_unsynchronized::h29c3bc6f9e91819d
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x564212681ad4 - std::sys_common::backtrace::_print_fmt::he497d8a0ec903793
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/std/src/sys_common/backtrace.rs:66:5
   3:     0x564212681ad4 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h9c2a9d2774d81873
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/std/src/sys_common/backtrace.rs:45:22
   4:     0x564211d2c3ac - core::fmt::write::hba4337c43d992f49
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/core/src/fmt/mod.rs:1194:17
   5:     0x56421267a895 - std::io::Write::write_fmt::heb73de6e02cfabed
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/std/src/io/mod.rs:1655:15
   6:     0x56421268397e - std::sys_common::backtrace::_print::h63c8b24acdd8e8ce
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/std/src/sys_common/backtrace.rs:48:5
   7:     0x56421268397e - std::sys_common::backtrace::print::h426700d6240cdcc2
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/std/src/sys_common/backtrace.rs:35:9
   8:     0x56421268397e - std::panicking::default_hook::{{closure}}::hc9a76eed0b18f82b
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/std/src/panicking.rs:295:22
   9:     0x5642126836ad - std::panicking::default_hook::h2e88d02087fae196
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/std/src/panicking.rs:314:9
  10:     0x5642126840bb - std::panicking::rust_panic_with_hook::habfdcc2e90f9fd4c
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/std/src/panicking.rs:702:17
  11:     0x564212683ee4 - std::panicking::begin_panic_handler::{{closure}}::he054b2a83a51d2cd
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/std/src/panicking.rs:588:13
  12:     0x564212682004 - std::sys_common::backtrace::__rust_end_short_backtrace::ha48b94ab49b30915
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/std/src/sys_common/backtrace.rs:138:18
  13:     0x564212683c4d - rust_begin_unwind
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/std/src/panicking.rs:584:5
  14:     0x564211d2ad03 - core::panicking::panic_fmt::h366d3a309ae17c94
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/core/src/panicking.rs:143:14
  15:     0x564211ea71bc - helix_core::transaction::ChangeSet::compose::h5fb0acffc57a7056
  16:     0x5642124271bd - helix_view::document::Document::apply::h0d5308ad4abdccb0
  17:     0x5642121ad473 - helix_term::commands::insert::insert_newline::h00623da086973675
  18:     0x56421210d323 - helix_term::ui::editor::EditorView::handle_keymap_event::{{closure}}::he1eb2f5a8bda7929
  19:     0x56421210d24a - helix_term::ui::editor::EditorView::handle_keymap_event::h8f140bececad49a1
  20:     0x56421210d6af - helix_term::ui::editor::EditorView::insert_mode::h2f0b1ce9f4742be3
  21:     0x56421210fe1a - <helix_term::ui::editor::EditorView as helix_term::compositor::Component>::handle_event::h5cd0103a680bf9cc
  22:     0x5642120a92d6 - helix_term::compositor::Compositor::handle_event::hc70763982578bd08
  23:     0x5642124df623 - helix_term::application::Application::run::{{closure}}::h7fbe376ebcef3a7f
  24:     0x564212502a79 - <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll::hb2cfa6140ccb53cc
  25:     0x56421250fc63 - tokio::runtime::park::CachedParkThread::block_on::h6677c1f1a9db0b20
  26:     0x5642124c1277 - tokio::runtime::scheduler::multi_thread::MultiThread::block_on::h0de39563e8c25763
  27:     0x5642124d87c6 - hx::main::he49c0fc0db18b7c1
  28:     0x5642124c8643 - std::sys_common::backtrace::__rust_begin_short_backtrace::ha6aa969ebab9e75d
  29:     0x56421251549d - std::rt::lang_start::{{closure}}::h80b7db8192fdec63
  30:     0x564212674fdb - core::ops::function::impls::<impl core::ops::function::FnOnce<A> for &F>::call_once::had4f69b3aefb47a8
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/core/src/ops/function.rs:259:13
  31:     0x564212674fdb - std::panicking::try::do_call::hf2ad5355fcafe775
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/std/src/panicking.rs:492:40
  32:     0x564212674fdb - std::panicking::try::h0a63ac363423e61e
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/std/src/panicking.rs:456:19
  33:     0x564212674fdb - std::panic::catch_unwind::h18088edcecb8693a
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/std/src/panic.rs:137:14
  34:     0x564212674fdb - std::rt::lang_start_internal::{{closure}}::ha7dad166dc711761
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/std/src/rt.rs:128:48
  35:     0x564212674fdb - std::panicking::try::do_call::hda0c61bf3a57d6e6
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/std/src/panicking.rs:492:40
  36:     0x564212674fdb - std::panicking::try::hbc940e68560040a9
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/std/src/panicking.rs:456:19
  37:     0x564212674fdb - std::panic::catch_unwind::haed0df2aeb3fa368
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/std/src/panic.rs:137:14
  38:     0x564212674fdb - std::rt::lang_start_internal::h9c06694362b5b80c
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/std/src/rt.rs:128:20
  39:     0x5642124d89a2 - main
  40:     0x7f9779c66290 - <unknown>
  41:     0x7f9779c6634a - __libc_start_main
  42:     0x564211cd2e55 - _start
                               at /build/glibc/src/glibc/csu/../sysdeps/x86_64/start.S:115
  43:                0x0 - <unknown>

@gabydd
Copy link
Member

gabydd commented Dec 24, 2022

ok more minimal reproduction of my first panic: :new<enter>i<space><space><esc>xs<space>li<backspace>
the second one also works with(where * is a <space>)


***

which pretty much confirms my suspicions, that this has to do with the special handling of delete_char_backward for indent characters where

  1. the selection before the panic is the second space and the newline
  2. the newline selection will create a transaction to delete both spaces
  3. the selection on the space will create a transaction to remove the first space and
    therefor they are removing one of the same spaces. this is why it can be only be reproduced when deleting spaces not other characters

@pascalkuthe
Copy link
Member

forgot to comment here: this is fixed by #6024

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