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 'rustc' panicked at 'index out of bounds: the len is 0 but the index is 0' #100981

Closed
biuiko opened this issue Aug 25, 2022 · 19 comments
Closed
Labels
C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@biuiko
Copy link

biuiko commented Aug 25, 2022

Code

<code>

Meta

rustc --version --verbose:

rustc 1.63.0 (4b91a6ea7 2022-08-08)

Error output

thread 'rustc' panicked at 'index out of bounds: the len is 0 but the index is 0', /Users/runner/.cargo/registry/src/github.com-1ecc6299db9ec823/ena-0.14.0/src/snapshot_vec.rs:199:10
Backtrace

thread 'rustc' panicked at 'index out of bounds: the len is 0 but the index is 0', /Users/runner/.cargo/registry/src/github.com-1ecc6299db9ec823/ena-0.14.0/src/snapshot_vec.rs:199:10
stack backtrace:
   0: _rust_begin_unwind
   1: core::panicking::panic_fmt
   2: core::panicking::panic_bounds_check
   3: <rustc_infer::infer::type_variable::TypeVariableTable>::probe
   4: <rustc_infer::infer::InferCtxt>::probe_ty_var
   5: <rustc_infer::infer::canonical::canonicalizer::Canonicalizer as rustc_middle::ty::fold::TypeFolder>::fold_ty
   6: <&rustc_middle::ty::list::List<rustc_middle::ty::subst::GenericArg> as rustc_middle::ty::fold::TypeFoldable>::try_fold_with::<rustc_infer::infer::canonical::canonicalizer::Canonicalizer>
   7: <rustc_middle::ty::PredicateKind as rustc_middle::ty::fold::TypeFoldable>::try_fold_with::<rustc_infer::infer::canonical::canonicalizer::Canonicalizer>
   8: <rustc_middle::ty::ParamEnvAnd<rustc_middle::ty::Predicate> as rustc_middle::ty::fold::TypeFoldable>::fold_with::<rustc_infer::infer::canonical::canonicalizer::Canonicalizer>
   9: <rustc_infer::infer::canonical::canonicalizer::Canonicalizer>::canonicalize::<rustc_middle::ty::ParamEnvAnd<rustc_middle::ty::Predicate>>
  10: <rustc_infer::infer::InferCtxt as rustc_trait_selection::traits::query::evaluate_obligation::InferCtxtExt>::evaluate_obligation
  11: <rustc_infer::infer::InferCtxt as rustc_trait_selection::traits::query::evaluate_obligation::InferCtxtExt>::evaluate_obligation_no_overflow
  12: rustc_trait_selection::traits::type_known_to_meet_bound_modulo_regions
  13: rustc_ty_utils::common_traits::is_item_raw
  14: <rustc_query_system::dep_graph::graph::DepGraph<rustc_middle::dep_graph::dep_node::DepKind>>::with_task::<rustc_middle::ty::context::TyCtxt, rustc_middle::ty::ParamEnvAnd<rustc_middle::ty::Ty>, bool>
  15: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::plumbing::QueryCtxt, rustc_query_system::query::caches::DefaultCache<rustc_middle::ty::ParamEnvAnd<rustc_middle::ty::Ty>, bool>>
  16: rustc_query_system::query::plumbing::get_query::<rustc_query_impl::queries::is_copy_raw, rustc_query_impl::plumbing::QueryCtxt>
  17: <rustc_middle::ty::Ty>::is_copy_modulo_regions
  18: rustc_ty_utils::needs_drop::needs_drop_raw
  19: <rustc_query_system::dep_graph::graph::DepGraph<rustc_middle::dep_graph::dep_node::DepKind>>::with_task::<rustc_middle::ty::context::TyCtxt, rustc_middle::ty::ParamEnvAnd<rustc_middle::ty::Ty>, bool>
  20: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::plumbing::QueryCtxt, rustc_query_system::query::caches::DefaultCache<rustc_middle::ty::ParamEnvAnd<rustc_middle::ty::Ty>, bool>>
  21: rustc_query_system::query::plumbing::get_query::<rustc_query_impl::queries::needs_drop_raw, rustc_query_impl::plumbing::QueryCtxt>
  22: rustc_ty_utils::instance::inner_resolve_instance
  23: rustc_ty_utils::instance::resolve_instance
  24: <rustc_middle::dep_graph::dep_node::DepKind as rustc_query_system::dep_graph::DepKind>::with_deps::<<rustc_query_system::dep_graph::graph::DepGraph<rustc_middle::dep_graph::dep_node::DepKind>>::with_task_impl<rustc_middle::ty::context::TyCtxt, rustc_middle::ty::ParamEnvAnd<(rustc_span::def_id::DefId, &rustc_middle::ty::list::List<rustc_middle::ty::subst::GenericArg>)>, core::result::Result<core::option::Option<rustc_middle::ty::instance::Instance>, rustc_errors::ErrorGuaranteed>>::{closure#0}, core::result::Result<core::option::Option<rustc_middle::ty::instance::Instance>, rustc_errors::ErrorGuaranteed>>
  25: <rustc_query_system::dep_graph::graph::DepGraph<rustc_middle::dep_graph::dep_node::DepKind>>::with_task::<rustc_middle::ty::context::TyCtxt, rustc_middle::ty::ParamEnvAnd<(rustc_span::def_id::DefId, &rustc_middle::ty::list::List<rustc_middle::ty::subst::GenericArg>)>, core::result::Result<core::option::Option<rustc_middle::ty::instance::Instance>, rustc_errors::ErrorGuaranteed>>
  26: rustc_query_system::query::plumbing::get_query::<rustc_query_impl::queries::resolve_instance, rustc_query_impl::plumbing::QueryCtxt>
  27: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::resolve_instance
  28: <rustc_middle::ty::instance::Instance>::resolve_opt_const_arg
  29: <rustc_middle::ty::instance::Instance>::resolve_drop_in_place
  30: <rustc_monomorphize::collector::MirNeighborCollector as rustc_middle::mir::visit::Visitor>::visit_terminator
  31: rustc_monomorphize::collector::collect_neighbours
  32: rustc_monomorphize::collector::collect_items_rec
  33: rustc_monomorphize::collector::collect_items_rec
  34: rustc_monomorphize::collector::collect_items_rec
  35: rustc_monomorphize::collector::collect_items_rec
  36: rustc_monomorphize::collector::collect_items_rec
  37: rustc_monomorphize::collector::collect_items_rec
  38: rustc_monomorphize::collector::collect_items_rec
  39: rustc_monomorphize::collector::collect_items_rec
  40: rustc_monomorphize::collector::collect_items_rec
  41: rustc_monomorphize::collector::collect_items_rec
  42: rustc_monomorphize::collector::collect_items_rec
  43: rustc_monomorphize::collector::collect_items_rec
  44: rustc_monomorphize::collector::collect_items_rec
  45: rustc_monomorphize::collector::collect_items_rec
  46: rustc_monomorphize::collector::collect_items_rec
  47: rustc_monomorphize::collector::collect_items_rec
  48: rustc_monomorphize::collector::collect_items_rec
  49: rustc_monomorphize::collector::collect_items_rec
  50: rustc_monomorphize::collector::collect_items_rec
  51: rustc_monomorphize::collector::collect_items_rec
  52: rustc_monomorphize::collector::collect_items_rec
  53: rustc_monomorphize::collector::collect_items_rec
  54: rustc_monomorphize::collector::collect_items_rec
  55: rustc_monomorphize::collector::collect_items_rec
  56: rustc_monomorphize::collector::collect_items_rec
  57: rustc_monomorphize::collector::collect_items_rec
  58: rustc_monomorphize::collector::collect_items_rec
  59: rustc_monomorphize::collector::collect_items_rec
  60: rustc_monomorphize::collector::collect_items_rec
  61: rustc_monomorphize::collector::collect_items_rec
  62: rustc_monomorphize::collector::collect_items_rec
  63: rustc_monomorphize::collector::collect_items_rec
  64: rustc_monomorphize::collector::collect_items_rec
  65: rustc_monomorphize::collector::collect_items_rec
  66: rustc_monomorphize::collector::collect_items_rec
  67: rustc_monomorphize::collector::collect_items_rec
  68: rustc_monomorphize::collector::collect_items_rec
  69: rustc_monomorphize::collector::collect_items_rec
  70: rustc_monomorphize::collector::collect_items_rec
  71: rustc_monomorphize::collector::collect_items_rec
  72: rustc_monomorphize::collector::collect_items_rec
  73: rustc_monomorphize::collector::collect_items_rec
  74: rustc_monomorphize::collector::collect_items_rec
  75: rustc_monomorphize::collector::collect_items_rec
  76: rustc_monomorphize::collector::collect_items_rec
  77: rustc_monomorphize::collector::collect_items_rec
  78: rustc_monomorphize::collector::collect_items_rec
  79: rustc_monomorphize::collector::collect_items_rec
  80: rustc_monomorphize::collector::collect_items_rec
  81: rustc_monomorphize::collector::collect_items_rec
  82: rustc_monomorphize::collector::collect_items_rec
  83: rustc_monomorphize::collector::collect_items_rec
  84: rustc_monomorphize::collector::collect_items_rec
  85: rustc_monomorphize::collector::collect_items_rec
  86: rustc_monomorphize::collector::collect_items_rec
  87: rustc_monomorphize::collector::collect_items_rec
  88: rustc_monomorphize::collector::collect_items_rec
  89: rustc_monomorphize::collector::collect_items_rec
  90: rustc_monomorphize::collector::collect_items_rec
  91: rustc_monomorphize::collector::collect_items_rec
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

error: internal compiler error: unexpected panic

note: the compiler unexpectedly panicked. this is a bug.

note: we would appreciate a bug report: https://github.com/rust-lang/rust/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md

note: rustc 1.63.0 (4b91a6ea7 2022-08-08) running on aarch64-apple-darwin

note: compiler flags: --crate-type lib -C embed-bitcode=no -C split-debuginfo=unpacked -C debuginfo=2 -C incremental

note: some of the compiler flags provided by cargo are hidden

query stack during panic:
#0 [is_copy_raw] computing whether `_` is `Copy`
#1 [needs_drop_raw] computing whether `_` needs drop
#2 [resolve_instance] resolving instance `core::ptr::drop_in_place::<_>`
#3 [collect_and_partition_mono_items] collect_and_partition_mono_items
#4 [exported_symbols] exported_symbols
end of query stack

@biuiko biuiko added C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Aug 25, 2022
@compiler-errors
Copy link
Member

@biuiko it would be super useful if you could provide test code for this!

@biuiko
Copy link
Author

biuiko commented Aug 25, 2022

@biuiko it would be super useful if you could provide test code for this!

I'm sorry but I'm working on my company's project and this is a private project :( I'll see if I can make a minimal reproducible example

@dawnofmidnight
Copy link
Contributor

dawnofmidnight commented Aug 25, 2022

FYI, I'm getting a similar error (i.e. the panic message looks like thread 'rustc' panicked at 'index out of bounds: the len is 110 but the index is 111', /cargo/registry/src/github.com-1ecc6299db9ec823/ena-0.14.0/src/snapshot_vec.rs:199:10). I'm on rustc 1.65.0-nightly (addacb587 2022-08-24). I'm trying to get a minimal reproducible example since my codebase is rather big, but no luck so far.

@compiler-errors
Copy link
Member

@dawnofmidnight is your codebase also private? I can take a look at this issue if it's public, even if all you have to share is the whole codebase.

@gimbling-away
Copy link
Contributor

gimbling-away commented Aug 25, 2022

This might be a duplicate of #92004, the PR for that iirc hasn't released into nightly yet but will soon. #100757 has already released into nightly.

@biuiko Can you try running this code on latest nightly?

@dawnofmidnight
Copy link
Contributor

@dawnofmidnight is your codebase also private? I can take a look at this issue if it's public, even if all you have to share is the whole codebase.

I have just made it public (beware, it's horrifying). I was working on https://github.com/dawnofmidnight/spyce/blob/main/crates/syntax/src/lexer/mod.rs when I got this, but I think I updated somewhere in between, so I'm not sure if it was that particular file.

@compiler-errors
Copy link
Member

@dawnofmidnight if you don't have a commit that actually repro's the issue, then that's fine, but I probably won't be able to investigate it.

@gimbles Yeah, possibly this issue is fixed by the same fix for #92004, since this is happening during codegen. I would be surprised if that fixes @dawnofmidnight's issue, which I think might be fixed by #99928 instead.

Just for the record, any time that y'all see an ICE with 'index out of bounds: the len is ## but the index is ##', /cargo/registry/src/github.com-1ecc6299db9ec823/ena-0.14.0 in the error message, it's possibly a new ICE, since that just means that we're using inference vars wrong somewhere in the compiler, but that can happen in a large number of places 😅

@dawnofmidnight
Copy link
Contributor

dawnofmidnight commented Aug 25, 2022

@dawnofmidnight if you don't have a commit that actually repro's the issue, then that's fine, but I probably won't be able to investigate it.

The commit on that repo does error on the latest nightly, not sure why github says "4 hours ago".

Just for the record, any time that y'all see an ICE with 'index out of bounds: the len is ## but the index is ##', /cargo/registry/src/github.com-1ecc6299db9ec823/ena-0.14.0 in the error message, it's possibly a new ICE, since that just means that we're using inference vars wrong somewhere in the compiler, but that can happen in a large number of places 😅

Oh, woops. I just saw this and figured this might be the right place to mention it.

@gwy15
Copy link

gwy15 commented Aug 25, 2022

This might be a duplicate of #92004, the PR for that iirc hasn't released into nightly yet but will soon. #100757 has already released into nightly.

@biuiko Can you try running this code on latest nightly?

Hi coworker of @biuiko here. We tried nightly and the good news is that the panic from rustc is gone, but now we're getting a

overflow evaluating the requirement `<SomeBuilder as BuilderTrait>::ParCloned`

This should be a code design problem for us, I'll let you know whether this will compile in nightly after I fix this code.

@gimbling-away
Copy link
Contributor

You could try increasing the recursion limit maybe?

@compiler-errors
Copy link
Member

(unrelated to this thread, but @dawnofmidnight your issue is fixed by #99928.)

@dawnofmidnight
Copy link
Contributor

dawnofmidnight commented Aug 25, 2022

Oh, yay! And sorry for interrupting the wrong thread. 😅

@gwy15
Copy link

gwy15 commented Aug 25, 2022

This might be a duplicate of #92004, the PR for that iirc hasn't released into nightly yet but will soon. #100757 has already released into nightly.
@biuiko Can you try running this code on latest nightly?

Hi coworker of @biuiko here. We tried nightly and the good news is that the panic from rustc is gone, but now we're getting a

overflow evaluating the requirement `<SomeBuilder as BuilderTrait>::ParCloned`

This should be a code design problem for us, I'll let you know whether this will compile in nightly after I fix this code.

I fixed the infinite recursive type problem and now the code compiles both in nightly and stable.

I tried but couldn't get a minimal reproducible example :( Hopefully this is fixed in #100757

@gwy15
Copy link

gwy15 commented Aug 25, 2022

BTW I tried nightly-2022-08-22 and that gives the exact same ICE output. Given that #100757 is merged 3 days ago, I believe that is the issue here.

@gimbling-away
Copy link
Contributor

PRs usually take a release or two after being merged to land into a nightly.

Honestly, considering the error message and the stacktrace 'n all are very similar, I'd bet that this is fixed and is a duplicate.

@Genysys
Copy link

Genysys commented Aug 29, 2022

Getting something similar and the latest nightly doesnt fix it. Here is the gist to the full error trace.

@Genysys
Copy link

Genysys commented Aug 29, 2022

Turns out not adding an await to a future triggered this on my path. The error message could be improved though i.e. it should not panic / crash

@compiler-errors
Copy link
Member

@Genysys that is the same issue as the one fixed by #99928.

@compiler-errors
Copy link
Member

I'm gonna close this due to

I fixed the infinite recursive type problem and now the code compiles both in nightly and stable.

and

We tried nightly and the good news is that the panic from rustc is gone

feel free to reopen an issue if you're able to reproduce this issue, and a code sample would be extra useful if so.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

6 participants