Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Crash when force closing a buffer that was deleted on disk #2624

Closed
aral opened this issue May 31, 2022 · 4 comments
Closed

Crash when force closing a buffer that was deleted on disk #2624

aral opened this issue May 31, 2022 · 4 comments
Labels
A-helix-term Area: Helix term improvements C-bug Category: This is a bug

Comments

@aral
Copy link
Contributor

aral commented May 31, 2022

Summary

I had deleted the file of an open buffer on disk. I then tried to force close it :buffer-close!. It crashed.

Reproduction Steps

In the middle of coding; can’t recreate now as I don’t want to lose my flow :)

Helix log

❯ RUST_BACKTRACE=full hx .
thread 'main' panicked at 'no entry found for key', helix-view/src/editor.rs:623:24
stack backtrace:
   0:     0x5599588012a4 - std::backtrace_rs::backtrace::libunwind::trace::h22893a5306c091b4
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
   1:     0x5599588012a4 - std::backtrace_rs::backtrace::trace_unsynchronized::h29c3bc6f9e91819d
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x5599588012a4 - std::sys_common::backtrace::_print_fmt::he497d8a0ec903793
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/std/src/sys_common/backtrace.rs:66:5
   3:     0x5599588012a4 - <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:     0x5599580e676c - core::fmt::write::hba4337c43d992f49
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/core/src/fmt/mod.rs:1194:17
   5:     0x5599587fad15 - std::io::Write::write_fmt::heb73de6e02cfabed
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/std/src/io/mod.rs:1655:15
   6:     0x55995880314e - std::sys_common::backtrace::_print::h63c8b24acdd8e8ce
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/std/src/sys_common/backtrace.rs:48:5
   7:     0x55995880314e - std::sys_common::backtrace::print::h426700d6240cdcc2
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/std/src/sys_common/backtrace.rs:35:9
   8:     0x55995880314e - std::panicking::default_hook::{{closure}}::hc9a76eed0b18f82b
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/std/src/panicking.rs:295:22
   9:     0x559958802e7d - std::panicking::default_hook::h2e88d02087fae196
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/std/src/panicking.rs:314:9
  10:     0x5599586bd28b - helix_term::application::Application::run::{{closure}}::{{closure}}::h12d44a26b16c4ad5
  11:     0x5599588037db - std::panicking::rust_panic_with_hook::habfdcc2e90f9fd4c
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/std/src/panicking.rs:702:17
  12:     0x559958803604 - std::panicking::begin_panic_handler::{{closure}}::he054b2a83a51d2cd
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/std/src/panicking.rs:588:13
  13:     0x5599588017d4 - std::sys_common::backtrace::__rust_end_short_backtrace::ha48b94ab49b30915
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/std/src/sys_common/backtrace.rs:138:18
  14:     0x55995880336d - rust_begin_unwind
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/std/src/panicking.rs:584:5
  15:     0x55995806bd53 - core::panicking::panic_fmt::h366d3a309ae17c94
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/core/src/panicking.rs:143:14
  16:     0x5599580e4e41 - core::panicking::panic_display::hd3e89d99fb893792
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/core/src/panicking.rs:72:5
  17:     0x5599580e4deb - core::panicking::panic_str::h98ed104b0c03a108
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/core/src/panicking.rs:56:5
  18:     0x55995806bbc6 - core::option::expect_failed::h58d487f78ae9d247
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/core/src/option.rs:1874:5
  19:     0x559958623362 - helix_view::editor::Editor::_refresh::ha2e2ed7d1cace601
  20:     0x55995862583e - helix_view::editor::Editor::close_document::h667e61d73b64ffb1
  21:     0x559958428c84 - helix_term::commands::typed::force_buffer_close::hb717e4706cde3eb6
  22:     0x559958570ca3 - helix_term::commands::typed::command_mode::{{closure}}::hd80e9c54965b77b3
  23:     0x55995858ec44 - <helix_term::ui::prompt::Prompt as helix_term::compositor::Component>::handle_event::hc20edb7ef05bb693
  24:     0x559958443871 - helix_term::compositor::Compositor::handle_event::h44595494eda1b0f4
  25:     0x5599583e69ae - helix_term::application::Application::handle_terminal_events::h8c7f5825c5f0b97e
  26:     0x5599586b93e5 - helix_term::application::Application::event_loop::{{closure}}::h455c71991fc9a5cb
  27:     0x5599586ce629 - <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll::h4aff422bd5ed82f2
  28:     0x55995869d802 - std::thread::local::LocalKey<T>::with::h68203639b5e723f2
  29:     0x559958693bd8 - tokio::park::thread::CachedParkThread::block_on::hc62f258db2ec3bc9
  30:     0x5599586863e3 - tokio::runtime::thread_pool::ThreadPool::block_on::he68c9450f117fde0
  31:     0x5599586ac550 - tokio::runtime::Runtime::block_on::h0be5f107588a71ae
  32:     0x55995866857d - hx::main::h55147127aa9b3379
  33:     0x55995868df43 - std::sys_common::backtrace::__rust_begin_short_backtrace::h19d108ced6e85bb1
  34:     0x55995869d51d - std::rt::lang_start::{{closure}}::h86db281d33c9137e
  35:     0x5599587f55ab - 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
  36:     0x5599587f55ab - std::panicking::try::do_call::hf2ad5355fcafe775
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/std/src/panicking.rs:492:40
  37:     0x5599587f55ab - std::panicking::try::h0a63ac363423e61e
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/std/src/panicking.rs:456:19
  38:     0x5599587f55ab - std::panic::catch_unwind::h18088edcecb8693a
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/std/src/panic.rs:137:14
  39:     0x5599587f55ab - std::rt::lang_start_internal::{{closure}}::ha7dad166dc711761
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/std/src/rt.rs:128:48
  40:     0x5599587f55ab - std::panicking::try::do_call::hda0c61bf3a57d6e6
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/std/src/panicking.rs:492:40
  41:     0x5599587f55ab - std::panicking::try::hbc940e68560040a9
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/std/src/panicking.rs:456:19
  42:     0x5599587f55ab - std::panic::catch_unwind::haed0df2aeb3fa368
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/std/src/panic.rs:137:14
  43:     0x5599587f55ab - std::rt::lang_start_internal::h9c06694362b5b80c
                               at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/std/src/rt.rs:128:20
  44:     0x5599586686a2 - main
  45:     0x7f1197bcbd90 - <unknown>
  46:     0x7f1197bcbe40 - __libc_start_main
  47:     0x55995809c005 - _start
  48:                0x0 - <unknown>

Platform

Linux (Fedora Silverblue 36)

Terminal Emulator

GNOME Console

Helix Version

helix 22.05 (fc8c488)

@aral aral added the C-bug Category: This is a bug label May 31, 2022
@the-mikedavis the-mikedavis added the A-helix-term Area: Helix term improvements label May 31, 2022
@the-mikedavis
Copy link
Member

That block:

fn _refresh(&mut self) {
let config = self.config();
for (view, _) in self.tree.views_mut() {
let doc = &self.documents[&view.doc];
view.ensure_cursor_in_view(doc, config.scrolloff)
}
}

@kirawi
Copy link
Member

kirawi commented Nov 10, 2022

@dead10ck did your write fixes address this issue?

@dead10ck
Copy link
Member

@dead10ck did your write fixes address this issue?

I don't believe so. After poking around a bit, I'm not sure that deleting the file externally has anything to do with the crash. This seems to be a case where after closing the document, there's still a view in memory whose document was the one we just closed—thus the "no entry found for key" error, which appears to be coming from this line in particular.

let doc = &self.documents[&view.doc];

The question is how this is happening

@pascalkuthe
Copy link
Member

I am pretty certain that #4888 fixes the underlying issue here. I am closing this issue as there is no reproduction case to confirm. If you are still having this problem feel free to open a new issue or reopen this one

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
A-helix-term Area: Helix term improvements C-bug Category: This is a bug
Projects
None yet
Development

No branches or pull requests

5 participants