Skip to content

LspServer panicked at 'index out of bounds: the len is 0 but the index is 0' #12879

@ralpha

Description

@ralpha

Just opened a project in VSCode and it showed a message "The Rust Analyzer Language Server server crashed 5 times in the last 3 minutes. The server will not be restarted.".

Here is the output:

thread 'LspServer' panicked at 'index out of bounds: the len is 0 but the index is 0', crates/rust-analyzer/src/reload.rs:358:41
stack backtrace:
   0: rust_begin_unwind
             at /rustc/e092d0b6b43f2de967af0887873151bb1c0b18d3/library/std/src/panicking.rs:584:5
   1: core::panicking::panic_fmt
             at /rustc/e092d0b6b43f2de967af0887873151bb1c0b18d3/library/core/src/panicking.rs:142:14
   2: core::panicking::panic_bounds_check
             at /rustc/e092d0b6b43f2de967af0887873151bb1c0b18d3/library/core/src/panicking.rs:84:5
   3: rust_analyzer::reload::<impl rust_analyzer::global_state::GlobalState>::switch_workspaces
   4: rust_analyzer::main_loop::<impl rust_analyzer::global_state::GlobalState>::handle_event
   5: rust_analyzer::main_loop::<impl rust_analyzer::global_state::GlobalState>::run
   6: rust_analyzer::main_loop::main_loop
   7: rust_analyzer::run_server
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
thread '<unnamed>' panicked at 'called `Result::unwrap()` on an `Err` value: "SendError(..)"', lib/lsp-server/src/stdio.rs:29:37
stack backtrace:
   0: rust_begin_unwind
             at /rustc/e092d0b6b43f2de967af0887873151bb1c0b18d3/library/std/src/panicking.rs:584:5
   1: core::panicking::panic_fmt
             at /rustc/e092d0b6b43f2de967af0887873151bb1c0b18d3/library/core/src/panicking.rs:142:14
   2: core::result::unwrap_failed
             at /rustc/e092d0b6b43f2de967af0887873151bb1c0b18d3/library/core/src/result.rs:1785:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
[Info  - 1:58:21 PM] Connection to server got closed. Server will restart.
[Error - 1:58:21 PM] Request textDocument/foldingRange failed.
Error: Connection got disposed.
	at Object.dispose (/home/user/.vscode/extensions/rust-lang.rust-analyzer-0.4.1141-linux-x64/out/main.js:29:4495)
	at Object.dispose (/home/user/.vscode/extensions/rust-lang.rust-analyzer-0.4.1141-linux-x64/out/main.js:34:10387)
	at _l.handleConnectionClosed (/home/user/.vscode/extensions/rust-lang.rust-analyzer-0.4.1141-linux-x64/out/main.js:36:10613)
	at _l.handleConnectionClosed (/home/user/.vscode/extensions/rust-lang.rust-analyzer-0.4.1141-linux-x64/out/main.js:39:49379)
	at t (/home/user/.vscode/extensions/rust-lang.rust-analyzer-0.4.1141-linux-x64/out/main.js:36:10321)
	at Pa.invoke (/home/user/.vscode/extensions/rust-lang.rust-analyzer-0.4.1141-linux-x64/out/main.js:2:14370)
	at Br.fire (/home/user/.vscode/extensions/rust-lang.rust-analyzer-0.4.1141-linux-x64/out/main.js:2:15139)
	at Nt (/home/user/.vscode/extensions/rust-lang.rust-analyzer-0.4.1141-linux-x64/out/main.js:3:6314)
	at Pa.invoke (/home/user/.vscode/extensions/rust-lang.rust-analyzer-0.4.1141-linux-x64/out/main.js:2:14370)
	at Br.fire (/home/user/.vscode/extensions/rust-lang.rust-analyzer-0.4.1141-linux-x64/out/main.js:2:15139)
	at xo.fireClose (/home/user/.vscode/extensions/rust-lang.rust-analyzer-0.4.1141-linux-x64/out/main.js:2:17394)
	at Socket.<anonymous> (/home/user/.vscode/extensions/rust-lang.rust-analyzer-0.4.1141-linux-x64/out/main.js:2:18924)
	at Socket.emit (node:events:402:35)
	at Pipe.<anonymous> (node:net:687:12)
[Error - 1:58:21 PM] Request textDocument/hover failed.
Error: Connection got disposed.
	at Object.dispose (/home/user/.vscode/extensions/rust-lang.rust-analyzer-0.4.1141-linux-x64/out/main.js:29:4495)
	at Object.dispose (/home/user/.vscode/extensions/rust-lang.rust-analyzer-0.4.1141-linux-x64/out/main.js:34:10387)
	at _l.handleConnectionClosed (/home/user/.vscode/extensions/rust-lang.rust-analyzer-0.4.1141-linux-x64/out/main.js:36:10613)
	at _l.handleConnectionClosed (/home/user/.vscode/extensions/rust-lang.rust-analyzer-0.4.1141-linux-x64/out/main.js:39:49379)
	at t (/home/user/.vscode/extensions/rust-lang.rust-analyzer-0.4.1141-linux-x64/out/main.js:36:10321)
	at Pa.invoke (/home/user/.vscode/extensions/rust-lang.rust-analyzer-0.4.1141-linux-x64/out/main.js:2:14370)
	at Br.fire (/home/user/.vscode/extensions/rust-lang.rust-analyzer-0.4.1141-linux-x64/out/main.js:2:15139)
	at Nt (/home/user/.vscode/extensions/rust-lang.rust-analyzer-0.4.1141-linux-x64/out/main.js:3:6314)
	at Pa.invoke (/home/user/.vscode/extensions/rust-lang.rust-analyzer-0.4.1141-linux-x64/out/main.js:2:14370)
	at Br.fire (/home/user/.vscode/extensions/rust-lang.rust-analyzer-0.4.1141-linux-x64/out/main.js:2:15139)
	at xo.fireClose (/home/user/.vscode/extensions/rust-lang.rust-analyzer-0.4.1141-linux-x64/out/main.js:2:17394)
	at Socket.<anonymous> (/home/user/.vscode/extensions/rust-lang.rust-analyzer-0.4.1141-linux-x64/out/main.js:2:18924)
	at Socket.emit (node:events:402:35)
	at Pipe.<anonymous> (node:net:687:12)
[Error - 1:58:21 PM] Request textDocument/codeLens failed.
Error: Connection got disposed.
	at Object.dispose (/home/user/.vscode/extensions/rust-lang.rust-analyzer-0.4.1141-linux-x64/out/main.js:29:4495)
	at Object.dispose (/home/user/.vscode/extensions/rust-lang.rust-analyzer-0.4.1141-linux-x64/out/main.js:34:10387)
	at _l.handleConnectionClosed (/home/user/.vscode/extensions/rust-lang.rust-analyzer-0.4.1141-linux-x64/out/main.js:36:10613)
	at _l.handleConnectionClosed (/home/user/.vscode/extensions/rust-lang.rust-analyzer-0.4.1141-linux-x64/out/main.js:39:49379)
	at t (/home/user/.vscode/extensions/rust-lang.rust-analyzer-0.4.1141-linux-x64/out/main.js:36:10321)
	at Pa.invoke (/home/user/.vscode/extensions/rust-lang.rust-analyzer-0.4.1141-linux-x64/out/main.js:2:14370)
	at Br.fire (/home/user/.vscode/extensions/rust-lang.rust-analyzer-0.4.1141-linux-x64/out/main.js:2:15139)
	at Nt (/home/user/.vscode/extensions/rust-lang.rust-analyzer-0.4.1141-linux-x64/out/main.js:3:6314)
	at Pa.invoke (/home/user/.vscode/extensions/rust-lang.rust-analyzer-0.4.1141-linux-x64/out/main.js:2:14370)
	at Br.fire (/home/user/.vscode/extensions/rust-lang.rust-analyzer-0.4.1141-linux-x64/out/main.js:2:15139)
	at xo.fireClose (/home/user/.vscode/extensions/rust-lang.rust-analyzer-0.4.1141-linux-x64/out/main.js:2:17394)
	at Socket.<anonymous> (/home/user/.vscode/extensions/rust-lang.rust-analyzer-0.4.1141-linux-x64/out/main.js:2:18924)
	at Socket.emit (node:events:402:35)
	at Pipe.<anonymous> (node:net:687:12)
thread 'LspServer' panicked at 'index out of bounds: the len is 0 but the index is 0', crates/rust-analyzer/src/reload.rs:358:41
stack backtrace:
   0: rust_begin_unwind
             at /rustc/e092d0b6b43f2de967af0887873151bb1c0b18d3/library/std/src/panicking.rs:584:5
   1: core::panicking::panic_fmt
             at /rustc/e092d0b6b43f2de967af0887873151bb1c0b18d3/library/core/src/panicking.rs:142:14
   2: core::panicking::panic_bounds_check
             at /rustc/e092d0b6b43f2de967af0887873151bb1c0b18d3/library/core/src/panicking.rs:84:5
   3: rust_analyzer::reload::<impl rust_analyzer::global_state::GlobalState>::switch_workspaces
   4: rust_analyzer::main_loop::<impl rust_analyzer::global_state::GlobalState>::handle_event
   5: rust_analyzer::main_loop::<impl rust_analyzer::global_state::GlobalState>::run
   6: rust_analyzer::main_loop::main_loop
   7: rust_analyzer::run_server
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
thread '<unnamed>' panicked at 'called `Result::unwrap()` on an `Err` value: "SendError(..)"', lib/lsp-server/src/stdio.rs:29:37
stack backtrace:
   0: rust_begin_unwind
             at /rustc/e092d0b6b43f2de967af0887873151bb1c0b18d3/library/std/src/panicking.rs:584:5
   1: core::panicking::panic_fmt
             at /rustc/e092d0b6b43f2de967af0887873151bb1c0b18d3/library/core/src/panicking.rs:142:14
   2: core::result::unwrap_failed
             at /rustc/e092d0b6b43f2de967af0887873151bb1c0b18d3/library/core/src/result.rs:1785:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
[Info  - 1:58:22 PM] Connection to server got closed. Server will restart.
thread 'LspServer' panicked at 'index out of bounds: the len is 0 but the index is 0', crates/rust-analyzer/src/reload.rs:358:41
stack backtrace:
   0: rust_begin_unwind
             at /rustc/e092d0b6b43f2de967af0887873151bb1c0b18d3/library/std/src/panicking.rs:584:5
   1: core::panicking::panic_fmt
             at /rustc/e092d0b6b43f2de967af0887873151bb1c0b18d3/library/core/src/panicking.rs:142:14
   2: core::panicking::panic_bounds_check
             at /rustc/e092d0b6b43f2de967af0887873151bb1c0b18d3/library/core/src/panicking.rs:84:5
   3: rust_analyzer::reload::<impl rust_analyzer::global_state::GlobalState>::switch_workspaces
   4: rust_analyzer::main_loop::<impl rust_analyzer::global_state::GlobalState>::handle_event
   5: rust_analyzer::main_loop::<impl rust_analyzer::global_state::GlobalState>::run
   6: rust_analyzer::main_loop::main_loop
   7: rust_analyzer::run_server
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
thread '<unnamed>' panicked at 'called `Result::unwrap()` on an `Err` value: "SendError(..)"', lib/lsp-server/src/stdio.rs:29:37
stack backtrace:
   0: rust_begin_unwind
             at /rustc/e092d0b6b43f2de967af0887873151bb1c0b18d3/library/std/src/panicking.rs:584:5
   1: core::panicking::panic_fmt
             at /rustc/e092d0b6b43f2de967af0887873151bb1c0b18d3/library/core/src/panicking.rs:142:14
   2: core::result::unwrap_failed
             at /rustc/e092d0b6b43f2de967af0887873151bb1c0b18d3/library/core/src/result.rs:1785:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
[Info  - 1:58:23 PM] Connection to server got closed. Server will restart.
thread 'LspServer' panicked at 'index out of bounds: the len is 0 but the index is 0', crates/rust-analyzer/src/reload.rs:358:41
stack backtrace:
   0: rust_begin_unwind
             at /rustc/e092d0b6b43f2de967af0887873151bb1c0b18d3/library/std/src/panicking.rs:584:5
   1: core::panicking::panic_fmt
             at /rustc/e092d0b6b43f2de967af0887873151bb1c0b18d3/library/core/src/panicking.rs:142:14
   2: core::panicking::panic_bounds_check
             at /rustc/e092d0b6b43f2de967af0887873151bb1c0b18d3/library/core/src/panicking.rs:84:5
   3: rust_analyzer::reload::<impl rust_analyzer::global_state::GlobalState>::switch_workspaces
   4: rust_analyzer::main_loop::<impl rust_analyzer::global_state::GlobalState>::handle_event
   5: rust_analyzer::main_loop::<impl rust_analyzer::global_state::GlobalState>::run
   6: rust_analyzer::main_loop::main_loop
   7: rust_analyzer::run_server
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
thread '<unnamed>' panicked at 'called `Result::unwrap()` on an `Err` value: "SendError(..)"', lib/lsp-server/src/stdio.rs:29:37
stack backtrace:
   0: rust_begin_unwind
             at /rustc/e092d0b6b43f2de967af0887873151bb1c0b18d3/library/std/src/panicking.rs:584:5
   1: core::panicking::panic_fmt
             at /rustc/e092d0b6b43f2de967af0887873151bb1c0b18d3/library/core/src/panicking.rs:142:14
   2: core::result::unwrap_failed
             at /rustc/e092d0b6b43f2de967af0887873151bb1c0b18d3/library/core/src/result.rs:1785:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
[Info  - 1:58:24 PM] Connection to server got closed. Server will restart.
thread 'LspServer' panicked at 'index out of bounds: the len is 0 but the index is 0', crates/rust-analyzer/src/reload.rs:358:41
stack backtrace:
   0: rust_begin_unwind
             at /rustc/e092d0b6b43f2de967af0887873151bb1c0b18d3/library/std/src/panicking.rs:584:5
   1: core::panicking::panic_fmt
             at /rustc/e092d0b6b43f2de967af0887873151bb1c0b18d3/library/core/src/panicking.rs:142:14
   2: core::panicking::panic_bounds_check
             at /rustc/e092d0b6b43f2de967af0887873151bb1c0b18d3/library/core/src/panicking.rs:84:5
   3: rust_analyzer::reload::<impl rust_analyzer::global_state::GlobalState>::switch_workspaces
   4: rust_analyzer::main_loop::<impl rust_analyzer::global_state::GlobalState>::handle_event
   5: rust_analyzer::main_loop::<impl rust_analyzer::global_state::GlobalState>::run
   6: rust_analyzer::main_loop::main_loop
   7: rust_analyzer::run_server
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
thread '<unnamed>' panicked at 'called `Result::unwrap()` on an `Err` value: "SendError(..)"', lib/lsp-server/src/stdio.rs:29:37
stack backtrace:
   0: rust_begin_unwind
             at /rustc/e092d0b6b43f2de967af0887873151bb1c0b18d3/library/std/src/panicking.rs:584:5
   1: core::panicking::panic_fmt
             at /rustc/e092d0b6b43f2de967af0887873151bb1c0b18d3/library/core/src/panicking.rs:142:14
   2: core::result::unwrap_failed
             at /rustc/e092d0b6b43f2de967af0887873151bb1c0b18d3/library/core/src/result.rs:1785:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
[Error - 1:58:25 PM] The Rust Analyzer Language Server server crashed 5 times in the last 3 minutes. The server will not be restarted. See the output for more information.

Issue started since today. (was working fine 20 hours ago)
When I reload the same errors come up.
Opening a different project it gives the same result. (crashed with same error)
I switched to release version for now to fix the issue.

I hope this helps with debugging the issue.

rust-analyzer version: rust-analyzer version: 0.4.1141-standalone (0b1ed70 2022-07-25) (Pre-release)

rustc version: rustc 1.61.0 (fe5b13d68 2022-05-18)

relevant settings: NA

Activity

self-assigned this
on Jul 26, 2022
Veykril

Veykril commented on Jul 26, 2022

@Veykril
Member

Ye that was an oversight on my part, if proc-macros are disabled we just panic

ralpha

ralpha commented on Jul 26, 2022

@ralpha
Author

Ye that was an oversight on my part, if proc-macros are disabled we just panic

Yeah that can be it, still have proc macros disabled because of a previous issue, from quite some time ago. Have never re-enabled it.
But at least we found a bug that way :)

added a commit that references this issue on Jul 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

    Participants

    @ralpha@Veykril

    Issue actions

      LspServer panicked at 'index out of bounds: the len is 0 but the index is 0' · Issue #12879 · rust-lang/rust-analyzer