Skip to content

ICE: index out of bounds: the len is 0 but the index is 0 -Zdrop-tracking, generators #102645

New issue

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

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

Already on GitHub? # to your account

Closed
matthiaskrgr opened this issue Oct 4, 2022 · 0 comments · Fixed by #102695
Closed
Assignees
Labels
A-coroutines Area: Coroutines C-bug Category: This is a bug. F-coroutines `#![feature(coroutines)]` 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

@matthiaskrgr
Copy link
Member

matthiaskrgr commented Oct 4, 2022

Code

#![feature(generators, generator_trait)]

use std::ops::Generator;
use std::pin::Pin;

fn main() {
    let mut a = 5;
    let mut b = || {
        let d = 6;
        yield;
        _zzz(); // #break
        a = d;
    };
    Pin::new(&mut b).resume();
}

fn _zzz() {()}

Meta

rustc --version --verbose:

rustc 1.66.0-nightly (57f097ea2 2022-10-01)
binary: rustc
commit-hash: 57f097ea25f2c05f424fc9b9dc50dbd6d399845c
commit-date: 2022-10-01
host: x86_64-unknown-linux-gnu
release: 1.66.0-nightly
LLVM version: 15.0.2

Error output

rustc -Zdrop-tracking <file>

error[E0061]: this function takes 1 argument but 0 arguments were supplied
   --> ./35a67217f16718c45dd897c4b00ceaa647b8d5d8.rs:14:22
    |
14  |     Pin::new(&mut b).resume();
    |                      ^^^^^^-- an argument of type `()` is missing
    |
note: associated function defined here
   --> /home/matthias/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ops/generator.rs:114:8
    |
114 |     fn resume(self: Pin<&mut Self>, arg: R) -> GeneratorState<Self::Yield, Self::Return>;
    |        ^^^^^^
help: provide the argument
    |
14  |     Pin::new(&mut b).resume(());
    |                            ~~~~
Backtrace

thread 'rustc' panicked at 'index out of bounds: the len is 0 but the index is 0', /cargo/registry/src/github.heygears.com-1ecc6299db9ec823/ena-0.14.0/src/snapshot_vec.rs:199:10
stack backtrace:
   0:     0x7fe16632b380 - std::backtrace_rs::backtrace::libunwind::trace::h80b67585f93dcdfa
                               at /rustc/57f097ea25f2c05f424fc9b9dc50dbd6d399845c/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   1:     0x7fe16632b380 - std::backtrace_rs::backtrace::trace_unsynchronized::h1727d1d942e500b9
                               at /rustc/57f097ea25f2c05f424fc9b9dc50dbd6d399845c/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7fe16632b380 - std::sys_common::backtrace::_print_fmt::h1d58d8daeea91706
                               at /rustc/57f097ea25f2c05f424fc9b9dc50dbd6d399845c/library/std/src/sys_common/backtrace.rs:66:5
   3:     0x7fe16632b380 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h813c9b7ed78580ba
                               at /rustc/57f097ea25f2c05f424fc9b9dc50dbd6d399845c/library/std/src/sys_common/backtrace.rs:45:22
   4:     0x7fe16638614e - core::fmt::write::h3eecc0c99e4c5326
                               at /rustc/57f097ea25f2c05f424fc9b9dc50dbd6d399845c/library/core/src/fmt/mod.rs:1209:17
   5:     0x7fe16631bf05 - std::io::Write::write_fmt::h169b89be5a4eb2e3
                               at /rustc/57f097ea25f2c05f424fc9b9dc50dbd6d399845c/library/std/src/io/mod.rs:1679:15
   6:     0x7fe16632e123 - std::sys_common::backtrace::_print::h8470ccc2c46bc222
                               at /rustc/57f097ea25f2c05f424fc9b9dc50dbd6d399845c/library/std/src/sys_common/backtrace.rs:48:5
   7:     0x7fe16632e123 - std::sys_common::backtrace::print::h59bfcbb529aad43f
                               at /rustc/57f097ea25f2c05f424fc9b9dc50dbd6d399845c/library/std/src/sys_common/backtrace.rs:35:9
   8:     0x7fe16632e123 - std::panicking::default_hook::{{closure}}::h19081fa8b049df20
                               at /rustc/57f097ea25f2c05f424fc9b9dc50dbd6d399845c/library/std/src/panicking.rs:267:22
   9:     0x7fe16632ddfa - std::panicking::default_hook::h8f0eea70584d6151
                               at /rustc/57f097ea25f2c05f424fc9b9dc50dbd6d399845c/library/std/src/panicking.rs:286:9
  10:     0x7fe168b9ac21 - <rustc_driver[5f28de9a0492c992]::DEFAULT_HOOK::{closure#0}::{closure#0} as core[2f8af133219d6c11]::ops::function::FnOnce<(&core[2f8af133219d6c11]::panic::panic_info::PanicInfo,)>>::call_once::{shim:vtable#0}
  11:     0x7fe16632e95b - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::hb9a306ebd1946910
                               at /rustc/57f097ea25f2c05f424fc9b9dc50dbd6d399845c/library/alloc/src/boxed.rs:1952:9
  12:     0x7fe16632e95b - std::panicking::rust_panic_with_hook::h6b2b2d988170cf5c
                               at /rustc/57f097ea25f2c05f424fc9b9dc50dbd6d399845c/library/std/src/panicking.rs:673:13
  13:     0x7fe16632e7b7 - std::panicking::begin_panic_handler::{{closure}}::h62d28487481f8926
                               at /rustc/57f097ea25f2c05f424fc9b9dc50dbd6d399845c/library/std/src/panicking.rs:560:13
  14:     0x7fe16632b82c - std::sys_common::backtrace::__rust_end_short_backtrace::h7b5def46adfc3854
                               at /rustc/57f097ea25f2c05f424fc9b9dc50dbd6d399845c/library/std/src/sys_common/backtrace.rs:138:18
  15:     0x7fe16632e4d2 - rust_begin_unwind
                               at /rustc/57f097ea25f2c05f424fc9b9dc50dbd6d399845c/library/std/src/panicking.rs:556:5
  16:     0x7fe166382d23 - core::panicking::panic_fmt::h05e1d78f70f70b46
                               at /rustc/57f097ea25f2c05f424fc9b9dc50dbd6d399845c/library/core/src/panicking.rs:142:14
  17:     0x7fe166382c62 - core::panicking::panic_bounds_check::hbe7631d6e5693b99
                               at /rustc/57f097ea25f2c05f424fc9b9dc50dbd6d399845c/library/core/src/panicking.rs:84:5
  18:     0x7fe1674857ce - <rustc_infer[2cd8bebc06dfe0eb]::infer::ShallowResolver as rustc_middle[8a82caabfb0f2329]::ty::fold::TypeFolder>::fold_ty
  19:     0x7fe1674fda20 - <rustc_infer[2cd8bebc06dfe0eb]::infer::canonical::canonicalizer::Canonicalizer as rustc_middle[8a82caabfb0f2329]::ty::fold::TypeFolder>::fold_ty
  20:     0x7fe167d2c057 - <rustc_infer[2cd8bebc06dfe0eb]::infer::InferCtxt as rustc_trait_selection[cab02295b9e50f19]::traits::query::evaluate_obligation::InferCtxtExt>::predicate_must_hold_modulo_regions
  21:     0x7fe167d2ba1c - rustc_trait_selection[cab02295b9e50f19]::traits::type_known_to_meet_bound_modulo_regions
  22:     0x7fe168a2da48 - rustc_ty_utils[77e3777a26d786a3]::common_traits::is_copy_raw
  23:     0x7fe167e627ef - rustc_query_system[e458c87a166b4189]::query::plumbing::try_execute_query::<rustc_query_impl[f6287e509623bd0a]::plumbing::QueryCtxt, rustc_query_system[e458c87a166b4189]::query::caches::DefaultCache<rustc_middle[8a82caabfb0f2329]::ty::ParamEnvAnd<rustc_middle[8a82caabfb0f2329]::ty::Ty>, bool>>
  24:     0x7fe168ada5be - <rustc_query_impl[f6287e509623bd0a]::Queries as rustc_middle[8a82caabfb0f2329]::ty::query::QueryEngine>::is_copy_raw
  25:     0x7fe1677cb7b7 - <rustc_middle[8a82caabfb0f2329]::ty::Ty>::is_copy_modulo_regions
  26:     0x7fe167e14f5d - rustc_ty_utils[77e3777a26d786a3]::needs_drop::needs_drop_raw
  27:     0x7fe167e627ef - rustc_query_system[e458c87a166b4189]::query::plumbing::try_execute_query::<rustc_query_impl[f6287e509623bd0a]::plumbing::QueryCtxt, rustc_query_system[e458c87a166b4189]::query::caches::DefaultCache<rustc_middle[8a82caabfb0f2329]::ty::ParamEnvAnd<rustc_middle[8a82caabfb0f2329]::ty::Ty>, bool>>
  28:     0x7fe168ada83e - <rustc_query_impl[f6287e509623bd0a]::Queries as rustc_middle[8a82caabfb0f2329]::ty::query::QueryEngine>::needs_drop_raw
  29:     0x7fe168de99f8 - <rustc_hir_analysis[c82a15bd09de242e]::check::generator_interior::drop_ranges::record_consumed_borrow::ExprUseDelegate as rustc_hir_analysis[c82a15bd09de242e]::expr_use_visitor::Delegate>::mutate
  30:     0x7fe1682e624f - <rustc_hir_analysis[c82a15bd09de242e]::expr_use_visitor::ExprUseVisitor>::mutate_expr
  31:     0x7fe1682e3eac - <rustc_hir_analysis[c82a15bd09de242e]::expr_use_visitor::ExprUseVisitor>::walk_expr
  32:     0x7fe1682e4c52 - <rustc_hir_analysis[c82a15bd09de242e]::expr_use_visitor::ExprUseVisitor>::consume_expr
  33:     0x7fe1682e5c16 - <rustc_hir_analysis[c82a15bd09de242e]::expr_use_visitor::ExprUseVisitor>::walk_block
  34:     0x7fe1682e2cd1 - <rustc_hir_analysis[c82a15bd09de242e]::expr_use_visitor::ExprUseVisitor>::walk_expr
  35:     0x7fe1682e4c52 - <rustc_hir_analysis[c82a15bd09de242e]::expr_use_visitor::ExprUseVisitor>::consume_expr
  36:     0x7fe168632723 - <rustc_hir_analysis[c82a15bd09de242e]::expr_use_visitor::ExprUseVisitor>::consume_body
  37:     0x7fe168de92dd - rustc_hir_analysis[c82a15bd09de242e]::check::generator_interior::drop_ranges::record_consumed_borrow::find_consumed_and_borrowed
  38:     0x7fe168e01673 - rustc_hir_analysis[c82a15bd09de242e]::check::generator_interior::drop_ranges::compute_drop_ranges
  39:     0x7fe168e3900c - rustc_hir_analysis[c82a15bd09de242e]::check::generator_interior::resolve_interior
  40:     0x7fe16772f08d - <rustc_hir_analysis[c82a15bd09de242e]::check::inherited::InheritedBuilder>::enter::<rustc_hir_analysis[c82a15bd09de242e]::check::typeck_with_fallback<rustc_hir_analysis[c82a15bd09de242e]::check::typeck::{closure#0}>::{closure#1}, &rustc_middle[8a82caabfb0f2329]::ty::context::TypeckResults>
  41:     0x7fe16772af2f - rustc_hir_analysis[c82a15bd09de242e]::check::typeck
  42:     0x7fe168257bf8 - rustc_query_system[e458c87a166b4189]::query::plumbing::try_execute_query::<rustc_query_impl[f6287e509623bd0a]::plumbing::QueryCtxt, rustc_query_system[e458c87a166b4189]::query::caches::DefaultCache<rustc_span[efd8b0f1895919e0]::def_id::LocalDefId, &rustc_middle[8a82caabfb0f2329]::ty::context::TypeckResults>>
  43:     0x7fe168ad81fe - <rustc_query_impl[f6287e509623bd0a]::Queries as rustc_middle[8a82caabfb0f2329]::ty::query::QueryEngine>::typeck
  44:     0x7fe16891afb7 - rustc_data_structures[cfd6ab9a7f8b3ad]::sync::par_for_each_in::<&[rustc_span[efd8b0f1895919e0]::def_id::LocalDefId], <rustc_middle[8a82caabfb0f2329]::hir::map::Map>::par_body_owners<rustc_hir_analysis[c82a15bd09de242e]::check::typeck_item_bodies::{closure#0}>::{closure#0}>
  45:     0x7fe16891ad73 - rustc_hir_analysis[c82a15bd09de242e]::check::typeck_item_bodies
  46:     0x7fe1688246ea - rustc_query_system[e458c87a166b4189]::query::plumbing::try_execute_query::<rustc_query_impl[f6287e509623bd0a]::plumbing::QueryCtxt, rustc_query_system[e458c87a166b4189]::query::caches::DefaultCache<(), ()>>
  47:     0x7fe168824417 - rustc_query_system[e458c87a166b4189]::query::plumbing::get_query::<rustc_query_impl[f6287e509623bd0a]::queries::typeck_item_bodies, rustc_query_impl[f6287e509623bd0a]::plumbing::QueryCtxt>
  48:     0x7fe167fa762f - <rustc_session[786cb1c5da006f9b]::session::Session>::time::<(), rustc_hir_analysis[c82a15bd09de242e]::check_crate::{closure#7}>
  49:     0x7fe167fa72c5 - rustc_hir_analysis[c82a15bd09de242e]::check_crate
  50:     0x7fe167fa68c7 - rustc_interface[a2e36ac52ab23c81]::passes::analysis
  51:     0x7fe168963ce4 - rustc_query_system[e458c87a166b4189]::query::plumbing::try_execute_query::<rustc_query_impl[f6287e509623bd0a]::plumbing::QueryCtxt, rustc_query_system[e458c87a166b4189]::query::caches::DefaultCache<(), core[2f8af133219d6c11]::result::Result<(), rustc_errors[1020869c0a53ac34]::ErrorGuaranteed>>>
  52:     0x7fe168963a17 - rustc_query_system[e458c87a166b4189]::query::plumbing::get_query::<rustc_query_impl[f6287e509623bd0a]::queries::analysis, rustc_query_impl[f6287e509623bd0a]::plumbing::QueryCtxt>
  53:     0x7fe167896ab7 - <rustc_interface[a2e36ac52ab23c81]::passes::QueryContext>::enter::<rustc_driver[5f28de9a0492c992]::run_compiler::{closure#1}::{closure#2}::{closure#3}, core[2f8af133219d6c11]::result::Result<(), rustc_errors[1020869c0a53ac34]::ErrorGuaranteed>>
  54:     0x7fe16788a04c - rustc_interface[a2e36ac52ab23c81]::interface::create_compiler_and_run::<core[2f8af133219d6c11]::result::Result<(), rustc_errors[1020869c0a53ac34]::ErrorGuaranteed>, rustc_driver[5f28de9a0492c992]::run_compiler::{closure#1}>
  55:     0x7fe167888982 - <scoped_tls[430d84ded6e482c8]::ScopedKey<rustc_span[efd8b0f1895919e0]::SessionGlobals>>::set::<rustc_interface[a2e36ac52ab23c81]::interface::run_compiler<core[2f8af133219d6c11]::result::Result<(), rustc_errors[1020869c0a53ac34]::ErrorGuaranteed>, rustc_driver[5f28de9a0492c992]::run_compiler::{closure#1}>::{closure#0}, core[2f8af133219d6c11]::result::Result<(), rustc_errors[1020869c0a53ac34]::ErrorGuaranteed>>
  56:     0x7fe16788866f - std[281da818632cbbdf]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[a2e36ac52ab23c81]::util::run_in_thread_pool_with_globals<rustc_interface[a2e36ac52ab23c81]::interface::run_compiler<core[2f8af133219d6c11]::result::Result<(), rustc_errors[1020869c0a53ac34]::ErrorGuaranteed>, rustc_driver[5f28de9a0492c992]::run_compiler::{closure#1}>::{closure#0}, core[2f8af133219d6c11]::result::Result<(), rustc_errors[1020869c0a53ac34]::ErrorGuaranteed>>::{closure#0}, core[2f8af133219d6c11]::result::Result<(), rustc_errors[1020869c0a53ac34]::ErrorGuaranteed>>
  57:     0x7fe1689fc550 - <<std[281da818632cbbdf]::thread::Builder>::spawn_unchecked_<rustc_interface[a2e36ac52ab23c81]::util::run_in_thread_pool_with_globals<rustc_interface[a2e36ac52ab23c81]::interface::run_compiler<core[2f8af133219d6c11]::result::Result<(), rustc_errors[1020869c0a53ac34]::ErrorGuaranteed>, rustc_driver[5f28de9a0492c992]::run_compiler::{closure#1}>::{closure#0}, core[2f8af133219d6c11]::result::Result<(), rustc_errors[1020869c0a53ac34]::ErrorGuaranteed>>::{closure#0}, core[2f8af133219d6c11]::result::Result<(), rustc_errors[1020869c0a53ac34]::ErrorGuaranteed>>::{closure#1} as core[2f8af133219d6c11]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  58:     0x7fe166338433 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h26c13cce480449d5
                               at /rustc/57f097ea25f2c05f424fc9b9dc50dbd6d399845c/library/alloc/src/boxed.rs:1938:9
  59:     0x7fe166338433 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h1d016e890f9a0fa4
                               at /rustc/57f097ea25f2c05f424fc9b9dc50dbd6d399845c/library/alloc/src/boxed.rs:1938:9
  60:     0x7fe166338433 - std::sys::unix::thread::Thread::new::thread_start::ha5f4632b746acf38
                               at /rustc/57f097ea25f2c05f424fc9b9dc50dbd6d399845c/library/std/src/sys/unix/thread.rs:108:17
  61:     0x7fe16609078d - <unknown>
  62:     0x7fe1661118e4 - clone
  63:                0x0 - <unknown>

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.66.0-nightly (57f097ea2 2022-10-01) running on x86_64-unknown-linux-gnu

note: compiler flags: -Z drop-tracking

query stack during panic:
#0 [is_copy_raw] computing whether `{integer}` is `Copy`
#1 [needs_drop_raw] computing whether `{integer}` needs drop
#2 [typeck] type-checking `main`
#3 [typeck_item_bodies] type-checking all item bodies
#4 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to previous error

For more information about this error, try `rustc --explain E0061`.

@matthiaskrgr matthiaskrgr added 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. C-bug Category: This is a bug. A-coroutines Area: Coroutines F-coroutines `#![feature(coroutines)]` labels Oct 4, 2022
@compiler-errors compiler-errors self-assigned this Oct 4, 2022
Dylan-DPC added a commit to Dylan-DPC/rust that referenced this issue Oct 14, 2022
…ial-copy, r=lcnr

Int and float inference variables are trivially copy

Fixes rust-lang#102645
@bors bors closed this as completed in 3271760 Oct 14, 2022
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
A-coroutines Area: Coroutines C-bug Category: This is a bug. F-coroutines `#![feature(coroutines)]` 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
2 participants