chanhx / crabviz

🦀 A LSP-based interative call graph generator
Apache License 2.0
674 stars 22 forks source link

panic while generating a call graph #17

Closed r4ntix closed 8 months ago

r4ntix commented 1 year ago

there is a panic while generating a call graph:

Panic context:
> 
version: 0.3.1631-standalone (83b3ba1b8 2023-08-19)
request: callHierarchy/outgoingCalls CallHierarchyOutgoingCallsParams {
    item: CallHierarchyItem {
        name: "output_record_batch_and_reset",
        kind: Function,
        tags: None,
        detail: Some(
            "fn output_record_batch_and_reset(&mut self) -> Result<RecordBatch>",
        ),
        uri: Url {
            scheme: "file",
            cannot_be_a_base: false,
            username: "",
            password: None,
            host: None,
            port: None,
            path: "/Users/r4ntix/Workspace/github/arrow-datafusion/datafusion/core/src/physical_plan/joins/sort_merge_join.rs",
            query: None,
            fragment: None,
        },
        range: Range {
            start: Position {
                line: 1242,
                character: 4,
            },
            end: Position {
                line: 1249,
                character: 5,
            },
        },
        selection_range: Range {
            start: Position {
                line: 1242,
                character: 7,
            },
            end: Position {
                line: 1242,
                character: 36,
            },
        },
        data: None,
    },
    work_done_progress_params: WorkDoneProgressParams {
        work_done_token: None,
    },
    partial_result_params: PartialResultParams {
        partial_result_token: None,
    },
}

thread 'Worker' panicked at 'invalid offset', /Users/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/line-index-0.1.0-pre.1/src/lib.rs:148:35
stack backtrace:
   0: _rust_begin_unwind
   1: core::panicking::panic_fmt
   2: core::option::expect_failed
   3: rust_analyzer::to_proto::range
   4: <core::iter::adapters::map::Map<I,F> as core::iter::traits::iterator::Iterator>::fold
   5: alloc::vec::in_place_collect::<impl alloc::vec::spec_from_iter::SpecFromIter<T,I> for alloc::vec::Vec<T>>::from_iter
   6: rust_analyzer::handlers::request::handle_call_hierarchy_outgoing
   7: core::ops::function::FnOnce::call_once{{vtable.shim}}
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
[Error - 17:33:17] Request callHierarchy/outgoingCalls failed.
  Message: request handler panicked: invalid offset
  Code: -32603 
chanhx commented 9 months ago

It is a RA bug (rust-lang/rust-analyzer#14839). You can check it by "Show Call Hierarchy", and switch to show outgoing calls.

image
stefnotch commented 4 months ago

Update from the future: https://github.com/rust-lang/rust-analyzer/issues/14839 seems to have been fixed and closed.

Hopefully that means that the next weekly release of Rust Analyzer will include a fix :)

stefnotch commented 4 months ago

@chanhx I've updated to the newest Rust analyzer version and can still reproduce this issue with https://github.com/bevyengine/naga_oil .

But it doesn't happen with all functions. It does happen with this one, and many others. https://github.com/bevyengine/naga_oil/blob/37a472c9dadde7f90504c24d0e3680821d54380a/src/compose/mod.rs#L277

Is that enough for you to reproduce and investigate it, or should I prepare a minimal sample and write up a proper bug report?

chanhx commented 4 months ago

The bug still exists in the newest version (v0.4.1951).

Did you see an error notification sourced from RA?

image

Or you can right-click a function to display the context menu and select "Show Call Hierarchy", and then switch to show outgoing calls to confirm that.

image