Skip to content

Thread panics on the assertion of "id.index() < Self::MAX_FILE_ID" #16118

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

Closed
rainingdays opened this issue Dec 14, 2023 · 4 comments · Fixed by #16130
Closed

Thread panics on the assertion of "id.index() < Self::MAX_FILE_ID" #16118

rainingdays opened this issue Dec 14, 2023 · 4 comments · Fixed by #16130
Assignees
Labels
C-bug Category: bug I-panic

Comments

@rainingdays
Copy link

rainingdays commented Dec 14, 2023

rust-analyzer version: rust-analyzer version: 0.3.1766-standalone (457b966 2023-12-10)

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

relevant settings: Running within VSCode, on Windows 10 Pro 22H2, build: 19045.3803

Rust-analyzer thread panics on the assertion:

Panic context:
> fetch_native_diagnostics

thread 'Worker' panicked at crates\base-db\src\span.rs:154:9:
assertion failed: id.index() < Self::MAX_FILE_ID
stack backtrace:
   0: std::panicking::begin_panic_handler
             at /rustc/a28077b28a02b92985b3a3faecf92813155f1ea1/library\std\src\panicking.rs:597
   1: core::panicking::panic_fmt
             at /rustc/a28077b28a02b92985b3a3faecf92813155f1ea1/library\core\src\panicking.rs:72
   2: core::panicking::panic
             at /rustc/a28077b28a02b92985b3a3faecf92813155f1ea1/library\core\src\panicking.rs:127
   3: hir_expand::ExpansionInfo::map_node_range_up
   4: hir_expand::files::InFileWrapper<base_db::span::HirFileId,&rowan::api::SyntaxNode<syntax::syntax_node::RustLanguage>>::original_file_range
   5: hir::semantics::SemanticsImpl::diagnostics_display_range
   6: ide_diagnostics::adjusted_display_range
   7: ide_diagnostics::handlers::type_mismatch::type_mismatch
   8: ide_diagnostics::diagnostics
   9: salsa::Cancelled::catch
  10: ide::Analysis::diagnostics
  11: core::ops::function::impls::<impl core::ops::function::FnMut<A> for &mut F>::call_mut
  12: <alloc::vec::Vec<T> as alloc::vec::spec_from_iter::SpecFromIter<T,I>>::from_iter
  13: rust_analyzer::diagnostics::fetch_native_diagnostics
  14: core::ops::function::FnOnce::call_once{{vtable.shim}}
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

I had copy the whole project files to my wsl distribution. Under ubuntu on wsl, it works fine, so I guess this issue concerns to the underlying windows 10.

@rainingdays rainingdays added the C-bug Category: bug label Dec 14, 2023
@rainingdays rainingdays changed the title Thread panic on the assertion of "id.index() < Self::MAX_FILE_ID" Thread panics on the assertion of "id.index() < Self::MAX_FILE_ID" Dec 14, 2023
bors added a commit that referenced this issue Dec 14, 2023
minor: Add messages to some asserts for better debugging

cc #16118
@rainingdays
Copy link
Author

rainingdays commented Dec 15, 2023

Oops, this issue occurs on my ubuntu of wsl too. and I find that the tokio's procedure macros, including tokio::test, tokio::main, are the reasons to trigger this panic. For instance:

#[tokio::test]
async fn subscribe_fails_if_there_is_a_fatal_database_error() {
    let app = spawn_app().await;
    ...
}

Remove that macro, the panic doesn't appear.

After switching to pre-release version: 0.4.1770-standalone (96f6608 2023-12-14), the log is:

thread 'Worker' panicked at crates\base-db\src\span.rs:154:9:
FileId index 4294967295 is too large
stack backtrace:
Panic context:
> fetch_native_diagnostics

thread 'Worker' panicked at crates\base-db\src\span.rs:154:9:
FileId index 4294967295 is too large
   0: std::panicking::begin_panic_handler
             at /rustc/a28077b28a02b92985b3a3faecf92813155f1ea1/library\std\src\panicking.rs:597
   1: core::panicking::panic_fmt
             at /rustc/a28077b28a02b92985b3a3faecf92813155f1ea1/library\core\src\panicking.rs:72
   2: hir_expand::ExpansionInfo::map_node_range_up
   3: hir_expand::files::InFileWrapper<base_db::span::HirFileId,&rowan::api::SyntaxNode<syntax::syntax_node::RustLanguage>>::original_file_range
   4: hir::semantics::SemanticsImpl::diagnostics_display_range
   5: ide_diagnostics::adjusted_display_range
   6: ide_diagnostics::handlers::type_mismatch::type_mismatch
   7: ide_diagnostics::diagnostics
   8: std::panicking::try
   9: ide::Analysis::assists_with_fixes
  10: rust_analyzer::handlers::request::handle_code_action
  11: std::panicking::try
  12: core::ops::function::FnOnce::call_once{{vtable.shim}}
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace. 

@Veykril
Copy link
Member

Veykril commented Dec 15, 2023

Hmm, that snippet alone does not trigger it for me (the assert should also be impossible to hit, I don't like this)

@Veykril
Copy link
Member

Veykril commented Dec 15, 2023

I do hit a new assert I placed though with that code in the fixup parts hmm.

Edit: It is indeed the fixup.

@philipp1992
Copy link

still affects me under ubuntu wsl

Panic context:
> fetch_native_diagnostics

thread 'Worker' panicked at /github/home/.cargo/registry/src/index.crates.io-6f17d22bba15001f/chalk-ir-0.98.0/src/debug.rs:156:13:
not implemented: cannot format ProjectionTy without setting Program in tls

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: bug I-panic
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants