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

thread '<unnamed>' panicked at 'index out of bounds: the len is 1 but the index is 2', crates/hir_def/src/nameres/path_resolution.rs:381:33 #12046

Closed
bjorn3 opened this issue Apr 20, 2022 · 3 comments
Labels
C-bug Category: bug S-unactionable Issue requires feedback, design decisions or is blocked on other work

Comments

@bjorn3
Copy link
Member

bjorn3 commented Apr 20, 2022

This happened while browsing bevy. I'm not sure exactly where it happened though.

Panic context:
> 
version: 65fbe0a8d 2022-04-18 stable
request: textDocument/hover HoverParams {
    text_document: TextDocumentIdentifier {
        uri: Url {
            scheme: "file",
            cannot_be_a_base: false,
            username: "",
            password: None,
            host: None,
            port: None,
            path: "/home/bjorn/Projects/bevy/crates/bevy_render/src/render_resource/texture.rs",
            query: None,
            fragment: None,
        },
    },
    position: Position(
        Position {
            line: 141,
            character: 11,
        },
    ),
    work_done_progress_params: WorkDoneProgressParams {
        work_done_token: None,
    },
}

> impl_trait_query(ImplId(35842) -> ItemLoc { container: ModuleId { krate: CrateId(333), block: None, local_id: Idx::<ModuleData>(2) }, id: ItemTreeId { tree: TreeId { file: HirFileId(FileId(FileId(2613))), block: None }, value: Idx::<Impl>(0) } } -> ImplData { target_trait: Some(TraitRef { path: Path { type_anchor: None, mod_path: ModPath { kind: Plain, segments: [Name(Text("Array"))] }, generic_args: [None] } }), self_ty: Array(Path(Path { type_anchor: None, mod_path: ModPath { kind: Plain, segments: [Name(Text("T"))] }, generic_args: [None] }), Scalar(Usize(0))), items: [TypeAliasId(TypeAliasId(12596)), ConstId(ConstId(19067)), FunctionId(FunctionId(97359)), FunctionId(FunctionId(97360)), FunctionId(FunctionId(97361))], is_negative: false, attribute_calls: None })

> DefMap CrateId(333) crate_name=Some(CrateDisplayName { crate_name: CrateName("tinyvec_macros"), canonical_name: "tinyvec_macros" }) block=None path=Array

thread '<unnamed>' panicked at 'index out of bounds: the len is 1 but the index is 2', crates/hir_def/src/nameres/path_resolution.rs:381:33
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: hir_def::nameres::path_resolution::<impl hir_def::nameres::DefMap>::resolve_path_fp_with_macro_single
   4: hir_def::resolver::Resolver::resolve_path_in_type_ns
   5: hir_ty::lower::TyLoweringContext::lower_trait_ref_from_path
   6: hir_ty::lower::impl_trait_query
   7: salsa::runtime::Runtime::execute_query_implementation
   8: salsa::derived::slot::Slot<Q,MP>::read_upgrade
   9: salsa::derived::slot::Slot<Q,MP>::maybe_changed_since
  10: <salsa::derived::DerivedStorage<Q,MP> as salsa::plumbing::QueryStorageOps<Q>>::maybe_changed_since
  11: salsa::derived::slot::MemoRevisions::validate_memoized_value
  12: salsa::derived::slot::Slot<Q,MP>::read_upgrade
  13: salsa::derived::slot::Slot<Q,MP>::read
  14: salsa::QueryTable<Q>::get
  15: <DB as hir_ty::db::HirDatabase>::trait_impls_in_crate
  16: hir::Impl::all_for_type
  17: core::ops::function::impls::<impl core::ops::function::FnMut<A> for &mut F>::call_mut
  18: <core::iter::adapters::flatten::Flatten<I> as core::iter::traits::iterator::Iterator>::next
  19: <alloc::vec::Vec<T> as alloc::vec::spec_from_iter::SpecFromIter<T,I>>::from_iter
  20: ide::goto_implementation::goto_implementation
  21: std::panicking::try
  22: core::ops::function::impls::<impl core::ops::function::FnMut<A> for &mut F>::call_mut
  23: <alloc::vec::Vec<T> as alloc::vec::spec_from_iter::SpecFromIter<T,I>>::from_iter
  24: rust_analyzer::handlers::handle_hover
  25: std::panicking::try
  26: <F as threadpool::FnBox>::call_box
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
Panic context:
> 
version: 65fbe0a8d 2022-04-18 stable
request: textDocument/hover HoverParams {
    text_document: TextDocumentIdentifier {
        uri: Url {
            scheme: "file",
            cannot_be_a_base: false,
            username: "",
            password: None,
            host: None,
            port: None,
            path: "/home/bjorn/Projects/bevy/crates/bevy_render/src/render_resource/buffer.rs",
            query: None,
            fragment: None,
        },
    },
    position: Position(
        Position {
            line: 44,
            character: 20,
        },
    ),
    work_done_progress_params: WorkDoneProgressParams {
        work_done_token: None,
    },
}

> impl_trait_query(ImplId(35842) -> ItemLoc { container: ModuleId { krate: CrateId(333), block: None, local_id: Idx::<ModuleData>(2) }, id: ItemTreeId { tree: TreeId { file: HirFileId(FileId(FileId(2613))), block: None }, value: Idx::<Impl>(0) } } -> ImplData { target_trait: Some(TraitRef { path: Path { type_anchor: None, mod_path: ModPath { kind: Plain, segments: [Name(Text("Array"))] }, generic_args: [None] } }), self_ty: Array(Path(Path { type_anchor: None, mod_path: ModPath { kind: Plain, segments: [Name(Text("T"))] }, generic_args: [None] }), Scalar(Usize(0))), items: [TypeAliasId(TypeAliasId(12596)), ConstId(ConstId(19067)), FunctionId(FunctionId(97359)), FunctionId(FunctionId(97360)), FunctionId(FunctionId(97361))], is_negative: false, attribute_calls: None })

> DefMap CrateId(333) crate_name=Some(CrateDisplayName { crate_name: CrateName("tinyvec_macros"), canonical_name: "tinyvec_macros" }) block=None path=Array

thread '<unnamed>' panicked at 'index out of bounds: the len is 1 but the index is 2', crates/hir_def/src/nameres/path_resolution.rs:381:33
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: hir_def::nameres::path_resolution::<impl hir_def::nameres::DefMap>::resolve_path_fp_with_macro_single
   4: hir_def::resolver::Resolver::resolve_path_in_type_ns
   5: hir_ty::lower::TyLoweringContext::lower_trait_ref_from_path
   6: hir_ty::lower::impl_trait_query
   7: salsa::runtime::Runtime::execute_query_implementation
   8: salsa::derived::slot::Slot<Q,MP>::read_upgrade
   9: salsa::derived::slot::Slot<Q,MP>::maybe_changed_since
  10: <salsa::derived::DerivedStorage<Q,MP> as salsa::plumbing::QueryStorageOps<Q>>::maybe_changed_since
  11: salsa::derived::slot::MemoRevisions::validate_memoized_value
  12: salsa::derived::slot::Slot<Q,MP>::read_upgrade
  13: salsa::derived::slot::Slot<Q,MP>::read
  14: salsa::QueryTable<Q>::get
  15: <DB as hir_ty::db::HirDatabase>::trait_impls_in_crate
  16: hir::Impl::all_for_type
  17: core::ops::function::impls::<impl core::ops::function::FnMut<A> for &mut F>::call_mut
  18: <core::iter::adapters::flatten::Flatten<I> as core::iter::traits::iterator::Iterator>::next
  19: <alloc::vec::Vec<T> as alloc::vec::spec_from_iter::SpecFromIter<T,I>>::from_iter
  20: ide::goto_implementation::goto_implementation
  21: std::panicking::try
  22: core::ops::function::impls::<impl core::ops::function::FnMut<A> for &mut F>::call_mut
  23: <alloc::vec::Vec<T> as alloc::vec::spec_from_iter::SpecFromIter<T,I>>::from_iter
  24: rust_analyzer::handlers::handle_hover
  25: std::panicking::try
  26: <F as threadpool::FnBox>::call_box
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
[Error - 20:10:22] Request textDocument/hover failed.
  Message: server panicked: index out of bounds: the len is 1 but the index is 2
  Code: -32603
@jonas-schievink
Copy link
Contributor

We also seem to hang while processing this function:

https://github.com/bevyengine/bevy/blob/main/crates/bevy_render/src/render_phase/draw.rs#L290-L299

@lnicola
Copy link
Member

lnicola commented May 8, 2022

I saw this after adding a dependency to Cargo.toml (using cargo add):

Panic context:
> impl_trait_query(ImplId(23678) -> ItemLoc { container: ModuleId { krate: CrateId(69), block: None, local_id: Idx::<ModuleData>(7) }, id: ItemTreeId { tree: TreeId { file: HirFileId(FileId(FileId(825))), block: None }, value: Idx::<Impl>(0) } } -> ImplData { target_trait: Some(TraitRef { path: Path { type_anchor: None, mod_path: ModPath { kind: Plain, segments: [Name(Text("Sync"))] }, generic_args: [None] } }), self_ty: Path(Path { type_anchor: None, mod_path: ModPath { kind: Plain, segments: [Name(Text("ScopedKey"))] }, generic_args: [Some(GenericArgs { args: [Type(Path(Path { type_anchor: None, mod_path: ModPath { kind: Plain, segments: [Name(Text("T"))] }, generic_args: [None] }))], has_self_type: false, bindings: [], desugared_from_fn: false })] }), items: [], is_negative: false, attribute_calls: None })

> impl_self_ty_query(ImplId(23678) -> ItemLoc { container: ModuleId { krate: CrateId(69), block: None, local_id: Idx::<ModuleData>(7) }, id: ItemTreeId { tree: TreeId { file: HirFileId(FileId(FileId(825))), block: None }, value: Idx::<Impl>(0) } } -> ImplData { target_trait: Some(TraitRef { path: Path { type_anchor: None, mod_path: ModPath { kind: Plain, segments: [Name(Text("Sync"))] }, generic_args: [None] } }), self_ty: Path(Path { type_anchor: None, mod_path: ModPath { kind: Plain, segments: [Name(Text("ScopedKey"))] }, generic_args: [Some(GenericArgs { args: [Type(Path(Path { type_anchor: None, mod_path: ModPath { kind: Plain, segments: [Name(Text("T"))] }, generic_args: [None] }))], has_self_type: false, bindings: [], desugared_from_fn: false })] }), items: [], is_negative: false, attribute_calls: None })

> DefMap CrateId(69) crate_name=Some(CrateDisplayName { crate_name: CrateName("tinyvec_macros"), canonical_name: "tinyvec_macros" }) block=None path=ScopedKey

thread '<unnamed>' panicked at 'index out of bounds: the len is 1 but the index is 7', crates/hir-def/src/nameres/path_resolution.rs:381:33
stack backtrace:
   0: rust_begin_unwind
             at /rustc/0f231250ba7fe3a3f98a18aee9abfd65b104fb92/library/std/src/panicking.rs:584:5
   1: core::panicking::panic_fmt
             at /rustc/0f231250ba7fe3a3f98a18aee9abfd65b104fb92/library/core/src/panicking.rs:143:14
   2: core::panicking::panic_bounds_check
             at /rustc/0f231250ba7fe3a3f98a18aee9abfd65b104fb92/library/core/src/panicking.rs:84:5
   3: hir_def::nameres::path_resolution::<impl hir_def::nameres::DefMap>::resolve_path_fp_with_macro_single
   4: hir_def::resolver::Resolver::resolve_path_in_type_ns
   5: hir_ty::lower::TyLoweringContext::lower_ty_ext
   6: hir_ty::lower::impl_self_ty_query
   7: salsa::runtime::Runtime::execute_query_implementation
   8: salsa::derived::slot::Slot<Q,MP>::read_upgrade
   9: salsa::derived::slot::Slot<Q,MP>::read
  10: <salsa::derived::DerivedStorage<Q,MP> as salsa::plumbing::QueryStorageOps<Q>>::try_fetch
  11: salsa::QueryTable<Q>::get
  12: <DB as hir_ty::db::HirDatabase>::impl_self_ty::__shim
  13: hir_ty::lower::impl_trait_query
  14: salsa::runtime::Runtime::execute_query_implementation
  15: salsa::derived::slot::Slot<Q,MP>::read_upgrade
  16: salsa::derived::slot::Slot<Q,MP>::maybe_changed_since
  17: <salsa::derived::DerivedStorage<Q,MP> as salsa::plumbing::QueryStorageOps<Q>>::maybe_changed_since
  18: salsa::derived::slot::MemoRevisions::validate_memoized_value
  19: salsa::derived::slot::Slot<Q,MP>::read_upgrade
  20: salsa::derived::slot::Slot<Q,MP>::read
  21: <salsa::derived::DerivedStorage<Q,MP> as salsa::plumbing::QueryStorageOps<Q>>::try_fetch
  22: <DB as hir_ty::db::HirDatabase>::trait_impls_in_crate::__shim
  23: hir_ty::method_resolution::TraitImpls::trait_impls_in_deps_query
  24: salsa::runtime::Runtime::execute_query_implementation
  25: salsa::derived::slot::Slot<Q,MP>::read_upgrade
  26: salsa::derived::slot::Slot<Q,MP>::read
  27: <salsa::derived::DerivedStorage<Q,MP> as salsa::plumbing::QueryStorageOps<Q>>::try_fetch
  28: <DB as hir_ty::db::HirDatabase>::trait_impls_in_deps::__shim
  29: hir_ty::chalk_db::<impl chalk_solve::RustIrDatabase<hir_ty::interner::Interner> for hir_ty::traits::ChalkContext>::impls_for_trait
  30: chalk_solve::clauses::program_clauses_that_could_match
  31: chalk_recursive::solve::SolveIteration::solve_iteration
  32: chalk_recursive::fixed_point::RecursiveContext<K,V>::solve_goal
  33: chalk_recursive::fixed_point::RecursiveContext<K,V>::solve_root_goal
  34: hir_ty::traits::trait_solve_query
  35: salsa::runtime::Runtime::execute_query_implementation
  36: salsa::derived::slot::Slot<Q,MP>::read_upgrade
  37: salsa::derived::slot::Slot<Q,MP>::read
  38: <salsa::derived::DerivedStorage<Q,MP> as salsa::plumbing::QueryStorageOps<Q>>::try_fetch
  39: salsa::QueryTable<Q>::get
  40: <DB as hir_ty::db::HirDatabase>::trait_solve_query::__shim
  41: <DB as hir_ty::db::HirDatabase>::trait_solve_query
  42: hir_ty::db::trait_solve_wait
  43: <DB as hir_ty::db::HirDatabase>::trait_solve
  44: hir_ty::infer::coerce::<impl hir_ty::infer::unify::InferenceTable>::coerce_inner
  45: hir_ty::infer::coerce::<impl hir_ty::infer::unify::InferenceTable>::coerce
  46: hir_ty::infer::coerce::<impl hir_ty::infer::InferenceContext>::coerce
  47: hir_ty::infer::expr::<impl hir_ty::infer::InferenceContext>::check_call_arguments
  48: hir_ty::infer::expr::<impl hir_ty::infer::InferenceContext>::infer_expr_inner
  49: hir_ty::infer::expr::<impl hir_ty::infer::InferenceContext>::infer_expr_inner
  50: hir_ty::infer::expr::<impl hir_ty::infer::InferenceContext>::infer_expr_inner
  51: hir_ty::infer::expr::<impl hir_ty::infer::InferenceContext>::infer_expr_coerce
  52: hir_ty::infer::infer_query
  53: salsa::runtime::Runtime::execute_query_implementation
  54: salsa::derived::slot::Slot<Q,MP>::read_upgrade
  55: salsa::derived::slot::Slot<Q,MP>::read
  56: <salsa::derived::DerivedStorage<Q,MP> as salsa::plumbing::QueryStorageOps<Q>>::try_fetch
  57: <DB as hir_ty::db::HirDatabase>::infer_query::__shim
  58: hir_ty::db::infer_wait
  59: hir::DefWithBody::diagnostics
  60: hir::ModuleDef::diagnostics
  61: hir::Module::diagnostics
  62: ide_diagnostics::diagnostics
  63: std::panicking::try
  64: ide::Analysis::diagnostics
  65: rust_analyzer::handlers::publish_diagnostics
  66: core::ops::function::impls::<impl core::ops::function::FnMut<A> for &mut F>::call_mut
  67: alloc::vec::in_place_collect::<impl alloc::vec::spec_from_iter::SpecFromIter<T,I> for alloc::vec::Vec<T>>::from_iter
  68: <F as threadpool::FnBox>::call_box
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

@flodiebold flodiebold added S-unactionable Issue requires feedback, design decisions or is blocked on other work C-bug Category: bug labels Jun 17, 2022
@lnicola
Copy link
Member

lnicola commented Jul 21, 2022

Dupe of #10084.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: bug S-unactionable Issue requires feedback, design decisions or is blocked on other work
Projects
None yet
Development

No branches or pull requests

4 participants