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

ICE: index out of bounds: the len is 12 but the index is 13 #134335

Open
matthiaskrgr opened this issue Dec 15, 2024 · 1 comment
Open

ICE: index out of bounds: the len is 12 but the index is 13 #134335

matthiaskrgr opened this issue Dec 15, 2024 · 1 comment
Assignees
Labels
C-bug Category: This is a bug. F-async_closure `#![feature(async_closure)]` I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ requires-nightly This issue requires a nightly compiler in some way. S-bug-has-test Status: This bug is tracked inside the repo by a `known-bug` test. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@matthiaskrgr
Copy link
Member

auto-reduced (treereduce-rust):

//@compile-flags: -Zunstable-options --edition=2024 --crate-type=lib
pub async fn async_closure(x: &mut i32) {
    let c = async move || {
        *x += 1;
    };
    call_once(c).await;
}

fn call_once<T>(f: impl FnOnce() -> T) -> T {
    f()
}

original:

//@ check-pass
//@ edition: 2021
// Precise capture struct by move, consume field

struct Vec { a: i32 }

pub async fn async_closure(x: &mut i32) {
    let c = async move || {
        *x += 1;
    };
    call_once(c).await;
}

fn call_once<T>(f: impl FnOnce() -> T) -> T {
    f()
}

Version information

rustc 1.85.0-nightly (4790a435c 2024-12-15)
binary: rustc
commit-hash: 4790a435cbcb55c94ccdef51bf7a9b2e55824528
commit-date: 2024-12-15
host: x86_64-unknown-linux-gnu
release: 1.85.0-nightly
LLVM version: 19.1.5

Command:
/home/matthias/.rustup/toolchains/master/bin/rustc -Zunstable-options --edition=2024 --crate-type=lib

Program output

thread 'rustc' panicked at /rustc/4790a435cbcb55c94ccdef51bf7a9b2e55824528/compiler/rustc_middle/src/hir/mod.rs:179:84:
index out of bounds: the len is 12 but the index is 13
stack backtrace:
   0:     0x776f0b5a4c5a - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::heb202b000efba683
   1:     0x776f0be13d66 - core::fmt::write::h4529572b8b32da24
   2:     0x776f0ce1db51 - std::io::Write::write_fmt::h1a906436cb206037
   3:     0x776f0b5a4ab2 - std::sys::backtrace::BacktraceLock::print::h934abc86fa2dd260
   4:     0x776f0b5a6faa - std::panicking::default_hook::{{closure}}::hfd4bbe50128406cd
   5:     0x776f0b5a6df3 - std::panicking::default_hook::h25fd19fcd22c2e04
   6:     0x776f0a6f9a68 - std[70002648da4681c1]::panicking::update_hook::<alloc[334d4c3039138aa]::boxed::Box<rustc_driver_impl[2cc745b14baadf]::install_ice_hook::{closure#0}>>::{closure#0}
   7:     0x776f0b5a7768 - std::panicking::rust_panic_with_hook::h3f6d3ded85336e6b
   8:     0x776f0b5a745a - std::panicking::begin_panic_handler::{{closure}}::h4686f34f41f48fef
   9:     0x776f0b5a50f9 - std::sys::backtrace::__rust_end_short_backtrace::h4d0c634afae53cc6
  10:     0x776f0b5a711d - rust_begin_unwind
  11:     0x776f081cf0c0 - core::panicking::panic_fmt::h5928a9348ea2bb6c
  12:     0x776f09f20c16 - core::panicking::panic_bounds_check::ha0907f8c63a361ab
  13:     0x776f0c076229 - rustc_query_impl[98026ab69133ca5a]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[98026ab69133ca5a]::query_impl::local_def_id_to_hir_id::dynamic_query::{closure#2}::{closure#0}, rustc_middle[4552a92c16cacd81]::query::erase::Erased<[u8; 8usize]>>
  14:     0x776f0c0759f6 - rustc_query_system[c5a9321c1b201b0d]::query::plumbing::try_execute_query::<rustc_query_impl[98026ab69133ca5a]::DynamicConfig<rustc_data_structures[41b15b2b138651fb]::vec_cache::VecCache<rustc_span[5501a71f8d28de35]::def_id::LocalDefId, rustc_middle[4552a92c16cacd81]::query::erase::Erased<[u8; 8usize]>, rustc_query_system[c5a9321c1b201b0d]::dep_graph::graph::DepNodeIndex>, false, false, false>, rustc_query_impl[98026ab69133ca5a]::plumbing::QueryCtxt, false>
  15:     0x776f0c07544f - rustc_query_impl[98026ab69133ca5a]::query_impl::local_def_id_to_hir_id::get_query_non_incr::__rust_end_short_backtrace
  16:     0x776f0d510cf0 - rustc_middle[4552a92c16cacd81]::query::plumbing::query_get_at::<rustc_data_structures[41b15b2b138651fb]::vec_cache::VecCache<rustc_span[5501a71f8d28de35]::def_id::LocalDefId, rustc_middle[4552a92c16cacd81]::query::erase::Erased<[u8; 8usize]>, rustc_query_system[c5a9321c1b201b0d]::dep_graph::graph::DepNodeIndex>>.cold
  17:     0x776f0ab86c3e - <rustc_middle[4552a92c16cacd81]::ty::context::TyCtxt>::has_attr::<rustc_span[5501a71f8d28de35]::def_id::DefId>
  18:     0x776f0ac0c7e9 - <rustc_lint[7d30a3ff3ade0185]::internal::Diagnostics as rustc_lint[7d30a3ff3ade0185]::passes::LateLintPass>::check_expr
  19:     0x776f0ac0ddd5 - <rustc_lint[7d30a3ff3ade0185]::late::LateContextAndPass<rustc_lint[7d30a3ff3ade0185]::late::RuntimeCombinedLateLintPass> as rustc_hir[5766cc08b8b964b9]::intravisit::Visitor>::visit_expr::{closure#0}
  20:     0x776f0ac0dc7d - <rustc_lint[7d30a3ff3ade0185]::late::LateContextAndPass<rustc_lint[7d30a3ff3ade0185]::late::RuntimeCombinedLateLintPass> as rustc_hir[5766cc08b8b964b9]::intravisit::Visitor>::visit_expr
  21:     0x776f0ac0eba8 - <rustc_lint[7d30a3ff3ade0185]::late::LateContextAndPass<rustc_lint[7d30a3ff3ade0185]::late::RuntimeCombinedLateLintPass> as rustc_hir[5766cc08b8b964b9]::intravisit::Visitor>::visit_block
  22:     0x776f0ac0e5ed - <rustc_lint[7d30a3ff3ade0185]::late::LateContextAndPass<rustc_lint[7d30a3ff3ade0185]::late::RuntimeCombinedLateLintPass> as rustc_hir[5766cc08b8b964b9]::intravisit::Visitor>::visit_expr::{closure#0}
  23:     0x776f0ac0dc7d - <rustc_lint[7d30a3ff3ade0185]::late::LateContextAndPass<rustc_lint[7d30a3ff3ade0185]::late::RuntimeCombinedLateLintPass> as rustc_hir[5766cc08b8b964b9]::intravisit::Visitor>::visit_expr
  24:     0x776f0ac0e1db - <rustc_lint[7d30a3ff3ade0185]::late::LateContextAndPass<rustc_lint[7d30a3ff3ade0185]::late::RuntimeCombinedLateLintPass> as rustc_hir[5766cc08b8b964b9]::intravisit::Visitor>::visit_expr::{closure#0}
  25:     0x776f0ac0dc7d - <rustc_lint[7d30a3ff3ade0185]::late::LateContextAndPass<rustc_lint[7d30a3ff3ade0185]::late::RuntimeCombinedLateLintPass> as rustc_hir[5766cc08b8b964b9]::intravisit::Visitor>::visit_expr
  26:     0x776f0ab90949 - rustc_hir[5766cc08b8b964b9]::intravisit::walk_block::<rustc_lint[7d30a3ff3ade0185]::late::LateContextAndPass<rustc_lint[7d30a3ff3ade0185]::late::RuntimeCombinedLateLintPass>>
  27:     0x776f0ac0eba8 - <rustc_lint[7d30a3ff3ade0185]::late::LateContextAndPass<rustc_lint[7d30a3ff3ade0185]::late::RuntimeCombinedLateLintPass> as rustc_hir[5766cc08b8b964b9]::intravisit::Visitor>::visit_block
  28:     0x776f0ac0e5ed - <rustc_lint[7d30a3ff3ade0185]::late::LateContextAndPass<rustc_lint[7d30a3ff3ade0185]::late::RuntimeCombinedLateLintPass> as rustc_hir[5766cc08b8b964b9]::intravisit::Visitor>::visit_expr::{closure#0}
  29:     0x776f0ac0dc7d - <rustc_lint[7d30a3ff3ade0185]::late::LateContextAndPass<rustc_lint[7d30a3ff3ade0185]::late::RuntimeCombinedLateLintPass> as rustc_hir[5766cc08b8b964b9]::intravisit::Visitor>::visit_expr
  30:     0x776f0ac0e39b - <rustc_lint[7d30a3ff3ade0185]::late::LateContextAndPass<rustc_lint[7d30a3ff3ade0185]::late::RuntimeCombinedLateLintPass> as rustc_hir[5766cc08b8b964b9]::intravisit::Visitor>::visit_expr::{closure#0}
  31:     0x776f0ac0dc7d - <rustc_lint[7d30a3ff3ade0185]::late::LateContextAndPass<rustc_lint[7d30a3ff3ade0185]::late::RuntimeCombinedLateLintPass> as rustc_hir[5766cc08b8b964b9]::intravisit::Visitor>::visit_expr
  32:     0x776f0ab90949 - rustc_hir[5766cc08b8b964b9]::intravisit::walk_block::<rustc_lint[7d30a3ff3ade0185]::late::LateContextAndPass<rustc_lint[7d30a3ff3ade0185]::late::RuntimeCombinedLateLintPass>>
  33:     0x776f0ac0eba8 - <rustc_lint[7d30a3ff3ade0185]::late::LateContextAndPass<rustc_lint[7d30a3ff3ade0185]::late::RuntimeCombinedLateLintPass> as rustc_hir[5766cc08b8b964b9]::intravisit::Visitor>::visit_block
  34:     0x776f0ac0e5ed - <rustc_lint[7d30a3ff3ade0185]::late::LateContextAndPass<rustc_lint[7d30a3ff3ade0185]::late::RuntimeCombinedLateLintPass> as rustc_hir[5766cc08b8b964b9]::intravisit::Visitor>::visit_expr::{closure#0}
  35:     0x776f0ac0dc7d - <rustc_lint[7d30a3ff3ade0185]::late::LateContextAndPass<rustc_lint[7d30a3ff3ade0185]::late::RuntimeCombinedLateLintPass> as rustc_hir[5766cc08b8b964b9]::intravisit::Visitor>::visit_expr
  36:     0x776f0ac0df32 - <rustc_lint[7d30a3ff3ade0185]::late::LateContextAndPass<rustc_lint[7d30a3ff3ade0185]::late::RuntimeCombinedLateLintPass> as rustc_hir[5766cc08b8b964b9]::intravisit::Visitor>::visit_expr::{closure#0}
  37:     0x776f0ac0dc7d - <rustc_lint[7d30a3ff3ade0185]::late::LateContextAndPass<rustc_lint[7d30a3ff3ade0185]::late::RuntimeCombinedLateLintPass> as rustc_hir[5766cc08b8b964b9]::intravisit::Visitor>::visit_expr
  38:     0x776f0ac0eba8 - <rustc_lint[7d30a3ff3ade0185]::late::LateContextAndPass<rustc_lint[7d30a3ff3ade0185]::late::RuntimeCombinedLateLintPass> as rustc_hir[5766cc08b8b964b9]::intravisit::Visitor>::visit_block
  39:     0x776f0ac0e5ed - <rustc_lint[7d30a3ff3ade0185]::late::LateContextAndPass<rustc_lint[7d30a3ff3ade0185]::late::RuntimeCombinedLateLintPass> as rustc_hir[5766cc08b8b964b9]::intravisit::Visitor>::visit_expr::{closure#0}
  40:     0x776f0ac0dc7d - <rustc_lint[7d30a3ff3ade0185]::late::LateContextAndPass<rustc_lint[7d30a3ff3ade0185]::late::RuntimeCombinedLateLintPass> as rustc_hir[5766cc08b8b964b9]::intravisit::Visitor>::visit_expr
  41:     0x776f0ac0dba3 - <rustc_lint[7d30a3ff3ade0185]::late::LateContextAndPass<rustc_lint[7d30a3ff3ade0185]::late::RuntimeCombinedLateLintPass> as rustc_hir[5766cc08b8b964b9]::intravisit::Visitor>::visit_nested_body
  42:     0x776f0ac0e6fe - <rustc_lint[7d30a3ff3ade0185]::late::LateContextAndPass<rustc_lint[7d30a3ff3ade0185]::late::RuntimeCombinedLateLintPass> as rustc_hir[5766cc08b8b964b9]::intravisit::Visitor>::visit_fn
  43:     0x776f0ac0e184 - <rustc_lint[7d30a3ff3ade0185]::late::LateContextAndPass<rustc_lint[7d30a3ff3ade0185]::late::RuntimeCombinedLateLintPass> as rustc_hir[5766cc08b8b964b9]::intravisit::Visitor>::visit_expr::{closure#0}
  44:     0x776f0ac0dc7d - <rustc_lint[7d30a3ff3ade0185]::late::LateContextAndPass<rustc_lint[7d30a3ff3ade0185]::late::RuntimeCombinedLateLintPass> as rustc_hir[5766cc08b8b964b9]::intravisit::Visitor>::visit_expr
  45:     0x776f0ac0dba3 - <rustc_lint[7d30a3ff3ade0185]::late::LateContextAndPass<rustc_lint[7d30a3ff3ade0185]::late::RuntimeCombinedLateLintPass> as rustc_hir[5766cc08b8b964b9]::intravisit::Visitor>::visit_nested_body
  46:     0x776f0ac0e6fe - <rustc_lint[7d30a3ff3ade0185]::late::LateContextAndPass<rustc_lint[7d30a3ff3ade0185]::late::RuntimeCombinedLateLintPass> as rustc_hir[5766cc08b8b964b9]::intravisit::Visitor>::visit_fn
  47:     0x776f0abf914b - <rustc_lint[7d30a3ff3ade0185]::late::LateContextAndPass<rustc_lint[7d30a3ff3ade0185]::late::RuntimeCombinedLateLintPass> as rustc_hir[5766cc08b8b964b9]::intravisit::Visitor>::visit_nested_item
  48:     0x776f0c0960c0 - rustc_lint[7d30a3ff3ade0185]::lint_mod
  49:     0x776f0c095b6b - rustc_query_impl[98026ab69133ca5a]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[98026ab69133ca5a]::query_impl::lint_mod::dynamic_query::{closure#2}::{closure#0}, rustc_middle[4552a92c16cacd81]::query::erase::Erased<[u8; 0usize]>>
  50:     0x776f0ce0ba01 - rustc_query_system[c5a9321c1b201b0d]::query::plumbing::try_execute_query::<rustc_query_impl[98026ab69133ca5a]::DynamicConfig<rustc_query_system[c5a9321c1b201b0d]::query::caches::DefaultCache<rustc_span[5501a71f8d28de35]::def_id::LocalModDefId, rustc_middle[4552a92c16cacd81]::query::erase::Erased<[u8; 0usize]>>, false, false, false>, rustc_query_impl[98026ab69133ca5a]::plumbing::QueryCtxt, false>
  51:     0x776f0ce09bd8 - rustc_query_impl[98026ab69133ca5a]::query_impl::lint_mod::get_query_non_incr::__rust_end_short_backtrace
  52:     0x776f0ce097c2 - rustc_lint[7d30a3ff3ade0185]::late::check_crate::{closure#1}
  53:     0x776f0ce09338 - rustc_lint[7d30a3ff3ade0185]::late::check_crate
  54:     0x776f0ce0cb5d - rustc_interface[cf66c2394d3c8572]::passes::analysis
  55:     0x776f0ce0c8ef - rustc_query_impl[98026ab69133ca5a]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[98026ab69133ca5a]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[4552a92c16cacd81]::query::erase::Erased<[u8; 0usize]>>
  56:     0x776f0ce41015 - rustc_query_system[c5a9321c1b201b0d]::query::plumbing::try_execute_query::<rustc_query_impl[98026ab69133ca5a]::DynamicConfig<rustc_query_system[c5a9321c1b201b0d]::query::caches::SingleCache<rustc_middle[4552a92c16cacd81]::query::erase::Erased<[u8; 0usize]>>, false, false, false>, rustc_query_impl[98026ab69133ca5a]::plumbing::QueryCtxt, false>
  57:     0x776f0ce40d4e - rustc_query_impl[98026ab69133ca5a]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
  58:     0x776f0ceb61b4 - rustc_interface[cf66c2394d3c8572]::interface::run_compiler::<(), rustc_driver_impl[2cc745b14baadf]::run_compiler::{closure#0}>::{closure#1}
  59:     0x776f0cd685db - std[70002648da4681c1]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[cf66c2394d3c8572]::util::run_in_thread_with_globals<rustc_interface[cf66c2394d3c8572]::util::run_in_thread_pool_with_globals<rustc_interface[cf66c2394d3c8572]::interface::run_compiler<(), rustc_driver_impl[2cc745b14baadf]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
  60:     0x776f0cd68a90 - <<std[70002648da4681c1]::thread::Builder>::spawn_unchecked_<rustc_interface[cf66c2394d3c8572]::util::run_in_thread_with_globals<rustc_interface[cf66c2394d3c8572]::util::run_in_thread_pool_with_globals<rustc_interface[cf66c2394d3c8572]::interface::run_compiler<(), rustc_driver_impl[2cc745b14baadf]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[3b8d2fc2756ea0bb]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  61:     0x776f0cd6a06f - std::sys::pal::unix::thread::Thread::new::thread_start::hdeaa41b2ac9b4ad7
  62:     0x776f06ea339d - <unknown>
  63:     0x776f06f2849c - <unknown>
  64:                0x0 - <unknown>

error: 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: please make sure that you have updated to the latest nightly

note: rustc 1.85.0-nightly (4790a435c 2024-12-15) running on x86_64-unknown-linux-gnu

note: compiler flags: -Z unstable-options --crate-type lib -Z dump-mir-dir=dir

query stack during panic:
#0 [local_def_id_to_hir_id] getting HIR ID of `async_closure::{closure#0}::{closure#0}::{closure#1}`
#1 [lint_mod] linting top-level module
end of query stack

@matthiaskrgr matthiaskrgr added C-bug Category: This is a bug. F-async_closure `#![feature(async_closure)]` 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 Dec 15, 2024
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Dec 15, 2024
@matthiaskrgr
Copy link
Member Author

//@compile-flags: -Zunstable-options --edition=2021 --crate-type=lib

#![feature(async_closure)]
pub async fn async_closure(x: &mut i32) {
    let c = async move || {
        *x += 1;
    };
    call_once(c).await;
}

fn call_once<T>(f: impl FnOnce() -> T) -> T {
    f()
}

bisects to #128506

@compiler-errors compiler-errors self-assigned this Dec 15, 2024
@compiler-errors compiler-errors added requires-nightly This issue requires a nightly compiler in some way. and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Dec 15, 2024
@matthiaskrgr matthiaskrgr added the S-bug-has-test Status: This bug is tracked inside the repo by a `known-bug` test. label Dec 16, 2024
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. F-async_closure `#![feature(async_closure)]` I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ requires-nightly This issue requires a nightly compiler in some way. S-bug-has-test Status: This bug is tracked inside the repo by a `known-bug` test. 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

3 participants