rust-lang / rust-lang/rust-analyzer

Thread 'Worker' panicked at "Bad offset"

Open
#16,171 0 comments 4 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: 0.4.1775-standalone

rustc version: rustc 1.74.1 (a28077b28 2023-12-04)

rust-analyzer suddenly showed a crash notification. Unfortunately it's unclear how I even triggered it or how I could reproduce it again. Maybe you can still glean something from the output.

Panic context:
> 
version: 0.4.1775-standalone
request: inlayHint/resolve InlayHint {
    position: Position {
        line: 174,
        character: 26,
    },
    label: LabelParts(
        [
            InlayHintLabelPart {
                value: "init:",
                tooltip: None,
                location: None,
                command: None,
            },
        ],
    ),
    kind: Some(
        Parameter,
    ),
    text_edits: None,
    tooltip: None,
    padding_left: Some(
        false,
    ),
    padding_right: Some(
        true,
    ),
    data: Some(
        Object {
            "file_id": Number(0),
        },
    ),
}

thread 'Worker' panicked at /github/home/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rowan-0.15.15/src/cursor.rs:751:9:
Bad offset: range 0..4584 offset 4602
stack backtrace:
   0: rust_begin_unwind
             at /rustc/a28077b28a02b92985b3a3faecf92813155f1ea1/library/std/src/panicking.rs:597:5
   1: core::panicking::panic_fmt
             at /rustc/a28077b28a02b92985b3a3faecf92813155f1ea1/library/core/src/panicking.rs:72:14
   2: rowan::cursor::SyntaxNode::token_at_offset
   3: ide::inlay_hints::inlay_hints
   4: salsa::Cancelled::catch
   5: ide::Analysis::inlay_hints
   6: rust_analyzer::handlers::request::handle_inlay_hints_resolve
   7: std::panicking::try
   8: core::ops::function::FnOnce::call_once{{vtable.shim}}
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
Panic context:
> 
version: 0.4.1775-standalone
request: inlayHint/resolve InlayHint {
    position: Position {
        line: 173,
        character: 30,
    },
    label: LabelParts(
        [
            InlayHintLabelPart {
                value: ": &&",
                tooltip: None,
                location: None,
                command: None,
            },
            InlayHintLabelPart {
                value: "PartNumber",
                tooltip: None,
                location: None,
                command: None,
            },
            InlayHintLabelPart {
                value: "",
                tooltip: None,
                location: None,
                command: None,
            },
        ],
    ),
    kind: Some(
        Type,
    ),
    text_edits: None,
    tooltip: None,
    padding_left: Some(
        false,
    ),
    padding_right: Some(
        false,
    ),
    data: Some(
        Object {
            "file_id": Number(0),
        },
    ),
}

thread 'Worker' panicked at /github/home/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rowan-0.15.15/src/cursor.rs:751:9:
Bad offset: range 0..4584 offset 4587
stack backtrace:
   0: rust_begin_unwind
             at /rustc/a28077b28a02b92985b3a3faecf92813155f1ea1/library/std/src/panicking.rs:597:5
   1: core::panicking::panic_fmt
             at /rustc/a28077b28a02b92985b3a3faecf92813155f1ea1/library/core/src/panicking.rs:72:14
   2: rowan::cursor::SyntaxNode::token_at_offset
   3: ide::inlay_hints::inlay_hints
   4: salsa::Cancelled::catch
   5: ide::Analysis::inlay_hints
   6: rust_analyzer::handlers::request::handle_inlay_hints_resolve
   7: std::panicking::try
   8: core::ops::function::FnOnce::call_once{{vtable.shim}}
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
[Error - 8:07:33 PM] Request inlayHint/resolve failed.
  Message: request handler panicked: Bad offset: range 0..4584 offset 4587
  Code: -32603 
Panic context:
> 
version: 0.4.1775-standalone
request: inlayHint/resolve InlayHint {
    position: Position {
        line: 173,
        character: 30,
    },
    label: LabelParts(
        [
            InlayHintLabelPart {
                value: ": &&",
                tooltip: None,
                location: None,
                command: None,
            },
            InlayHintLabelPart {
                value: "PartNumber",
                tooltip: None,
                location: None,
                command: None,
            },
            InlayHintLabelPart {
                value: "",
                tooltip: None,
                location: None,
                command: None,
            },
        ],
    ),
    kind: Some(
        Type,
    ),
    text_edits: None,
    tooltip: None,
    padding_left: Some(
        false,
    ),
    padding_right: Some(
        false,
    ),
    data: Some(
        Object {
            "file_id": Number(0),
        },
    ),
}

thread 'Worker' panicked at /github/home/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rowan-0.15.15/src/cursor.rs:751:9:
Bad offset: range 0..4584 offset 4587
stack backtrace:
   0: rust_begin_unwind
             at /rustc/a28077b28a02b92985b3a3faecf92813155f1ea1/library/std/src/panicking.rs:597:5
   1: core::panicking::panic_fmt
             at /rustc/a28077b28a02b92985b3a3faecf92813155f1ea1/library/core/src/panicking.rs:72:14
   2: rowan::cursor::SyntaxNode::token_at_offset
   3: ide::inlay_hints::inlay_hints
   4: salsa::Cancelled::catch
   5: ide::Analysis::inlay_hints
   6: rust_analyzer::handlers::request::handle_inlay_hints_resolve
   7: std::panicking::try
   8: core::ops::function::FnOnce::call_once{{vtable.shim}}
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
[Error - 8:07:33 PM] Request inlayHint/resolve failed.
  Message: request handler panicked: Bad offset: range 0..4584 offset 4587
  Code: -32603 
Panic context:
> 
version: 0.4.1775-standalone
request: inlayHint/resolve InlayHint {
    position: Position {
        line: 173,
        character: 30,
    },
    label: LabelParts(
        [
            InlayHintLabelPart {
                value: ": &&",
                tooltip: None,
                location: None,
                command: None,
            },
            InlayHintLabelPart {
                value: "PartNumber",
                tooltip: None,
                location: None,
                command: None,
            },
            InlayHintLabelPart {
                value: "",
                tooltip: None,
                location: None,
                command: None,
            },
        ],
    ),
    kind: Some(
        Type,
    ),
    text_edits: None,
    tooltip: None,
    padding_left: Some(
        false,
    ),
    padding_right: Some(
        false,
    ),
    data: Some(
        Object {
            "file_id": Number(0),
        },
    ),
}

thread 'Worker' panicked at /github/home/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rowan-0.15.15/src/cursor.rs:751:9:
Bad offset: range 0..4584 offset 4587
stack backtrace:
   0: rust_begin_unwind
             at /rustc/a28077b28a02b92985b3a3faecf92813155f1ea1/library/std/src/panicking.rs:597:5
   1: core::panicking::panic_fmt
             at /rustc/a28077b28a02b92985b3a3faecf92813155f1ea1/library/core/src/panicking.rs:72:14
   2: rowan::cursor::SyntaxNode::token_at_offset
   3: ide::inlay_hints::inlay_hints
   4: salsa::Cancelled::catch
   5: ide::Analysis::inlay_hints
   6: rust_analyzer::handlers::request::handle_inlay_hints_resolve
   7: std::panicking::try
   8: core::ops::function::FnOnce::call_once{{vtable.shim}}
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
[Error - 8:07:33 PM] Request inlayHint/resolve failed.
  Message: request handler panicked: Bad offset: range 0..4584 offset 4587
  Code: -32603 

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

Start with the reported inlayHint/resolve path through ide::inlay_hints and rust_analyzer::handlers::request::handle_inlay_hints_resolve, then inspect rowan's cursor.rs at line 751. The report has no reproduction steps or test location, so first determine how the reported offsets exceed the syntax-node range. Done means the request no longer panics with Bad offset for the affected case.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
devtools
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.