Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Index out of bounds panic with 'rustcSource' in new release #12043

Closed
tedinski opened this issue Apr 20, 2022 · 1 comment · Fixed by #12044
Closed

Index out of bounds panic with 'rustcSource' in new release #12043

tedinski opened this issue Apr 20, 2022 · 1 comment · Fixed by #12044

Comments

@tedinski
Copy link
Contributor

rust-analyzer has begun crash-looping in vscode for me:

thread 'main' panicked at 'index out of bounds: the len is 122 but the index is 123', crates/project_model/src/workspace.rs:762:78
stack backtrace:
   0: rust_begin_unwind
             at /rustc/7737e0b5c4103216d6fd8cf941b7ab9bdbaace7c/library/std/src/panicking.rs:584:5
   1: core::panicking::panic_fmt
             at /rustc/7737e0b5c4103216d6fd8cf941b7ab9bdbaace7c/library/core/src/panicking.rs:143:14
   2: core::panicking::panic_bounds_check
             at /rustc/7737e0b5c4103216d6fd8cf941b7ab9bdbaace7c/library/core/src/panicking.rs:85:5
   3: project_model::workspace::ProjectWorkspace::to_crate_graph
   4: rust_analyzer::reload::<impl rust_analyzer::global_state::GlobalState>::switch_workspaces
   5: rust_analyzer::main_loop::<impl rust_analyzer::global_state::GlobalState>::handle_event
   6: rust_analyzer::main_loop::<impl rust_analyzer::global_state::GlobalState>::run
   7: rust_analyzer::main_loop::main_loop
   8: rust_analyzer::run_server
   9: rust_analyzer::main
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(..)"', /home/runner/.cargo/registry/src/github.com-1ecc6299db9ec823/lsp-server-0.6.0/src/stdio.rs:29:37
stack backtrace:
   0: rust_begin_unwind
             at /rustc/7737e0b5c4103216d6fd8cf941b7ab9bdbaace7c/library/std/src/panicking.rs:584:5
   1: core::panicking::panic_fmt
             at /rustc/7737e0b5c4103216d6fd8cf941b7ab9bdbaace7c/library/core/src/panicking.rs:143:14
   2: core::result::unwrap_failed
             at /rustc/7737e0b5c4103216d6fd8cf941b7ab9bdbaace7c/library/core/src/result.rs:1749:5

rust-analyzer version: 65fbe0a 2022-04-18 nightly, and 65fbe0a 2022-04-18 stable. Was not in previous stable release.
rustc version: rustc 1.61.0-nightly (5f3700105 2022-03-22)
relevant settings:

Can be reproduced with this project: https://github.com/model-checking/kani

Notably uses these rust-analyzer settings in vscode:

    "rust-analyzer.rustcSource": "discover",

This, together with a rust-toolchain.toml specifying the above nightly release, supports src/kani-compiler/Cargo.toml which includes:

[package.metadata.rust-analyzer]
# This package uses rustc crates.
rustc_private=true

Cause

The line of code triggering the panic was introduced with #11964

I wonder if possibly that line of code should be rustc_workspace[pkg] and not cargo[pkg]?

Temporary workaround

Removing "rust-analyzer.rustcSource": "discover", from vscode config removes my ability to jump to rustc source code, but stops the crash loop.

@zhassan-aws
Copy link

zhassan-aws commented Apr 20, 2022

Here's a minimal reproducer:

cargo new ra-panic && cd ra-panic
echo '[toolchain]' > rust-toolchain.toml
echo 'channel = "nightly-2022-03-23"' >> rust-toolchain.toml
echo 'components = ["llvm-tools-preview", "rustc-dev", "rust-src", "rustfmt"]' >> rust-toolchain.toml
echo '[package.metadata.rust-analyzer]' >> Cargo.toml
echo 'rustc_private=true' >> Cargo.toml

Then open the ra-panic directory in VSCode and open src/main.rs

The panic only occurs if the settings.json has this setting:

    "rust-analyzer.rustcSource": "discover",

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants