Skip to content

Index out of bounds panic in line index #10138

Closed
@tvallotton

Description

@tvallotton

Rust analyzer panicked while commenting some code. I haven't been able to reproduce the issue, but I decided to give you the output just in case. I was commenting either the ast::Statement enum or its Display implementation. If it helps the code I had can be found at https://github.com/tvallotton/sqlparser-rs/tree/rust-analyzer-panic.

Panic context:
> 
version: d15f646ff 2021-08-30 stable
request: codeLens/resolve CodeLens {
    range: Range {
        start: Position {
            line: 1351,
            character: 11,
        },
        end: Position {
            line: 1351,
            character: 19,
        },
    },
    command: None,
    data: Some(
        Object({
            "impls": Object({
                "textDocument": Object({
                    "uri": String(
                        "file:///Users/tomas/Documents/sqlparser-rs/src/ast/mod.rs",
                    ),
                }),
                "position": Object({
                    "line": Number(
                        1351,
                    ),
                    "character": Number(
                        11,
                    ),
                }),
            }),
        }),
    ),
}

thread '<unnamed>' panicked at 'index out of bounds: the len is 1153 but the index is 1351', crates/ide_db/src/line_index.rs:106:9
stack backtrace:
   0: _rust_begin_unwind
   1: core::panicking::panic_fmt
   2: core::panicking::panic_bounds_check
   3: rust_analyzer::from_proto::text_range
   4: rust_analyzer::handlers::handle_code_lens_resolve
   5: rust_analyzer::dispatch::RequestDispatcher::on::{{closure}}::{{closure}}
   6: <F as threadpool::FnBox>::call_box
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
[Error - 11:44:57 AM] Request codeLens/resolve failed.
  Message: server panicked: index out of bounds: the len is 1153 but the index is 1351
  Code: -32603 
Panic context:
> 
version: d15f646ff 2021-08-30 stable
request: codeLens/resolve CodeLens {
    range: Range {
        start: Position {
            line: 1334,
            character: 9,
        },
        end: Position {
            line: 1334,
            character: 20,
        },
    },
    command: None,
    data: Some(
        Object({
            "impls": Object({
                "textDocument": Object({
                    "uri": String(
                        "file:///Users/tomas/Documents/sqlparser-rs/src/ast/mod.rs",
                    ),
                }),
                "position": Object({
                    "line": Number(
                        1334,
                    ),
                    "character": Number(
                        9,
                    ),
                }),
            }),
        }),
    ),
}

thread '<unnamed>' panicked at 'index out of bounds: the len is 1153 but the index is 1334', crates/ide_db/src/line_index.rs:106:9
Panic context:
> 
version: d15f646ff 2021-08-30 stable
request: codeLens/resolve CodeLens {
    range: Range {
        start: Position {
            line: 1321,
            character: 11,
        },
        end: Position {
            line: 1321,
            character: 21,
        },
    },
    command: None,
    data: Some(
        Object({
            "impls": Object({
                "textDocument": Object({
                    "uri": String(
                        "file:///Users/tomas/Documents/sqlparser-rs/src/ast/mod.rs",
                    ),
                }),
                "position": Object({
                    "line": Number(
                        1321,
                    ),
                    "character": Number(
                        11,
                    ),
                }),
            }),
        }),
    ),
}

thread '<unnamed>' panicked at 'index out of bounds: the len is 1153 but the index is 1321', crates/ide_db/src/line_index.rs:106:9
stack backtrace:
Panic context:
> 
version: d15f646ff 2021-08-30 stable
request: codeLens/resolve CodeLens {
    range: Range {
        start: Position {
            line: 1351,
            character: 11,
        },
        end: Position {
            line: 1351,
            character: 19,
        },
    },
    command: None,
    data: Some(
        Object({
            "impls": Object({
                "textDocument": Object({
                    "uri": String(
                        "file:///Users/tomas/Documents/sqlparser-rs/src/ast/mod.rs",
                    ),
                }),
                "position": Object({
                    "line": Number(
                        1351,
                    ),
                    "character": Number(
                        11,
                    ),
                }),
            }),
        }),
    ),
}

thread '<unnamed>' panicked at 'index out of bounds: the len is 1153 but the index is 1351', crates/ide_db/src/line_index.rs:   0: _rust_begin_unwind106
 :  91: 
core::panicking::panic_fmt
   2: core::panicking::panic_bounds_check
   3: rust_analyzer::from_proto::text_range
   4: rust_analyzer::handlers::handle_code_lens_resolve
   5: rust_analyzer::dispatch::RequestDispatcher::on::{{closure}}::{{closure}}
   6: <F as threadpool::FnBox>::call_box
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
stack backtrace:
   0: _rust_begin_unwind
   1: core::panicking::panic_fmt
   2: core::panicking::panic_bounds_check
   3: rust_analyzer::from_proto::text_range
   4: rust_analyzer::handlers::handle_code_lens_resolve
   5: rust_analyzer::dispatch::RequestDispatcher::on::{{closure}}::{{closure}}
   6: <F as threadpool::FnBox>::call_box
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
stack backtrace:
   0: _rust_begin_unwind
   1: core::panicking::panic_fmt
   2: core::panicking::panic_bounds_check
   3: rust_analyzer::from_proto::text_range
   4: rust_analyzer::handlers::handle_code_lens_resolve
   5: rust_analyzer::dispatch::RequestDispatcher::on::{{closure}[Error - 11:45:12 AM] Request codeLens/resolve failed.
  Message: server panicked: index out of bounds: the len is 1153 but the index is 1334
  Code: -32603 
}::{{closure}}
   6: <F as threadpool::FnBox>::call_box
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
[Error - 11:45:12 AM] Request codeLens/resolve failed.
  Message: server panicked: index out of bounds: the len is 1153 but the index is 1321
  Code: -32603 
[Error - 11:45:12 AM] Request codeLens/resolve failed.
  Message: server panicked: index out of bounds: the len is 1153 but the index is 1351
  Code: -32603 

Metadata

Metadata

Assignees

No one assigned

    Labels

    Broken WindowBugs / technical debt to be addressed immediately

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions