rust-lang / rust-lang/rust-analyzer

rust-analyzer panic when call `callHierarchy/outgoingCalls`

Open
#17,762 6 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

C-bug
Dominant language
Rust
Stars
16.9k
Forks
2.2k
Avg merge
1d 12h
Merged PRs (30d)
72

Description

rust-analyzer version: (eg. output of "rust-analyzer: Show RA Version" command, accessible in VSCode via Ctrl/⌘+Shift+P)
1.81.0-nightly (9c3bc80 2024-06-27)
rustc version: (eg. output of rustc -V)

rustc 1.81.0-nightly (9c3bc805d 2024-06-27)
binary: rustc
commit-hash: 9c3bc805dd9cb84019c124b9a50fdff1e62a7ec9
commit-date: 2024-06-27
host: x86_64-unknown-linux-gnu
release: 1.81.0-nightly
LLVM version: 18.1.7

editor or extension: (eg. VSCode, Vim, Emacs, etc. For VSCode users, specify your extension version; for users of other editors, provide the distribution if applicable)
Emacs with lsp-mode.el
relevant settings: (eg. client settings, or environment variables like CARGO, RUSTC, RUSTUP_HOME or CARGO_HOME)

repository link (if public, optional): (eg. rust-analyzer)
https://github.com/BurntSushi/ripgrep/blob/master/crates/core/messages.rs#L124

code snippet to reproduce:

  1. Put cursor on https://github.com/BurntSushi/ripgrep/blob/master/crates/core/messages.rs#L124
  2. call callHierarchy/outgoingCalls will got the panci:
Panic context:
> 
version: 1.81.0-nightly (9c3bc80 2024-06-27)
request: callHierarchy/outgoingCalls CallHierarchyOutgoingCallsParams {
    item: CallHierarchyItem {
        name: "atomic_store",
        kind: Function,
        tags: None,
        detail: Some(
            "unsafe fn atomic_store<T>(dst: *mut T, val: T, order: Ordering)\nwhere\n    T: Copy,",
        ),
        uri: Url {
            scheme: "file",
            cannot_be_a_base: false,
            username: "",
            password: None,
            host: None,
            port: None,
            path: "/home/exec/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/sync/atomic.rs",
            query: None,
            fragment: None,
        },
        range: Range {
            start: Position {
                line: 3292,
                character: 0,
            },
            end: Position {
                line: 3305,
                character: 1,
            },
        },
        selection_range: Range {
            start: Position {
                line: 3294,
                character: 10,
            },
            end: Position {
                line: 3294,
                character: 22,
            },
        },
        data: None,
    },
    work_done_progress_params: WorkDoneProgressParams {
        work_done_token: None,
    },
    partial_result_params: PartialResultParams {
        partial_result_token: None,
    },
}

thread 'Worker' panicked at /rust/deps/line-index-0.1.1/src/lib.rs:111:35:
invalid offset
stack backtrace:
   0:     0x7fb87118c325 - std::backtrace_rs::backtrace::libunwind::trace::h07b28210221fdfcf
                               at /rustc/9c3bc805dd9cb84019c124b9a50fdff1e62a7ec9/library/std/src/../../backtrace/src/backtrace/libunwind.rs:116:5
   1:     0x7fb87118c325 - std::backtrace_rs::backtrace::trace_unsynchronized::h57474388c6dca70e
                               at /rustc/9c3bc805dd9cb84019c124b9a50fdff1e62a7ec9/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7fb87118c325 - std::sys::backtrace::_print_fmt::hf65679b3b8aa3de9
                               at /rustc/9c3bc805dd9cb84019c124b9a50fdff1e62a7ec9/library/std/src/sys/backtrace.rs:68:5
   3:     0x7fb87118c325 - <std::sys::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h3b74abb4c59b311d
                               at /rustc/9c3bc805dd9cb84019c124b9a50fdff1e62a7ec9/library/std/src/sys/backtrace.rs:44:22
   4:     0x7fb8711dbeeb - core::fmt::rt::Argument::fmt::h2e8bf0997b20ef74
                               at /rustc/9c3bc805dd9cb84019c124b9a50fdff1e62a7ec9/library/core/src/fmt/rt.rs:165:63
   5:     0x7fb8711dbeeb - core::fmt::write::h411a68a005ab8995
                               at /rustc/9c3bc805dd9cb84019c124b9a50fdff1e62a7ec9/library/core/src/fmt/mod.rs:1168:21
   6:     0x7fb871180fbf - std::io::Write::write_fmt::he4dc34d02cbce267
                               at /rustc/9c3bc805dd9cb84019c124b9a50fdff1e62a7ec9/library/std/src/io/mod.rs:1835:15
   7:     0x7fb87118c0fe - std::sys::backtrace::_print::ha6b310959102561f
                               at /rustc/9c3bc805dd9cb84019c124b9a50fdff1e62a7ec9/library/std/src/sys/backtrace.rs:47:5
   8:     0x7fb87118c0fe - std::sys::backtrace::print::h85fe5852cea7cec8
                               at /rustc/9c3bc805dd9cb84019c124b9a50fdff1e62a7ec9/library/std/src/sys/backtrace.rs:34:9
   9:     0x7fb87118ea49 - std::panicking::default_hook::{{closure}}::ha3c5796eabdb9549
  10:     0x7fb87118e7ec - std::panicking::default_hook::hd5d9e6ee76a17e6c
                               at /rustc/9c3bc805dd9cb84019c124b9a50fdff1e62a7ec9/library/std/src/panicking.rs:292:9
  11:     0x55bf6013f4b2 - <stdx[6ea13dea3eae90fa]::panic_context::PanicContext>::init::{closure#0}
  12:     0x7fb87118f31f - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::hd3484a16c3465019
                               at /rustc/9c3bc805dd9cb84019c124b9a50fdff1e62a7ec9/library/alloc/src/boxed.rs:2078:9
  13:     0x7fb87118f31f - std::panicking::rust_panic_with_hook::hf1adc754e9701eca
                               at /rustc/9c3bc805dd9cb84019c124b9a50fdff1e62a7ec9/library/std/src/panicking.rs:804:13
  14:     0x7fb87118ef47 - std::panicking::begin_panic_handler::{{closure}}::hee50761a1b454f3e
                               at /rustc/9c3bc805dd9cb84019c124b9a50fdff1e62a7ec9/library/std/src/panicking.rs:670:13
  15:     0x7fb87118c7e9 - std::sys::backtrace::__rust_end_short_backtrace::h54a0955362eadbbb
                               at /rustc/9c3bc805dd9cb84019c124b9a50fdff1e62a7ec9/library/std/src/sys/backtrace.rs:171:18
  16:     0x7fb87118ec24 - rust_begin_unwind
                               at /rustc/9c3bc805dd9cb84019c124b9a50fdff1e62a7ec9/library/std/src/panicking.rs:661:5
  17:     0x7fb8711d84a3 - core::panicking::panic_fmt::h55e93124dd288cd7
                               at /rustc/9c3bc805dd9cb84019c124b9a50fdff1e62a7ec9/library/core/src/panicking.rs:74:14
  18:     0x7fb8711d82db - core::panicking::panic_display::ha354ffe96c543f97
                               at /rustc/9c3bc805dd9cb84019c124b9a50fdff1e62a7ec9/library/core/src/panicking.rs:264:5
  19:     0x7fb8711d82db - core::option::expect_failed::h7aa7b38d428aaaec
                               at /rustc/9c3bc805dd9cb84019c124b9a50fdff1e62a7ec9/library/core/src/option.rs:2023:5
  20:     0x55bf5f91ba51 - <line_index[5872198562828a97]::LineIndex>::line_col
  21:     0x55bf5f1512a9 - rust_analyzer[36e1672cec1b44b9]::lsp::to_proto::range
  22:     0x55bf5f109bad - rust_analyzer[36e1672cec1b44b9]::handlers::request::handle_call_hierarchy_outgoing
  23:     0x55bf5ef8b070 - <<stdx[6ea13dea3eae90fa]::thread::pool::Pool>::spawn<<rust_analyzer[36e1672cec1b44b9]::task_pool::TaskPool<rust_analyzer[36e1672cec1b44b9]::main_loop::Task>>::spawn<<rust_analyzer[36e1672cec1b44b9]::dispatch::RequestDispatcher>::on_with_thread_intent<true, false, lsp_types[bff49e2f37f6d3b7]::request::CallHierarchyOutgoingCalls>::{closure#0}>::{closure#0}>::{closure#0} as core[d16126bd6b552dfc]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  24:     0x55bf6013c291 - std[74439f15b62b8a55]::sys::backtrace::__rust_begin_short_backtrace::<<stdx[6ea13dea3eae90fa]::thread::Builder>::spawn<<stdx[6ea13dea3eae90fa]::thread::pool::Pool>::new::{closure#0}, ()>::{closure#0}, ()>
  25:     0x55bf6013d3e2 - <<std[74439f15b62b8a55]::thread::Builder>::spawn_unchecked_<<stdx[6ea13dea3eae90fa]::thread::Builder>::spawn<<stdx[6ea13dea3eae90fa]::thread::pool::Pool>::new::{closure#0}, ()>::{closure#0}, ()>::{closure#2} as core[d16126bd6b552dfc]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  26:     0x7fb8711991ab - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h1961d6f9f91f3c82
                               at /rustc/9c3bc805dd9cb84019c124b9a50fdff1e62a7ec9/library/alloc/src/boxed.rs:2064:9
  27:     0x7fb8711991ab - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hde4b94e543ba1278
                               at /rustc/9c3bc805dd9cb84019c124b9a50fdff1e62a7ec9/library/alloc/src/boxed.rs:2064:9
  28:     0x7fb8711991ab - std::sys::pal::unix::thread::Thread::new::thread_start::h726d268d34ef4439
                               at /rustc/9c3bc805dd9cb84019c124b9a50fdff1e62a7ec9/library/std/src/sys/pal/unix/thread.rs:108:17
  29:     0x7fb870e90272 - start_thread
  30:     0x7fb870f0bdec - clone3
  31:                0x0 - <unknown>

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the panic from callHierarchy/outgoingCalls at ripgrep's crates/core/messages.rs line 124 using the reported rust-analyzer setup. Start with handlers::request::handle_call_hierarchy_outgoing, then inspect lsp::to_proto::range and line_index::LineIndex::line_col. Done means the request no longer panics and returns a valid outgoing-call result.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
devtools
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.