Skip to content

ICE compiler/rustc_query_system/src/dep_graph/query.rs index out of bounds #142152

Open
@matthiaskrgr

Description

@matthiaskrgr

Code

compile with -Zquery-dep-graph -Zthreads=4 -Cincremental=/tmp/ -Zincremental-verify-ich=yes --edition=2024 --crate-type lib

This will sometimes ICE, around 1/10 times for me

pub trait Associate {
    type Associated;
}

pub struct Wrap<'a> {
    pub field: &'a i32,
}

pub trait Create<T> {
    fn create() -> Self;
}

pub fn oh_no<'a, T>()
where
    Wrap<'a>: Associate,
    <Wrap<'a> as Associate>::Associated: Create<T>,
{
    <Wrap<'a> as Associate>::Associated::create();
}

pub fn main() {}

Meta

rustc --version --verbose:

rustc 1.89.0-nightly (c57119b9a 2025-06-07)
binary: rustc
commit-hash: c57119b9a1c86968188bb9703a7859c17f8bc71c
commit-date: 2025-06-07
host: x86_64-unknown-linux-gnu
release: 1.89.0-nightly
LLVM version: 20.1.5

Error output

thread 'rustc' panicked at compiler/rustc_query_system/src/dep_graph/query.rs:31:49:
index out of bounds: the len is 122 but the index is 523
stack backtrace:
   0:     0x724e3390ef53 - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::haf62842818d14700
   1:     0x724e34002cb7 - core::fmt::write::hcbc7f51ba008f803
   2:     0x724e33904c63 - std::io::Write::write_fmt::hae893cdefa15425e
   3:     0x724e3390edb2 - std::sys::backtrace::BacktraceLock::print::ha054f106f07b7628
   4:     0x724e3391299a - std::panicking::default_hook::{{closure}}::h7f764cabab3db86e
   5:     0x724e3391251f - std::panicking::default_hook::h014d489547013991
   6:     0x724e32a14343 - std[c475a882e07ae63]::panicking::update_hook::<alloc[81a84acdd818619f]::boxed::Box<rustc_driver_impl[521b9eae2fc4e103]::install_ice_hook::{closure#1}>>::{closure#0}
   7:     0x724e33913203 - std::panicking::rust_panic_with_hook::h09797f209f5eff9b
   8:     0x724e33912efa - std::panicking::begin_panic_handler::{{closure}}::h9e770369565c83a5
   9:     0x724e3390f429 - std::sys::backtrace::__rust_end_short_backtrace::h74b6f9a68b0bb61f
  10:     0x724e33912bcd - __rustc[68e581a04d2baff0]::rust_begin_unwind
  11:     0x724e30076700 - core::panicking::panic_fmt::hd3bdf9865accc11f
  12:     0x724e3209d3a3 - core::panicking::panic_bounds_check::h9cebfb3d6917ee12
  13:     0x724e334494c4 - <rustc_query_system[5096c0469bfd6733]::dep_graph::query::DepGraphQuery>::push
  14:     0x724e33303e56 - rustc_data_structures[48b81750ed2870a8]::outline::<<rustc_query_system[5096c0469bfd6733]::dep_graph::serialized::EncoderState<rustc_middle[ecaecb1147c2deb2]::dep_graph::DepsType>>::record<<rustc_query_system[5096c0469bfd6733]::dep_graph::serialized::EncoderState<rustc_middle[ecaecb1147c2deb2]::dep_graph::DepsType>>::encode_promoted_node::{closure#0}>::{closure#0}, ()>
  15:     0x724e34462911 - <rustc_query_system[5096c0469bfd6733]::dep_graph::graph::DepGraphData<rustc_middle[ecaecb1147c2deb2]::dep_graph::DepsType>>::try_mark_previous_green::<rustc_query_impl[70af034b9e771977]::plumbing::QueryCtxt>
  16:     0x724e34da5136 - <rustc_query_system[5096c0469bfd6733]::dep_graph::graph::DepGraphData<rustc_middle[ecaecb1147c2deb2]::dep_graph::DepsType>>::try_mark_green::<rustc_query_impl[70af034b9e771977]::plumbing::QueryCtxt>
  17:     0x724e34d9bd1d - rustc_query_system[5096c0469bfd6733]::query::plumbing::ensure_must_run::<rustc_query_impl[70af034b9e771977]::DynamicConfig<rustc_query_system[5096c0469bfd6733]::query::caches::SingleCache<rustc_middle[ecaecb1147c2deb2]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[70af034b9e771977]::plumbing::QueryCtxt>
  18:     0x724e3546ef1e - rustc_query_impl[70af034b9e771977]::query_impl::proc_macro_decls_static::get_query_incr::__rust_end_short_backtrace
  19:     0x724e32e0733d - rayon_core[7170aa47ed7daee8]::scope::scope::<rustc_data_structures[48b81750ed2870a8]::sync::parallel::scope<rustc_interface[bbfabb48a2aa6e29]::passes::run_required_analyses::{closure#0}::{closure#1}::{closure#0}, ()>::{closure#0}, rustc_data_structures[48b81750ed2870a8]::marker::FromDyn<()>>::{closure#0}
  20:     0x724e342b9a48 - rustc_interface[bbfabb48a2aa6e29]::passes::analysis
  21:     0x724e342b8c75 - rustc_query_impl[70af034b9e771977]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[70af034b9e771977]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[ecaecb1147c2deb2]::query::erase::Erased<[u8; 0usize]>>
  22:     0x724e35532e82 - rustc_query_system[5096c0469bfd6733]::query::plumbing::try_execute_query::<rustc_query_impl[70af034b9e771977]::DynamicConfig<rustc_query_system[5096c0469bfd6733]::query::caches::SingleCache<rustc_middle[ecaecb1147c2deb2]::query::erase::Erased<[u8; 0usize]>>, false, false, false>, rustc_query_impl[70af034b9e771977]::plumbing::QueryCtxt, true>
  23:     0x724e355327a3 - rustc_query_impl[70af034b9e771977]::query_impl::analysis::get_query_incr::__rust_end_short_backtrace
  24:     0x724e354f603f - rustc_interface[bbfabb48a2aa6e29]::passes::create_and_enter_global_ctxt::<core[c83a95fd3175649b]::option::Option<rustc_interface[bbfabb48a2aa6e29]::queries::Linker>, rustc_driver_impl[521b9eae2fc4e103]::run_compiler::{closure#0}::{closure#2}>::{closure#2}::{closure#0}
  25:     0x724e35345b70 - rustc_interface[bbfabb48a2aa6e29]::interface::run_compiler::<(), rustc_driver_impl[521b9eae2fc4e103]::run_compiler::{closure#0}>::{closure#1}
  26:     0x724e32a28d94 - <rayon_core[7170aa47ed7daee8]::job::StackJob<rayon_core[7170aa47ed7daee8]::latch::LatchRef<rayon_core[7170aa47ed7daee8]::latch::LockLatch>, <rayon_core[7170aa47ed7daee8]::registry::Registry>::in_worker_cold<<rayon_core[7170aa47ed7daee8]::thread_pool::ThreadPool>::install<rustc_interface[bbfabb48a2aa6e29]::util::run_in_thread_pool_with_globals<rustc_interface[bbfabb48a2aa6e29]::interface::run_compiler<(), rustc_driver_impl[521b9eae2fc4e103]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#5}::{closure#0}::{closure#1}::{closure#0}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()> as rayon_core[7170aa47ed7daee8]::job::Job>::execute
  27:     0x724e3252f01e - <rayon_core[7170aa47ed7daee8]::registry::WorkerThread>::wait_until_cold
  28:     0x724e3252c9a1 - <rayon_core[7170aa47ed7daee8]::registry::ThreadBuilder>::run
  29:     0x724e32a0a8bd - std[c475a882e07ae63]::sys::backtrace::__rust_begin_short_backtrace::<<rayon_core[7170aa47ed7daee8]::ThreadPoolBuilder>::build_scoped<rustc_interface[bbfabb48a2aa6e29]::util::run_in_thread_pool_with_globals<rustc_interface[bbfabb48a2aa6e29]::interface::run_compiler<(), rustc_driver_impl[521b9eae2fc4e103]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#5}::{closure#0}::{closure#0}, rustc_interface[bbfabb48a2aa6e29]::util::run_in_thread_pool_with_globals<rustc_interface[bbfabb48a2aa6e29]::interface::run_compiler<(), rustc_driver_impl[521b9eae2fc4e103]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#5}::{closure#0}::{closure#1}, ()>::{closure#0}::{closure#0}::{closure#0}, ()>
  30:     0x724e32a19862 - <<std[c475a882e07ae63]::thread::Builder>::spawn_unchecked_<<rayon_core[7170aa47ed7daee8]::ThreadPoolBuilder>::build_scoped<rustc_interface[bbfabb48a2aa6e29]::util::run_in_thread_pool_with_globals<rustc_interface[bbfabb48a2aa6e29]::interface::run_compiler<(), rustc_driver_impl[521b9eae2fc4e103]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#5}::{closure#0}::{closure#0}, rustc_interface[bbfabb48a2aa6e29]::util::run_in_thread_pool_with_globals<rustc_interface[bbfabb48a2aa6e29]::interface::run_compiler<(), rustc_driver_impl[521b9eae2fc4e103]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#5}::{closure#0}::{closure#1}, ()>::{closure#0}::{closure#0}::{closure#0}, ()>::{closure#1} as core[c83a95fd3175649b]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  31:     0x724e352a62bd - std::sys::pal::unix::thread::Thread::new::thread_start::h44a4c2b992fd9536
  32:     0x724e2eca57eb - <unknown>
  33:     0x724e2ed2918c - <unknown>
  34:                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: please attach the file at `/tmp/glacier2/fixed/rustc-ice-2025-06-07T09_54_25-2892720.txt` to your bug report

note: compiler flags: -Z query-dep-graph -Z threads=4 -C incremental=[REDACTED] -Z incremental-verify-ich=yes --crate-type lib

query stack during panic:
#0 [analysis] running analysis passes on this crate
end of query stack
Backtrace

<backtrace>

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-incr-compArea: Incremental compilationA-parallel-compilerArea: parallel compilerC-bugCategory: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️S-has-mcveStatus: A Minimal Complete and Verifiable Example has been found for this issueT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions