Stream: t-compiler/rust-analyzer

Topic: Annoying crash in rust-analyzer, how to debug?

Daniel Egger (May 08 2020 at 12:38, on Zulip):

I have this super weird crash of rust-analyzer both in vim (with coc plugin) and VSCode in some actix code but I've no idea how to debug this without any editor running as I can't find this information in the repository.

As soon as I try to crank up the debugging by enabling full stacktraces the the panic vanishes and an error messages about a long running loop occurs instead. This is the panic I'm trying to figure out:

stack backtrace:
   0: <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt
   1: core::fmt::write
   2: std::io::Write::write_fmt
   3: std::panicking::default_hook::{{closure}}
   4: std::panicking::default_hook
   5: std::panicking::rust_panic_with_hook
   6: rust_begin_unwind
   7: core::panicking::panic_fmt
   8: core::str::slice_error_fail
   9: core::str::traits::<impl core::slice::SliceIndex<str> for core::ops::range::Range<usize>>::index::{{closure}}
  10: ra_ide::display::function_signature::FunctionSignature::from_struct
  11: ra_ide::inlay_hints::get_param_name_hints
  12: ra_ide::inlay_hints::inlay_hints
  13: std::panicking::try::do_call
  14: __rust_maybe_catch_panic
  15: ra_db::CheckCanceled::catch_canceled
  16: ra_ide::Analysis::inlay_hints
  17: rust_analyzer::main_loop::handlers::handle_inlay_hints
  18: <F as threadpool::FnBox>::call_box
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

Is there any easy would from the CLI to trigger the function in line 10 from the CLI?

Laurențiu (May 08 2020 at 12:39, on Zulip):

Might be

Laurențiu (May 08 2020 at 12:40, on Zulip):

To get better stack traces you don't need to set RUST_BACKTRACE=full, but rather bump debug to 1 or 2 in rust-analyzer's Cargo.toml and rebuild it

Daniel Egger (May 08 2020 at 12:42, on Zulip):

I'm seeing this with a version one commit ahead of this PR.

Daniel Egger (May 08 2020 at 12:43, on Zulip):

Will retry with a bumped debug setting but it would be great if I could trigger the bug outside of an editor.

bjorn3 (May 08 2020 at 12:46, on Zulip):

I think the panic is at

matklad (May 08 2020 at 12:46, on Zulip):

Hm, yeah, that code is def still broken, it dies [1..] all over the place :-(

matklad (May 08 2020 at 12:46, on Zulip):

There are four potential panics there :-)

Laurențiu (May 08 2020 at 12:47, on Zulip):

Should that code use Display and split stuff out of strings? It seems a bit finicky.

bjorn3 (May 08 2020 at 12:47, on Zulip):

But only one string indexing as in the backtrace, right?

matklad (May 08 2020 at 12:50, on Zulip): @Laurențiu Nicola ^^

Daniel Egger (May 08 2020 at 13:03, on Zulip):

Hm... [ERROR rust_analyzer::main_loop] overly long loop turn: 594.980266ms

And of course with debug=2, I can't reproduce the panic anymore...

Last update: Jul 28 2021 at 04:45UTC