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: compiler/rustc_metadata/src/rmeta/decoder/cstore_impl.rs:595:32: uninterned StableCrateId #112700

Open
bjorn3 opened this issue Jun 16, 2023 · 18 comments
Assignees
Labels
A-incr-comp Area: Incremental compilation C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ P-medium Medium priority regression-from-stable-to-stable Performance or correctness regression from one stable version to another. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Milestone

Comments

@bjorn3
Copy link
Member

bjorn3 commented Jun 16, 2023

I tried this code:

./x.py build compiler/rustc_codegen_cranelift

with the compiler profile which enables incr comp.

I expected to see this happen: It worked.

Instead, this happened: Got an incr comp related ICE.

Meta

Base commit is c84d5e7. Commit of the previous build is bjorn3@15d3eee.

Backtrace

error: internal compiler error: compiler/rustc_metadata/src/rmeta/decoder/cstore_impl.rs:595:32: uninterned StableCrateId: StableCrateId(16163198275912615384)

thread 'rustc' panicked at 'Box<dyn Any>', /rustc/eff24c06d8f4397802b546aa2e52450e1022fc02/compiler/rustc_errors/src/lib.rs:1651:9
stack backtrace:
   0: std::panicking::begin_panic::<rustc_errors::ExplicitBug>
   1: <rustc_errors::HandlerInner>::bug::<alloc::string::String>
   2: <rustc_errors::Handler>::bug::<alloc::string::String>
   3: rustc_middle::util::bug::opt_span_bug_fmt::<rustc_span::span_encoding::Span>::{closure#0}
   4: rustc_middle::ty::context::tls::with_opt::<rustc_middle::util::bug::opt_span_bug_fmt<rustc_span::span_encoding::Span>::{closure#0}, !>::{closure#0}
   5: rustc_middle::ty::context::tls::with_context_opt::<rustc_middle::ty::context::tls::with_opt<rustc_middle::util::bug::opt_span_bug_fmt<rustc_span::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
   6: rustc_middle::util::bug::bug_fmt
   7: <rustc_metadata::creader::CStore as rustc_session::cstore::CrateStore>::stable_crate_id_to_crate_num
   8: <rustc_span::span_encoding::Span as rustc_serialize::serialize::Decodable<rustc_middle::query::on_disk_cache::CacheDecoder>>::decode
   9: <alloc::vec::Vec<(rustc_middle::ty::Predicate, rustc_span::span_encoding::Span)> as alloc::vec::spec_from_iter::SpecFromIter<(rustc_middle::ty::Predicate, rustc_span::span_encoding::Span), core::iter::adapters::map::Map<core::ops::range::Range<usize>, <[(rustc_middle::ty::Predicate, rustc_span::span_encoding::Span)] as rustc_middle::ty::codec::RefDecodable<rustc_middle::query::on_disk_cache::CacheDecoder>>::decode::{closure#0}>>>::from_iter
  10: <[(rustc_middle::ty::Predicate, rustc_span::span_encoding::Span)] as rustc_middle::ty::codec::RefDecodable<rustc_middle::query::on_disk_cache::CacheDecoder>>::decode
  11: <rustc_middle::query::on_disk_cache::OnDiskCache>::load_indexed::<rustc_middle::ty::generics::GenericPredicates>
  12: rustc_query_impl::plumbing::try_load_from_disk::<rustc_middle::ty::generics::GenericPredicates>
  13: <rustc_query_impl::query_impl::implied_predicates_of::dynamic_query::{closure#6} as core::ops::function::FnOnce<(rustc_middle::ty::context::TyCtxt, &rustc_span::def_id::DefId, rustc_query_system::dep_graph::serialized::SerializedDepNodeIndex, rustc_query_system::dep_graph::graph::DepNodeIndex)>>::call_once
  14: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::DynamicConfig<rustc_query_system::query::caches::DefaultCache<rustc_span::def_id::DefId, rustc_middle::query::erase::Erased<[u8; 24]>>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, true>
  15: rustc_middle::query::plumbing::query_get_at::<rustc_query_system::query::caches::DefaultCache<rustc_span::def_id::DefId, rustc_middle::query::erase::Erased<[u8; 24]>>>
  16: <rustc_privacy::ReachEverythingInTheInterfaceVisitor>::predicates
  17: <rustc_privacy::EmbargoVisitor as rustc_hir::intravisit::Visitor>::visit_item
  18: <rustc_middle::hir::map::Map>::visit_all_item_likes_in_crate::<rustc_privacy::EmbargoVisitor>
  19: rustc_privacy::effective_visibilities
  20: rustc_passes::stability::check_unused_or_stable_features
  21: <rustc_session::session::Session>::time::<(), rustc_interface::passes::analysis::{closure#0}::{closure#2}::{closure#0}>
  22: rustc_interface::passes::analysis
  23: <rustc_interface::queries::QueryResult<&rustc_middle::ty::context::GlobalCtxt>>::enter::<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_driver_impl::run_compiler::{closure#1}::{closure#2}::{closure#4}>
  24: <rustc_interface::interface::Compiler>::enter::<rustc_driver_impl::run_compiler::{closure#1}::{closure#2}, core::result::Result<core::option::Option<rustc_interface::queries::Linker>, rustc_span::ErrorGuaranteed>>
  25: <scoped_tls::ScopedKey<rustc_span::SessionGlobals>>::set::<rustc_interface::interface::run_compiler<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_driver_impl::run_compiler::{closure#1}>::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

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.71.0-beta.1 (eff24c06d 2023-05-29) running on aarch64-unknown-linux-gnu

note: compiler flags: --crate-type dylib -C opt-level=3 -C embed-bitcode=no -C debuginfo=0 -Z unstable-options -C incremental=[REDACTED] -C symbol-mangling-version=v0 -Z unstable-options -Z macro-backtrace -C link-args=-Wl,-z,origin -C link-args=-Wl,-rpath,$ORIGIN/../lib -C split-debuginfo=off -C llvm-args=-import-instr-limit=10 -Z binary-dep-depinfo -Z force-unstable-if-unmarked

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

query stack during panic:
thread panicked while processing panic. aborting.
rustc exited with signal: 6 (SIGABRT) (core dumped)
error: could not compile `rustc_codegen_cranelift` (lib)

@bjorn3 bjorn3 added I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ C-bug Category: This is a bug. labels Jun 16, 2023
@bjorn3
Copy link
Member Author

bjorn3 commented Jun 16, 2023

cc @jyn514 looks like #111329 didn't fix everything yet.

@jyn514
Copy link
Member

jyn514 commented Jun 16, 2023

This is an ICE in beta, not stage 1. So this is probably a real incr comp bug, not a bug in bootstrap..

@jyn514 jyn514 added the A-incr-comp Area: Incremental compilation label Jun 16, 2023
@jyn514 jyn514 changed the title Bootstrap error: internal compiler error: compiler/rustc_metadata/src/rmeta/decoder/cstore_impl.rs:595:32: uninterned StableCrateId: StableCrateId(16163198275912615384) ICE: compiler/rustc_metadata/src/rmeta/decoder/cstore_impl.rs:595:32: uninterned StableCrateId Jun 16, 2023
@jyn514
Copy link
Member

jyn514 commented Jun 16, 2023

#88488 might be related.

@jyn514 jyn514 added this to the 1.71.0 milestone Jul 2, 2023
@jyn514 jyn514 added the regression-from-stable-to-beta Performance or correctness regression from stable to beta. label Jul 3, 2023
@rustbot rustbot added the I-prioritize Issue: Indicates that prioritization has been requested for this issue. label Jul 3, 2023
@dpaoliello
Copy link
Contributor

I'm reliably hitting this using x86_64-pc-windows-msvc. Please let me know if you need any info to debug it.

@apiraino apiraino added T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. and removed T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) labels Aug 12, 2023
@michaelwoerister
Copy link
Member

@dpaoliello, did you start seeing this with the current stable release (1.71)?

I'll try to take a look at this some time this week. @bjorn3's reproducer is small which should be very helpful. I could imagine that for some reason the StableCrateId is being read from the wrong position. Span has custom (de)serialization code which increases the likelihood that serialization and deserialization code go out of sync.

@michaelwoerister michaelwoerister self-assigned this Aug 14, 2023
@dpaoliello
Copy link
Contributor

With the beta release (1.72), specifically when building the Rust compiler itself, the bootstrap compiler raises this error when building rustdoc.

Building tool rustdoc (stage0 -> stage1, x86_64-pc-windows-msvc)
   Compiling rustdoc v0.0.0 (D:\Repos\rust.public\src\librustdoc)
error: internal compiler error: compiler\rustc_metadata\src\rmeta\decoder\cstore_impl.rs:603:32: uninterned StableCrateId: StableCrateId(1692878147909482118)

thread 'rustc' panicked at 'Box<dyn Any>', /rustc/7ba605cd90d6467bda469d1cd2148ac32ea562bf\compiler\rustc_errors\src\lib.rs:1651:9
stack backtrace:
   0:     0x7ffffd04848c - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::hd8a71b9cc1213453
   1:     0x7ffffd08213b - core::fmt::write::h2137bd4839ff36b0
   2:     0x7ffffd03d62f - <std::io::IoSliceMut as core::fmt::Debug>::fmt::h2215e92ef84aa7da
   3:     0x7ffffd04823b - std::sys::common::alloc::realloc_fallback::h089c830c192939e7
   4:     0x7ffffd04baaa - std::panicking::default_hook::hc0f8a3f459953916
   5:     0x7ffffd04b6ff - std::panicking::default_hook::hc0f8a3f459953916
   6:     0x7fffd2210030 - rustc_driver_impl[231c8e5c2de9bfe0]::describe_lints
   7:     0x7ffffd04c3a8 - std::panicking::rust_panic_with_hook::hb839fb7d70d57722
   8:     0x7fffd336fd33 - <rustc_middle[5485c56beb31a715]::ty::generics::GenericPredicates as core[d3dc892524d4bdc1]::fmt::Debug>::fmt
   9:     0x7fffd336f979 - <rustc_middle[5485c56beb31a715]::ty::generics::GenericPredicates as core[d3dc892524d4bdc1]::fmt::Debug>::fmt
  10:     0x7fffd32c6cd9 - <rustc_middle[5485c56beb31a715]::ty::typeck_results::UserType as rustc_middle[5485c56beb31a715]::ty::context::Lift>::lift_to_tcx
  11:     0x7fffd33038f0 - rustc_middle[5485c56beb31a715]::ty::context::tls::TLV::__getit::destroy
  12:     0x7fffd33036cc - rustc_middle[5485c56beb31a715]::ty::context::tls::TLV::__getit::destroy
  13:     0x7fffd32f173d - rustc_middle[5485c56beb31a715]::util::bug::bug_fmt
  14:     0x7fffd32f07cd - <rustc_middle[5485c56beb31a715]::ty::visit::MaxUniverse as rustc_type_ir[255c775d6553f7f2]::visit::TypeVisitor<rustc_middle[5485c56beb31a715]::ty::context::TyCtxt>>::visit_region
  15:     0x7fffd32f078f - <rustc_middle[5485c56beb31a715]::ty::visit::MaxUniverse as rustc_type_ir[255c775d6553f7f2]::visit::TypeVisitor<rustc_middle[5485c56beb31a715]::ty::context::TyCtxt>>::visit_region
  16:     0x7fffd32f162f - rustc_middle[5485c56beb31a715]::util::bug::bug_fmt
  17:     0x7fffd1c535ba - <rustc_metadata[dd375fd090dff413]::creader::CStore as rustc_session[ead9e1dae2a1643]::cstore::CrateStore>::stable_crate_id_to_crate_num
  18:     0x7fffd2131e83 - <rustc_span[d0b2ccbe9022bf3e]::span_encoding::Span as rustc_serialize[525a20fe883ba736]::serialize::Decodable<rustc_middle[5485c56beb31a715]::query::on_disk_cache::CacheDecoder>>::decode
  19:     0x7fffd1b4cbb0 - rustc_query_impl[d28c8893f84bf7f3]::query_callbacks
  20:     0x7fffd1b9e5b0 - rustc_query_impl[d28c8893f84bf7f3]::query_callbacks
  21:     0x7fffd1be089a - rustc_query_impl[d28c8893f84bf7f3]::query_callbacks
  22:     0x7fffd1fbc46a - rustc_trait_selection[7a6ef23f8cdce67d]::traits::wf::predicate_obligations
  23:     0x7fffd1faf4c8 - rustc_trait_selection[7a6ef23f8cdce67d]::traits::wf::obligations
  24:     0x7fffd1f2cded - rustc_trait_selection[7a6ef23f8cdce67d]::traits::query::type_op::implied_outlives_bounds::compute_implied_outlives_bounds_inner
  25:     0x7fffd1ae9101 - <rustc_borrowck[94dfdb82f7484f14]::type_check::relate_tys::NllTypeRelatingDelegate as rustc_infer[f2afe29e7d82f4b0]::infer::nll_relate::TypeRelatingDelegate>::push_outlives
  26:     0x7fffd1ada9d4 - <rustc_borrowck[94dfdb82f7484f14]::type_check::relate_tys::NllTypeRelatingDelegate as rustc_infer[f2afe29e7d82f4b0]::infer::nll_relate::TypeRelatingDelegate>::push_outlives
  27:     0x7fffd1b4ee23 - rustc_query_impl[d28c8893f84bf7f3]::query_callbacks
  28:     0x7fffd1b4248e - rustc_query_impl[d28c8893f84bf7f3]::query_callbacks
  29:     0x7fffd0e60458 - rustc_query_impl[d28c8893f84bf7f3]::profiling_support::alloc_self_profile_query_strings
  30:     0x7fffd1b89f1f - rustc_query_impl[d28c8893f84bf7f3]::query_callbacks
  31:     0x7fffd0e5f4ff - rustc_query_impl[d28c8893f84bf7f3]::profiling_support::alloc_self_profile_query_strings
  32:     0x7fffd1fe1df2 - <rustc_infer[f2afe29e7d82f4b0]::infer::InferCtxt as rustc_trait_selection[7a6ef23f8cdce67d]::traits::outlives_bounds::InferCtxtExt>::implied_outlives_bounds
  33:     0x7fffd10edf97 - <rustc_lint[7e42441c7223ef]::types::ImproperCTypesDefinitions as rustc_lint[7e42441c7223ef]::passes::LateLintPass>::check_field_def
  34:     0x7fffd110aeff - rustc_trait_selection[7a6ef23f8cdce67d]::traits::misc::all_fields_implement_trait
  35:     0x7fffd110a9b5 - rustc_trait_selection[7a6ef23f8cdce67d]::traits::misc::type_allowed_to_implement_copy
  36:     0x7fffd0b7a963 - <rustc_hir_analysis[b698c89314d7dd88]::collect::generics_of::AnonConstInParamTyDetector as rustc_hir[ac129e4511490d5c]::intravisit::Visitor>::visit_generic_param
  37:     0x7fffd153df5b - <rustc_hir_analysis[b698c89314d7dd88]::check::region::RegionResolutionVisitor as rustc_hir[ac129e4511490d5c]::intravisit::Visitor>::visit_local
  38:     0x7fffd0e42ee5 - rustc_query_impl[d28c8893f84bf7f3]::profiling_support::alloc_self_profile_query_strings
  39:     0x7fffd0e229c3 - rustc_query_impl[d28c8893f84bf7f3]::profiling_support::alloc_self_profile_query_strings
  40:     0x7fffd0e6307f - rustc_query_impl[d28c8893f84bf7f3]::profiling_support::alloc_self_profile_query_strings
  41:     0x7fffd0e8c839 - rustc_query_impl[d28c8893f84bf7f3]::profiling_support::alloc_self_profile_query_strings
  42:     0x7fffd0e5d485 - rustc_query_impl[d28c8893f84bf7f3]::profiling_support::alloc_self_profile_query_strings
  43:     0x7fffd0bcf005 - <rustc_hir_analysis[b698c89314d7dd88]::variance::variance_of_opaque::{closure#0}::OpaqueTypeLifetimeCollector as rustc_type_ir[255c775d6553f7f2]::visit::TypeVisitor<rustc_middle[5485c56beb31a715]::ty::context::TyCtxt>>::visit_ty
  44:     0x7fffd0b69f9c - rustc_hir_analysis[b698c89314d7dd88]::check_crate
  45:     0x7fffce53ba81 - rustc_interface[d29207099cd3cfd3]::passes::analysis
  46:     0x7fffd0e454ed - rustc_query_impl[d28c8893f84bf7f3]::profiling_support::alloc_self_profile_query_strings
  47:     0x7fffd0e4c6b9 - rustc_query_impl[d28c8893f84bf7f3]::profiling_support::alloc_self_profile_query_strings
  48:     0x7fffd0e61b75 - rustc_query_impl[d28c8893f84bf7f3]::profiling_support::alloc_self_profile_query_strings
  49:     0x7fffd0e7026b - rustc_query_impl[d28c8893f84bf7f3]::profiling_support::alloc_self_profile_query_strings
  50:     0x7fffd0ee9165 - rustc_query_impl[d28c8893f84bf7f3]::profiling_support::alloc_self_profile_query_strings
  51:     0x7fffce4f85be - <rustc_middle[5485c56beb31a715]::ty::SymbolName as core[d3dc892524d4bdc1]::fmt::Display>::fmt
  52:     0x7fffce4f951d - <rustc_middle[5485c56beb31a715]::ty::SymbolName as core[d3dc892524d4bdc1]::fmt::Display>::fmt
  53:     0x7fffce4f778a - <rustc_middle[5485c56beb31a715]::ty::SymbolName as core[d3dc892524d4bdc1]::fmt::Display>::fmt
  54:     0x7fffce4f69fd - <rustc_middle[5485c56beb31a715]::ty::SymbolName as core[d3dc892524d4bdc1]::fmt::Display>::fmt
  55:     0x7fffce50d5e9 - <rustc_middle[5485c56beb31a715]::ty::SymbolName as core[d3dc892524d4bdc1]::fmt::Display>::fmt
  56:     0x7fffce50d836 - <rustc_middle[5485c56beb31a715]::ty::SymbolName as core[d3dc892524d4bdc1]::fmt::Display>::fmt
  57:     0x7ffffd05fa5c - std::sys::windows::thread::Thread::new::hc9442dda768a3297
  58:     0x7ff8902e1f88 - BaseThreadInitThunk
  59:     0x7ff8923f8241 - RtlUserThreadStart

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.72.0-beta.1 (7ba605cd9 2023-07-11) running on x86_64-pc-windows-msvc

note: compiler flags: --crate-type lib -C opt-level=3 -C embed-bitcode=no -C debuginfo=2 -C debug-assertions=on -C overflow-checks=off -Z unstable-options -C incremental=[REDACTED] -C symbol-mangling-version=v0 -Z unstable-options -Z macro-backtrace -C split-debuginfo=packed -C target-feature=+crt-static -C llvm-args=-import-instr-limit=10 -Z binary-dep-depinfo -Z tls-model=initial-exec

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

query stack during panic:
thread panicked while processing panic. aborting.

@michaelwoerister
Copy link
Member

OK, I've been able to reproduce this with the two commits given by @Ddystopia in #113266. The backtrace from a compiler built with debuginfo looks like this:

Backtrace

error: internal compiler error: compiler/rustc_metadata/src/rmeta/decoder/cstore_impl.rs:595:32: uninterned StableCrateId: StableCrateId(1632958532300426288)

thread 'rustc' panicked at 'Box<dyn Any>', rs/compiler/rustc_errors/src/lib.rs:1651:9
stack backtrace:
   0:     0x7fa500e62980 - std::backtrace_rs::backtrace::libunwind::trace::haea5f11d77a70d01
                               at rs/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
   1:     0x7fa500e62980 - std::backtrace_rs::backtrace::trace_unsynchronized::h703dd4aa7f373f38
                               at rs/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7fa500e62980 - std::sys_common::backtrace::_print_fmt::h22431bb0cb564c0f
                               at rs/library/std/src/sys_common/backtrace.rs:65:5
   3:     0x7fa500e62980 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h2333cbfc479a2fc4
                               at rs/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x7fa500eebb58 - core::fmt::rt::Argument::fmt::h13231428eb2ed796
                               at rs/library/core/src/fmt/rt.rs:138:9
   5:     0x7fa500eebb58 - core::fmt::write::h94c3a8a331226fbc
                               at rs/library/core/src/fmt/mod.rs:1094:21
   6:     0x7fa500e59621 - std::io::Write::write_fmt::h0fe6b49705fd979e
                               at rs/library/std/src/io/mod.rs:1713:15
   7:     0x7fa500e627ba - std::sys_common::backtrace::_print::heeff11ef8171ab5d
                               at rs/library/std/src/sys_common/backtrace.rs:47:5
   8:     0x7fa500e627ba - std::sys_common::backtrace::print::ha2b11e10be088438
                               at rs/library/std/src/sys_common/backtrace.rs:34:9
   9:     0x7fa500e2a864 - std::panicking::default_hook::{{closure}}::h0280d842e2119e8a
  10:     0x7fa500e2a608 - std::panicking::default_hook::hf85db8b74f83bc90
                               at rs/library/std/src/panicking.rs:288:9
  11:     0x7fa50190240c - <alloc[72fab78219be1254]::boxed::Box<dyn for<'a, 'b> core[2f8f677d0b7db0dd]::ops::function::Fn<(&'a core[2f8f677d0b7db0dd]::panic::panic_info::PanicInfo<'b>,), Output = ()> + core[2f8f677d0b7db0dd]::marker::Send + core[2f8f677d0b7db0dd]::marker::Sync> as core[2f8f677d0b7db0dd]::ops::function::Fn<(&core[2f8f677d0b7db0dd]::panic::panic_info::PanicInfo,)>>::call
                               at rs/library/alloc/src/boxed.rs:1999:9
  12:     0x7fa50190240c - rustc_driver_impl[f1098a13171d8758]::install_ice_hook::{closure#0}
                               at rs/compiler/rustc_driver_impl/src/lib.rs:1269:13
  13:     0x7fa500e2adbb - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::h676c18f966ee74c3
                               at rs/library/alloc/src/boxed.rs:1999:9
  14:     0x7fa500e2adbb - std::panicking::rust_panic_with_hook::h7a88224240b15201
                               at rs/library/std/src/panicking.rs:709:13
  15:     0x7fa50415d9d3 - std[4b153bf51e87bee0]::panicking::begin_panic::<rustc_errors[f7eace3a591cf558]::ExplicitBug>::{closure#0}
                               at rs/library/std/src/panicking.rs:626:9
  16:     0x7fa50415cb86 - std[4b153bf51e87bee0]::sys_common::backtrace::__rust_end_short_backtrace::<std[4b153bf51e87bee0]::panicking::begin_panic<rustc_errors[f7eace3a591cf558]::ExplicitBug>::{closure#0}, !>
                               at rs/library/std/src/sys_common/backtrace.rs:151:18
  17:     0x7fa50188a486 - std[4b153bf51e87bee0]::panicking::begin_panic::<rustc_errors[f7eace3a591cf558]::ExplicitBug>
                               at rs/library/std/src/panicking.rs:625:12
  18:     0x7fa5041767c6 - std[4b153bf51e87bee0]::panic::panic_any::<rustc_errors[f7eace3a591cf558]::ExplicitBug>
                               at rs/library/std/src/panic.rs:63:5
  19:     0x7fa50417610a - <rustc_errors[f7eace3a591cf558]::HandlerInner>::bug::<alloc[72fab78219be1254]::string::String>
                               at rs/compiler/rustc_errors/src/lib.rs:1651:9
  20:     0x7fa504175f44 - <rustc_errors[f7eace3a591cf558]::Handler>::bug::<alloc[72fab78219be1254]::string::String>
                               at rs/compiler/rustc_errors/src/lib.rs:1064:9
  21:     0x7fa504209910 - rustc_middle[4f9e7fc8cb0fbf47]::util::bug::opt_span_bug_fmt::<rustc_span[3250ac878e6d0468]::span_encoding::Span>::{closure#0}
                               at rs/compiler/rustc_middle/src/util/bug.rs:35:34
  22:     0x7fa5042083cc - rustc_middle[4f9e7fc8cb0fbf47]::ty::context::tls::with_opt::<rustc_middle[4f9e7fc8cb0fbf47]::util::bug::opt_span_bug_fmt<rustc_span[3250ac878e6d0468]::span_encoding::Span>::{closure#0}, !>::{closure#0}
                               at rs/compiler/rustc_middle/src/ty/context/tls.rs:154:36
  23:     0x7fa50420833a - rustc_middle[4f9e7fc8cb0fbf47]::ty::context::tls::with_context_opt::<rustc_middle[4f9e7fc8cb0fbf47]::ty::context::tls::with_opt<rustc_middle[4f9e7fc8cb0fbf47]::util::bug::opt_span_bug_fmt<rustc_span[3250ac878e6d0468]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
                               at rs/compiler/rustc_middle/src/ty/context/tls.rs:100:18
  24:     0x7fa504208377 - rustc_middle[4f9e7fc8cb0fbf47]::ty::context::tls::with_opt::<rustc_middle[4f9e7fc8cb0fbf47]::util::bug::opt_span_bug_fmt<rustc_span[3250ac878e6d0468]::span_encoding::Span>::{closure#0}, !>
                               at rs/compiler/rustc_middle/src/ty/context/tls.rs:154:5
  25:     0x7fa504209849 - rustc_middle[4f9e7fc8cb0fbf47]::util::bug::opt_span_bug_fmt::<rustc_span[3250ac878e6d0468]::span_encoding::Span>
                               at rs/compiler/rustc_middle/src/util/bug.rs:31:5
  26:     0x7fa50187b018 - rustc_middle[4f9e7fc8cb0fbf47]::util::bug::bug_fmt
                               at rs/compiler/rustc_middle/src/util/bug.rs:15:5
  27:     0x7fa503787b9c - <rustc_metadata[182cfb69743dd12d]::creader::CStore as rustc_session[db83a94508f84f1c]::cstore::CrateStore>::stable_crate_id_to_crate_num::{closure#0}
                               at rs/compiler/rustc_metadata/src/rmeta/decoder/cstore_impl.rs:595:32
  28:     0x7fa503787b9c - <core[2f8f677d0b7db0dd]::option::Option<&rustc_span[3250ac878e6d0468]::def_id::CrateNum>>::unwrap_or_else::<<rustc_metadata[182cfb69743dd12d]::creader::CStore as rustc_session[db83a94508f84f1c]::cstore::CrateStore>::stable_crate_id_to_crate_num::{closure#0}>
                               at rs/library/core/src/option.rs:979:21
  29:     0x7fa503787b9c - <rustc_metadata[182cfb69743dd12d]::creader::CStore as rustc_session[db83a94508f84f1c]::cstore::CrateStore>::stable_crate_id_to_crate_num
                               at rs/compiler/rustc_metadata/src/rmeta/decoder/cstore_impl.rs:592:10
  30:     0x7fa5041f00f1 - <rustc_middle[4f9e7fc8cb0fbf47]::ty::context::TyCtxt>::stable_crate_id_to_crate_num
                               at rs/compiler/rustc_middle/src/ty/context.rs:856:13
  31:     0x7fa5041f00f1 - <rustc_middle[4f9e7fc8cb0fbf47]::query::on_disk_cache::EncodedSourceFileId>::translate
                               at rs/compiler/rustc_middle/src/query/on_disk_cache.rs:149:20
  32:     0x7fa5041f00f1 - <rustc_middle[4f9e7fc8cb0fbf47]::query::on_disk_cache::CacheDecoder>::file_index_to_file::{closure#0}
                               at rs/compiler/rustc_middle/src/query/on_disk_cache.rs:495:33
  33:     0x7fa5041f00f1 - <std[4b153bf51e87bee0]::collections::hash::map::Entry<rustc_middle[4f9e7fc8cb0fbf47]::query::on_disk_cache::SourceFileIndex, alloc[72fab78219be1254]::rc::Rc<rustc_span[3250ac878e6d0468]::SourceFile>>>::or_insert_with::<<rustc_middle[4f9e7fc8cb0fbf47]::query::on_disk_cache::CacheDecoder>::file_index_to_file::{closure#0}>
                               at rs/library/std/src/collections/hash/map.rs:2558:43
  34:     0x7fa5041f00f1 - <rustc_middle[4f9e7fc8cb0fbf47]::query::on_disk_cache::CacheDecoder>::file_index_to_file
                               at rs/compiler/rustc_middle/src/query/on_disk_cache.rs:491:9
  35:     0x7fa5041f00f1 - <rustc_span[3250ac878e6d0468]::span_encoding::Span as rustc_serialize[69648a2a7da6d613]::serialize::Decodable<rustc_middle[4f9e7fc8cb0fbf47]::query::on_disk_cache::CacheDecoder>>::decode
                               at rs/compiler/rustc_middle/src/query/on_disk_cache.rs:692:23
  36:     0x7fa5031d3a1f - <(rustc_middle[4f9e7fc8cb0fbf47]::ty::Predicate, rustc_span[3250ac878e6d0468]::span_encoding::Span) as rustc_serialize[69648a2a7da6d613]::serialize::Decodable<rustc_middle[4f9e7fc8cb0fbf47]::query::on_disk_cache::CacheDecoder>>::decode
                               at rs/compiler/rustc_serialize/src/serialize.rs:429:43
  37:     0x7fa5031d3a1f - <[(rustc_middle[4f9e7fc8cb0fbf47]::ty::Predicate, rustc_span[3250ac878e6d0468]::span_encoding::Span)] as rustc_middle[4f9e7fc8cb0fbf47]::ty::codec::RefDecodable<rustc_middle[4f9e7fc8cb0fbf47]::query::on_disk_cache::CacheDecoder>>::decode::{closure#0}
                               at rs/compiler/rustc_middle/src/ty/codec.rs:363:47
  38:     0x7fa5031d3a1f - core[2f8f677d0b7db0dd]::iter::adapters::map::map_fold::<usize, (rustc_middle[4f9e7fc8cb0fbf47]::ty::Predicate, rustc_span[3250ac878e6d0468]::span_encoding::Span), (), <[(rustc_middle[4f9e7fc8cb0fbf47]::ty::Predicate, rustc_span[3250ac878e6d0468]::span_encoding::Span)] as rustc_middle[4f9e7fc8cb0fbf47]::ty::codec::RefDecodable<rustc_middle[4f9e7fc8cb0fbf47]::query::on_disk_cache::CacheDecoder>>::decode::{closure#0}, core[2f8f677d0b7db0dd]::iter::traits::iterator::Iterator::for_each::call<(rustc_middle[4f9e7fc8cb0fbf47]::ty::Predicate, rustc_span[3250ac878e6d0468]::span_encoding::Span), <alloc[72fab78219be1254]::vec::Vec<(rustc_middle[4f9e7fc8cb0fbf47]::ty::Predicate, rustc_span[3250ac878e6d0468]::span_encoding::Span)>>::extend_trusted<core[2f8f677d0b7db0dd]::iter::adapters::map::Map<core[2f8f677d0b7db0dd]::ops::range::Range<usize>, <[(rustc_middle[4f9e7fc8cb0fbf47]::ty::Predicate, rustc_span[3250ac878e6d0468]::span_encoding::Span)] as rustc_middle[4f9e7fc8cb0fbf47]::ty::codec::RefDecodable<rustc_middle[4f9e7fc8cb0fbf47]::query::on_disk_cache::CacheDecoder>>::decode::{closure#0}>>::{closure#0}>::{closure#0}>::{closure#0}
                               at rs/library/core/src/iter/adapters/map.rs:84:28
  39:     0x7fa5031d3a1f - <core[2f8f677d0b7db0dd]::ops::range::Range<usize> as core[2f8f677d0b7db0dd]::iter::traits::iterator::Iterator>::fold::<(), core[2f8f677d0b7db0dd]::iter::adapters::map::map_fold<usize, (rustc_middle[4f9e7fc8cb0fbf47]::ty::Predicate, rustc_span[3250ac878e6d0468]::span_encoding::Span), (), <[(rustc_middle[4f9e7fc8cb0fbf47]::ty::Predicate, rustc_span[3250ac878e6d0468]::span_encoding::Span)] as rustc_middle[4f9e7fc8cb0fbf47]::ty::codec::RefDecodable<rustc_middle[4f9e7fc8cb0fbf47]::query::on_disk_cache::CacheDecoder>>::decode::{closure#0}, core[2f8f677d0b7db0dd]::iter::traits::iterator::Iterator::for_each::call<(rustc_middle[4f9e7fc8cb0fbf47]::ty::Predicate, rustc_span[3250ac878e6d0468]::span_encoding::Span), <alloc[72fab78219be1254]::vec::Vec<(rustc_middle[4f9e7fc8cb0fbf47]::ty::Predicate, rustc_span[3250ac878e6d0468]::span_encoding::Span)>>::extend_trusted<core[2f8f677d0b7db0dd]::iter::adapters::map::Map<core[2f8f677d0b7db0dd]::ops::range::Range<usize>, <[(rustc_middle[4f9e7fc8cb0fbf47]::ty::Predicate, rustc_span[3250ac878e6d0468]::span_encoding::Span)] as rustc_middle[4f9e7fc8cb0fbf47]::ty::codec::RefDecodable<rustc_middle[4f9e7fc8cb0fbf47]::query::on_disk_cache::CacheDecoder>>::decode::{closure#0}>>::{closure#0}>::{closure#0}>::{closure#0}>
                               at rs/library/core/src/iter/traits/iterator.rs:2481:21
  40:     0x7fa5031d3a1f - <core[2f8f677d0b7db0dd]::iter::adapters::map::Map<core[2f8f677d0b7db0dd]::ops::range::Range<usize>, <[(rustc_middle[4f9e7fc8cb0fbf47]::ty::Predicate, rustc_span[3250ac878e6d0468]::span_encoding::Span)] as rustc_middle[4f9e7fc8cb0fbf47]::ty::codec::RefDecodable<rustc_middle[4f9e7fc8cb0fbf47]::query::on_disk_cache::CacheDecoder>>::decode::{closure#0}> as core[2f8f677d0b7db0dd]::iter::traits::iterator::Iterator>::fold::<(), core[2f8f677d0b7db0dd]::iter::traits::iterator::Iterator::for_each::call<(rustc_middle[4f9e7fc8cb0fbf47]::ty::Predicate, rustc_span[3250ac878e6d0468]::span_encoding::Span), <alloc[72fab78219be1254]::vec::Vec<(rustc_middle[4f9e7fc8cb0fbf47]::ty::Predicate, rustc_span[3250ac878e6d0468]::span_encoding::Span)>>::extend_trusted<core[2f8f677d0b7db0dd]::iter::adapters::map::Map<core[2f8f677d0b7db0dd]::ops::range::Range<usize>, <[(rustc_middle[4f9e7fc8cb0fbf47]::ty::Predicate, rustc_span[3250ac878e6d0468]::span_encoding::Span)] as rustc_middle[4f9e7fc8cb0fbf47]::ty::codec::RefDecodable<rustc_middle[4f9e7fc8cb0fbf47]::query::on_disk_cache::CacheDecoder>>::decode::{closure#0}>>::{closure#0}>::{closure#0}>
                               at rs/library/core/src/iter/adapters/map.rs:124:9
  41:     0x7fa50321df0f - <core[2f8f677d0b7db0dd]::iter::adapters::map::Map<core[2f8f677d0b7db0dd]::ops::range::Range<usize>, <[(rustc_middle[4f9e7fc8cb0fbf47]::ty::Predicate, rustc_span[3250ac878e6d0468]::span_encoding::Span)] as rustc_middle[4f9e7fc8cb0fbf47]::ty::codec::RefDecodable<rustc_middle[4f9e7fc8cb0fbf47]::query::on_disk_cache::CacheDecoder>>::decode::{closure#0}> as core[2f8f677d0b7db0dd]::iter::traits::iterator::Iterator>::for_each::<<alloc[72fab78219be1254]::vec::Vec<(rustc_middle[4f9e7fc8cb0fbf47]::ty::Predicate, rustc_span[3250ac878e6d0468]::span_encoding::Span)>>::extend_trusted<core[2f8f677d0b7db0dd]::iter::adapters::map::Map<core[2f8f677d0b7db0dd]::ops::range::Range<usize>, <[(rustc_middle[4f9e7fc8cb0fbf47]::ty::Predicate, rustc_span[3250ac878e6d0468]::span_encoding::Span)] as rustc_middle[4f9e7fc8cb0fbf47]::ty::codec::RefDecodable<rustc_middle[4f9e7fc8cb0fbf47]::query::on_disk_cache::CacheDecoder>>::decode::{closure#0}>>::{closure#0}>
                               at rs/library/core/src/iter/traits/iterator.rs:856:9
  42:     0x7fa50321df0f - <alloc[72fab78219be1254]::vec::Vec<(rustc_middle[4f9e7fc8cb0fbf47]::ty::Predicate, rustc_span[3250ac878e6d0468]::span_encoding::Span)>>::extend_trusted::<core[2f8f677d0b7db0dd]::iter::adapters::map::Map<core[2f8f677d0b7db0dd]::ops::range::Range<usize>, <[(rustc_middle[4f9e7fc8cb0fbf47]::ty::Predicate, rustc_span[3250ac878e6d0468]::span_encoding::Span)] as rustc_middle[4f9e7fc8cb0fbf47]::ty::codec::RefDecodable<rustc_middle[4f9e7fc8cb0fbf47]::query::on_disk_cache::CacheDecoder>>::decode::{closure#0}>>
                               at rs/library/alloc/src/vec/mod.rs:2843:17
  43:     0x7fa50321df0f - <alloc[72fab78219be1254]::vec::Vec<(rustc_middle[4f9e7fc8cb0fbf47]::ty::Predicate, rustc_span[3250ac878e6d0468]::span_encoding::Span)> as alloc[72fab78219be1254]::vec::spec_extend::SpecExtend<(rustc_middle[4f9e7fc8cb0fbf47]::ty::Predicate, rustc_span[3250ac878e6d0468]::span_encoding::Span), core[2f8f677d0b7db0dd]::iter::adapters::map::Map<core[2f8f677d0b7db0dd]::ops::range::Range<usize>, <[(rustc_middle[4f9e7fc8cb0fbf47]::ty::Predicate, rustc_span[3250ac878e6d0468]::span_encoding::Span)] as rustc_middle[4f9e7fc8cb0fbf47]::ty::codec::RefDecodable<rustc_middle[4f9e7fc8cb0fbf47]::query::on_disk_cache::CacheDecoder>>::decode::{closure#0}>>>::spec_extend
                               at rs/library/alloc/src/vec/spec_extend.rs:26:9
  44:     0x7fa50321df0f - <alloc[72fab78219be1254]::vec::Vec<(rustc_middle[4f9e7fc8cb0fbf47]::ty::Predicate, rustc_span[3250ac878e6d0468]::span_encoding::Span)> as alloc[72fab78219be1254]::vec::spec_from_iter_nested::SpecFromIterNested<(rustc_middle[4f9e7fc8cb0fbf47]::ty::Predicate, rustc_span[3250ac878e6d0468]::span_encoding::Span), core[2f8f677d0b7db0dd]::iter::adapters::map::Map<core[2f8f677d0b7db0dd]::ops::range::Range<usize>, <[(rustc_middle[4f9e7fc8cb0fbf47]::ty::Predicate, rustc_span[3250ac878e6d0468]::span_encoding::Span)] as rustc_middle[4f9e7fc8cb0fbf47]::ty::codec::RefDecodable<rustc_middle[4f9e7fc8cb0fbf47]::query::on_disk_cache::CacheDecoder>>::decode::{closure#0}>>>::from_iter
                               at rs/library/alloc/src/vec/spec_from_iter_nested.rs:62:9
  45:     0x7fa50321df0f - <alloc[72fab78219be1254]::vec::Vec<(rustc_middle[4f9e7fc8cb0fbf47]::ty::Predicate, rustc_span[3250ac878e6d0468]::span_encoding::Span)> as alloc[72fab78219be1254]::vec::spec_from_iter::SpecFromIter<(rustc_middle[4f9e7fc8cb0fbf47]::ty::Predicate, rustc_span[3250ac878e6d0468]::span_encoding::Span), core[2f8f677d0b7db0dd]::iter::adapters::map::Map<core[2f8f677d0b7db0dd]::ops::range::Range<usize>, <[(rustc_middle[4f9e7fc8cb0fbf47]::ty::Predicate, rustc_span[3250ac878e6d0468]::span_encoding::Span)] as rustc_middle[4f9e7fc8cb0fbf47]::ty::codec::RefDecodable<rustc_middle[4f9e7fc8cb0fbf47]::query::on_disk_cache::CacheDecoder>>::decode::{closure#0}>>>::from_iter
                               at rs/library/alloc/src/vec/spec_from_iter.rs:33:9
  46:     0x7fa5031e59f3 - <alloc[72fab78219be1254]::vec::Vec<(rustc_middle[4f9e7fc8cb0fbf47]::ty::Predicate, rustc_span[3250ac878e6d0468]::span_encoding::Span)> as core[2f8f677d0b7db0dd]::iter::traits::collect::FromIterator<(rustc_middle[4f9e7fc8cb0fbf47]::ty::Predicate, rustc_span[3250ac878e6d0468]::span_encoding::Span)>>::from_iter::<core[2f8f677d0b7db0dd]::iter::adapters::map::Map<core[2f8f677d0b7db0dd]::ops::range::Range<usize>, <[(rustc_middle[4f9e7fc8cb0fbf47]::ty::Predicate, rustc_span[3250ac878e6d0468]::span_encoding::Span)] as rustc_middle[4f9e7fc8cb0fbf47]::ty::codec::RefDecodable<rustc_middle[4f9e7fc8cb0fbf47]::query::on_disk_cache::CacheDecoder>>::decode::{closure#0}>>
                               at rs/library/alloc/src/vec/mod.rs:2711:9
  47:     0x7fa5031e59f3 - <core[2f8f677d0b7db0dd]::iter::adapters::map::Map<core[2f8f677d0b7db0dd]::ops::range::Range<usize>, <[(rustc_middle[4f9e7fc8cb0fbf47]::ty::Predicate, rustc_span[3250ac878e6d0468]::span_encoding::Span)] as rustc_middle[4f9e7fc8cb0fbf47]::ty::codec::RefDecodable<rustc_middle[4f9e7fc8cb0fbf47]::query::on_disk_cache::CacheDecoder>>::decode::{closure#0}> as core[2f8f677d0b7db0dd]::iter::traits::iterator::Iterator>::collect::<alloc[72fab78219be1254]::vec::Vec<(rustc_middle[4f9e7fc8cb0fbf47]::ty::Predicate, rustc_span[3250ac878e6d0468]::span_encoding::Span)>>
                               at rs/library/core/src/iter/traits/iterator.rs:1895:9
  48:     0x7fa5031e59f3 - <[(rustc_middle[4f9e7fc8cb0fbf47]::ty::Predicate, rustc_span[3250ac878e6d0468]::span_encoding::Span)] as rustc_middle[4f9e7fc8cb0fbf47]::ty::codec::RefDecodable<rustc_middle[4f9e7fc8cb0fbf47]::query::on_disk_cache::CacheDecoder>>::decode
                               at rs/compiler/rustc_middle/src/ty/codec.rs:363:13
  49:     0x7fa5031fdf62 - <rustc_middle[4f9e7fc8cb0fbf47]::ty::generics::GenericPredicates as rustc_serialize[69648a2a7da6d613]::serialize::Decodable<rustc_middle[4f9e7fc8cb0fbf47]::query::on_disk_cache::CacheDecoder>>::decode
                               at rs/compiler/rustc_middle/src/ty/generics.rs:323:52
  50:     0x7fa503158e74 - rustc_middle[4f9e7fc8cb0fbf47]::query::on_disk_cache::decode_tagged::<rustc_middle[4f9e7fc8cb0fbf47]::query::on_disk_cache::CacheDecoder, rustc_query_system[baf62fdee479b465]::dep_graph::serialized::SerializedDepNodeIndex, rustc_middle[4f9e7fc8cb0fbf47]::ty::generics::GenericPredicates>
                               at rs/compiler/rustc_middle/src/query/on_disk_cache.rs:530:17
  51:     0x7fa503158e74 - <rustc_middle[4f9e7fc8cb0fbf47]::query::on_disk_cache::OnDiskCache>::load_indexed::<rustc_middle[4f9e7fc8cb0fbf47]::ty::generics::GenericPredicates>::{closure#0}
                               at rs/compiler/rustc_middle/src/query/on_disk_cache.rs:432:59
  52:     0x7fa503158e74 - <rustc_middle[4f9e7fc8cb0fbf47]::query::on_disk_cache::OnDiskCache>::with_decoder::<rustc_middle[4f9e7fc8cb0fbf47]::ty::generics::GenericPredicates, <rustc_middle[4f9e7fc8cb0fbf47]::query::on_disk_cache::OnDiskCache>::load_indexed<rustc_middle[4f9e7fc8cb0fbf47]::ty::generics::GenericPredicates>::{closure#0}>
                               at rs/compiler/rustc_middle/src/query/on_disk_cache.rs:458:9
  53:     0x7fa503158e74 - <rustc_middle[4f9e7fc8cb0fbf47]::query::on_disk_cache::OnDiskCache>::load_indexed::<rustc_middle[4f9e7fc8cb0fbf47]::ty::generics::GenericPredicates>
                               at rs/compiler/rustc_middle/src/query/on_disk_cache.rs:432:21
  54:     0x7fa503158e74 - <rustc_middle[4f9e7fc8cb0fbf47]::query::on_disk_cache::OnDiskCache>::try_load_query_result::<rustc_middle[4f9e7fc8cb0fbf47]::ty::generics::GenericPredicates>
                               at rs/compiler/rustc_middle/src/query/on_disk_cache.rs:402:25
  55:     0x7fa50339131c - rustc_query_impl[61ca156b384b54ed]::plumbing::try_load_from_disk::<rustc_middle[4f9e7fc8cb0fbf47]::ty::generics::GenericPredicates>::{closure#0}
                               at rs/compiler/rustc_query_impl/src/plumbing.rs:409:40
  56:     0x7fa50339131c - rustc_middle[4f9e7fc8cb0fbf47]::ty::context::tls::enter_context::<rustc_query_impl[61ca156b384b54ed]::plumbing::try_load_from_disk<rustc_middle[4f9e7fc8cb0fbf47]::ty::generics::GenericPredicates>::{closure#0}, core[2f8f677d0b7db0dd]::option::Option<rustc_middle[4f9e7fc8cb0fbf47]::ty::generics::GenericPredicates>>::{closure#0}
                               at rs/compiler/rustc_middle/src/ty/context/tls.rs:82:9
  [...]

@michaelwoerister
Copy link
Member

It looks like the two sessions feed different -Cmetadata values into the StableCrateId hash of rustc_data_structures. I don't know why yet. It could be coming from Cargo or from ./x.py?

I also need to review how -Cmetadata interacts with incr. comp. cache invalidation.

@bjorn3
Copy link
Member Author

bjorn3 commented Aug 15, 2023

If there is a different StableCrateId rustc should ignore the existing incremental cache as unrelated to the current one. The StableCrateId is the identity of a crate.

@michaelwoerister
Copy link
Member

As far as I can tell, the problem here is that the HashStable impl of Span does not take the cnum field of the corresponding SourceFile into account. In some rare cases the compiler then does not detect that a value is outdated (e.g. a Span in the value comes from rustc_data_structures[123] instead of rustc_data_structures[456]) and tries to load it from the cache.

Adding source_file.cnum.hash_stable(...) to the HashStable impl of Span fixes the ICE for my test case. Another way to achieve the same result would be to unify SourceFile's name_hash field and StableSourceFileId -- i.e. mix in the StableCrateId of the originating crate into the name_hash. That might be more performant since we then don't have to do a cnum -> StableCrateId mapping during each Span::hash_stable call.

@Mark-Simulacrum Mark-Simulacrum added regression-from-stable-to-stable Performance or correctness regression from one stable version to another. and removed regression-from-stable-to-beta Performance or correctness regression from stable to beta. labels Aug 18, 2023
@surechen
Copy link
Contributor

surechen commented Dec 9, 2023

I also encountered this problem

python ./x.py test compiler/rustc_data_structures/

target: x86_64-pc-windows-msvc

cargo.toml :

[rust]

parallel-compiler = false
error: internal compiler error: compiler\rustc_metadata\src\rmeta\decoder\cstore_impl.rs:606:32: uninterned StableCrateId: StableCrateId(13189329033857301201)

thread 'rustc' panicked at /rustc/782883f609713fe9617ba64d90086742ec62d374\compiler\rustc_errors\src\lib.rs:1661:9:
Box<dyn Any>
stack backtrace:
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

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 attach the file at `D:\source\rust\rust\rustc-ice-2023-12-09T04_48_21-4316.txt` to your bug report

note: compiler flags: --crate-type lib -C opt-level=3 -C embed-bitcode=no -Z unstable-options -C incremental=[REDACTED] -C symbol-mangling-version=v0 -Z unstable-options -Z macro-backtrace -C split-debuginfo=packed -C target-feature=+crt-static -C llvm-args=-import-instr-limit=10 -Z unstable-options -Z binary-dep-depinfo -Z tls-model=initial-exec

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

query stack during panic:
thread panicked while processing panic. aborting.
error: could not compile `rustdoc` (lib)

Caused by:
  process didn't exit successfully: `D:\source\rust\rust\build\bootstrap\debug\rustc --crate-name rustdoc --edition=2021 'src\librustdoc\lib.rs' --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --crate-type lib --emit=dep-info,metadata,link -C opt-level=3 -C embed-bitcode=no -Zunstable-options --check-cfg 'cfg(feature, values("jemalloc"))' -C metadata=01f4d5a260686675 -C extra-filename=-01f4d5a260686675 --out-dir 'D:\source\rust\rust\build\x86_64-pc-windows-msvc\stage0-tools\x86_64-pc-windows-msvc\release\deps' --target x86_64-pc-windows-msvc -C 'incremental=D:\source\rust\rust\build\x86_64-pc-windows-msvc\stage0-tools\x86_64-pc-windows-msvc\release\incremental' -L 'dependency=D:\source\rust\rust\build\x86_64-pc-windows-msvc\stage0-tools\x86_64-pc-windows-msvc\release\deps' -L 'dependency=D:\source\rust\rust\build\x86_64-pc-windows-msvc\stage0-tools\release\deps' --extern 'arrayvec=D:\source\rust\rust\build\x86_64-pc-windows-msvc\stage0-tools\x86_64-pc-windows-msvc\release\deps\libarrayvec-c0fe13c606c671d7.rmeta' --extern 'askama=D:\source\rust\rust\build\x86_64-pc-windows-msvc\stage0-tools\x86_64-pc-windows-msvc\release\deps\libaskama-cdab1361fe75244e.rmeta' --extern 'indexmap=D:\source\rust\rust\build\x86_64-pc-windows-msvc\stage0-tools\x86_64-pc-windows-msvc\release\deps\libindexmap-5130818e636453ab.rmeta' --extern 'itertools=D:\source\rust\rust\build\x86_64-pc-windows-msvc\stage0-tools\x86_64-pc-windows-msvc\release\deps\libitertools-9f988ca984b15d43.rmeta' --extern 'minifier=D:\source\rust\rust\build\x86_64-pc-windows-msvc\stage0-tools\x86_64-pc-windows-msvc\release\deps\libminifier-ee80a6cb82ef9bf8.rmeta' --extern 'once_cell=D:\source\rust\rust\build\x86_64-pc-windows-msvc\stage0-tools\x86_64-pc-windows-msvc\release\deps\libonce_cell-1d3e96356082c9b5.rmeta' --extern 'regex=D:\source\rust\rust\build\x86_64-pc-windows-msvc\stage0-tools\x86_64-pc-windows-msvc\release\deps\libregex-64ea37194865f89f.rmeta' --extern 'rustdoc_json_types=D:\source\rust\rust\build\x86_64-pc-windows-msvc\stage0-tools\x86_64-pc-windows-msvc\release\deps\librustdoc_json_types-9af1d9526643b0a4.rmeta' --extern 'serde=D:\source\rust\rust\build\x86_64-pc-windows-msvc\stage0-tools\x86_64-pc-windows-msvc\release\deps\libserde-8f44f31e671060bf.rmeta' --extern 'serde_json=D:\source\rust\rust\build\x86_64-pc-windows-msvc\stage0-tools\x86_64-pc-windows-msvc\release\deps\libserde_json-20c0790e61435ff6.rmeta' --extern 'smallvec=D:\source\rust\rust\build\x86_64-pc-windows-msvc\stage0-tools\x86_64-pc-windows-msvc\release\deps\libsmallvec-98fd81a6eb021168.rmeta' --extern 'tempfile=D:\source\rust\rust\build\x86_64-pc-windows-msvc\stage0-tools\x86_64-pc-windows-msvc\release\deps\libtempfile-c38eb69b25df06d4.rmeta' --extern 'threadpool=D:\source\rust\rust\build\x86_64-pc-windows-msvc\stage0-tools\x86_64-pc-windows-msvc\release\deps\libthreadpool-cb01cd5dfa74e1fc.rmeta' --extern 'tracing=D:\source\rust\rust\build\x86_64-pc-windows-msvc\stage0-tools\x86_64-pc-windows-msvc\release\deps\libtracing-c37592520cc8b5f0.rmeta' --extern 'tracing_subscriber=D:\source\rust\rust\build\x86_64-pc-windows-msvc\stage0-tools\x86_64-pc-windows-msvc\release\deps\libtracing_subscriber-ac890cea32c3c2af.rmeta' --extern 'tracing_tree=D:\source\rust\rust\build\x86_64-pc-windows-msvc\stage0-tools\x86_64-pc-windows-msvc\release\deps\libtracing_tree-ce401f66adf97c4d.rmeta' --cfg=bootstrap --cfg=windows_raw_dylib -Csymbol-mangling-version=v0 -Zunstable-options '--check-cfg=cfg(bootstrap,values())' '--check-cfg=cfg(parallel_compiler,values())' '--check-cfg=cfg(no_btreemap_remove_entry,values())' '--check-cfg=cfg(crossbeam_loom,values())' '--check-cfg=cfg(span_locations,values())' '--check-cfg=cfg(rustix_use_libc,values())' '--check-cfg=cfg(emulate_second_only_system,values())' '--check-cfg=cfg(windows_raw_dylib,values())' -Zmacro-backtrace -Csplit-debuginfo=packed -Ctarget-feature=+crt-static -Cllvm-args=-import-instr-limit=10 -Zunstable-options -Z binary-dep-depinfo` (exit code: 0xc0000409, STATUS_STACK_BUFFER_OVERRUN)
Build completed unsuccessfully in 0:05:21



@apiraino
Copy link
Contributor

WG-prioritization assigning priority (Zulip discussion).

@rustbot label -I-prioritize +P-medium

@rustbot rustbot added P-medium Medium priority and removed I-prioritize Issue: Indicates that prioritization has been requested for this issue. labels Dec 11, 2023
@michaelwoerister
Copy link
Member

I'm having a hard time writing a small reproducer for this. Simply changing -Cmetadata of an upstream dependency is not sufficient. I think it also needs to involved certain things to be read from the incr. comp. cache in order to trigger the ICE.

bors added a commit to rust-lang-ci/rust that referenced this issue Dec 19, 2023
…ce-file-id, r=<try>

Unify SourceFile::name_hash and StableSourceFileId

This PR adapts the existing `StableSourceFileId` type so that it can be used instead of the `name_hash` field of `SourceFile`. This simplifies a few things that were kind of duplicated before.

The PR should also fix issues rust-lang#112700 and rust-lang#115835, but I was not able to reproduce these issues in a regression test. As far as I can tell, the root cause of these issues is that the id of the originating crate is not hashed in the `HashStable` impl of `Span` and thus cache entries that should have been considered invalidated were loaded. After this PR, the `stable_id` field of `SourceFile` includes information about the originating crate, so that ICE should not occur anymore.
bors added a commit to rust-lang-ci/rust that referenced this issue Dec 24, 2023
…ce-file-id, r=cjgillot

Unify SourceFile::name_hash and StableSourceFileId

This PR adapts the existing `StableSourceFileId` type so that it can be used instead of the `name_hash` field of `SourceFile`. This simplifies a few things that were kind of duplicated before.

The PR should also fix issues rust-lang#112700 and rust-lang#115835, but I was not able to reproduce these issues in a regression test. As far as I can tell, the root cause of these issues is that the id of the originating crate is not hashed in the `HashStable` impl of `Span` and thus cache entries that should have been considered invalidated were loaded. After this PR, the `stable_id` field of `SourceFile` includes information about the originating crate, so that ICE should not occur anymore.
github-actions bot pushed a commit to rust-lang/miri that referenced this issue Dec 26, 2023
…d, r=cjgillot

Unify SourceFile::name_hash and StableSourceFileId

This PR adapts the existing `StableSourceFileId` type so that it can be used instead of the `name_hash` field of `SourceFile`. This simplifies a few things that were kind of duplicated before.

The PR should also fix issues rust-lang/rust#112700 and rust-lang/rust#115835, but I was not able to reproduce these issues in a regression test. As far as I can tell, the root cause of these issues is that the id of the originating crate is not hashed in the `HashStable` impl of `Span` and thus cache entries that should have been considered invalidated were loaded. After this PR, the `stable_id` field of `SourceFile` includes information about the originating crate, so that ICE should not occur anymore.
@michaelwoerister
Copy link
Member

A potential fix for this has been merged in #119139 last week. Since the issue seems to most easily trigger during bootstrap, we'll have to wait for the fix to make it to beta before we can tell if it worked. I wasn't able to come up with a small reproducer, unfortunately.

@vegardgs-ksat
Copy link

I encountered this issue in stable (1.77.1) today.

$ cargo test contacts::search
   Compiling fjalar-database v0.1.0 (/Users/vegardgs/workspace/kogs/fjalar/database)
error: internal compiler error: compiler/rustc_metadata/src/rmeta/decoder/cstore_impl.rs:613:32: uninterned StableCrateId: StableCrateId(0)

thread 'rustc' panicked at /rustc/7cf61ebde7b22796c69757901dd346d0fe70bd97/compiler/rustc_errors/src/lib.rs:932:30:
Box<dyn Any>
stack backtrace:
   0:        0x1014448d4 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::hd4e6df6dd376d525
   1:        0x1014872b4 - core::fmt::write::h5a442bf928ef18fb
   2:        0x10143ab9c - std::io::Write::write_fmt::h01fe6f9cc882fac7
   3:        0x101444708 - std::sys_common::backtrace::print::h249c7fd853efd630
   4:        0x1014471d0 - std::panicking::default_hook::{{closure}}::h539bfee0454d0951
   5:        0x101446f18 - std::panicking::default_hook::he5a7d244fe90fc13
   6:        0x109b65408 - <alloc[b606dcf9f479e37c]::boxed::Box<rustc_driver_impl[64327daa3a5146a5]::install_ice_hook::{closure#0}> as core[13280c881f35522b]::ops::function::Fn<(&dyn for<'a, 'b> core[13280c881f35522b]::ops::function::Fn<(&'a core[13280c881f35522b]::panic::panic_info::PanicInfo<'b>,), Output = ()> + core[13280c881f35522b]::marker::Sync + core[13280c881f35522b]::marker::Send, &core[13280c881f35522b]::panic::panic_info::PanicInfo)>>::call
   7:        0x10144785c - std::panicking::rust_panic_with_hook::h9b82bdc13ccb171b
   8:        0x10de19584 - std[d41acc809eeea868]::panicking::begin_panic::<rustc_errors[b61bc3038148d90f]::ExplicitBug>::{closure#0}
   9:        0x10de18ec8 - std[d41acc809eeea868]::sys_common::backtrace::__rust_end_short_backtrace::<std[d41acc809eeea868]::panicking::begin_panic<rustc_errors[b61bc3038148d90f]::ExplicitBug>::{closure#0}, !>
  10:        0x10e24166c - std[d41acc809eeea868]::panicking::begin_panic::<rustc_errors[b61bc3038148d90f]::ExplicitBug>
  11:        0x10de0d298 - <rustc_errors[b61bc3038148d90f]::diagnostic_builder::BugAbort as rustc_errors[b61bc3038148d90f]::diagnostic_builder::EmissionGuarantee>::emit_producing_guarantee
  12:        0x10dc02c34 - <rustc_errors[b61bc3038148d90f]::DiagCtxt>::bug::<alloc[b606dcf9f479e37c]::string::String>
  13:        0x10dc2ea54 - rustc_middle[ca4af2868b1ce88d]::util::bug::opt_span_bug_fmt::<rustc_span[4db8343918321063]::span_encoding::Span>::{closure#0}
  14:        0x10dc2ca48 - rustc_middle[ca4af2868b1ce88d]::ty::context::tls::with_opt::<rustc_middle[ca4af2868b1ce88d]::util::bug::opt_span_bug_fmt<rustc_span[4db8343918321063]::span_encoding::Span>::{closure#0}, !>::{closure#0}
  15:        0x10dc2ca14 - rustc_middle[ca4af2868b1ce88d]::ty::context::tls::with_context_opt::<rustc_middle[ca4af2868b1ce88d]::ty::context::tls::with_opt<rustc_middle[ca4af2868b1ce88d]::util::bug::opt_span_bug_fmt<rustc_span[4db8343918321063]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
  16:        0x10e224690 - rustc_middle[ca4af2868b1ce88d]::util::bug::bug_fmt
  17:        0x10d7ce124 - <rustc_metadata[f797ad83e140e687]::creader::CStore as rustc_session[d6cbb4e49a2d8117]::cstore::CrateStore>::stable_crate_id_to_crate_num
  18:        0x10db88b70 - <rustc_middle[ca4af2868b1ce88d]::ty::context::TyCtxt>::def_path_hash_to_def_id
  19:        0x10dc8b4a8 - <rustc_query_system[49d49f6d7647d37d]::dep_graph::dep_node::DepNode as rustc_middle[ca4af2868b1ce88d]::dep_graph::dep_node::DepNodeExt>::extract_def_id
  20:        0x10cfba918 - <rustc_query_impl[c8aba89b8a3b468f]::plumbing::query_callback<rustc_query_impl[c8aba89b8a3b468f]::query_impl::hir_attrs::QueryType>::{closure#0} as core[13280c881f35522b]::ops::function::FnOnce<(rustc_middle[ca4af2868b1ce88d]::ty::context::TyCtxt, rustc_query_system[49d49f6d7647d37d]::dep_graph::dep_node::DepNode)>>::call_once
  21:        0x10d01dc64 - <rustc_query_system[49d49f6d7647d37d]::dep_graph::graph::DepGraphData<rustc_middle[ca4af2868b1ce88d]::dep_graph::DepsType>>::try_mark_previous_green::<rustc_query_impl[c8aba89b8a3b468f]::plumbing::QueryCtxt>
  22:        0x10d01da38 - <rustc_query_system[49d49f6d7647d37d]::dep_graph::graph::DepGraphData<rustc_middle[ca4af2868b1ce88d]::dep_graph::DepsType>>::try_mark_green::<rustc_query_impl[c8aba89b8a3b468f]::plumbing::QueryCtxt>
  23:        0x10cf3cc3c - rustc_query_system[49d49f6d7647d37d]::query::plumbing::ensure_must_run::<rustc_query_impl[c8aba89b8a3b468f]::DynamicConfig<rustc_query_system[49d49f6d7647d37d]::query::caches::SingleCache<rustc_middle[ca4af2868b1ce88d]::query::erase::Erased<[u8; 0usize]>>, false, false, false>, rustc_query_impl[c8aba89b8a3b468f]::plumbing::QueryCtxt>
  24:        0x10d10cd2c - rustc_query_impl[c8aba89b8a3b468f]::query_impl::proc_macro_decls_static::get_query_incr::__rust_end_short_backtrace
  25:        0x109ce48bc - <rustc_session[d6cbb4e49a2d8117]::session::Session>::time::<(), rustc_interface[4bd36eacb978473d]::passes::analysis::{closure#0}::{closure#0}::{closure#0}::{closure#1}>
  26:        0x109d2130c - std[d41acc809eeea868]::panicking::try::<(), core[13280c881f35522b]::panic::unwind_safe::AssertUnwindSafe<rustc_interface[4bd36eacb978473d]::passes::analysis::{closure#0}::{closure#0}::{closure#0}>>
  27:        0x109ce520c - <rustc_session[d6cbb4e49a2d8117]::session::Session>::time::<(), rustc_interface[4bd36eacb978473d]::passes::analysis::{closure#0}>
  28:        0x109cccbb8 - rustc_interface[4bd36eacb978473d]::passes::analysis
  29:        0x10cfd4520 - rustc_query_impl[c8aba89b8a3b468f]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[c8aba89b8a3b468f]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[ca4af2868b1ce88d]::query::erase::Erased<[u8; 1usize]>>
  30:        0x10cff9310 - <rustc_query_impl[c8aba89b8a3b468f]::query_impl::analysis::dynamic_query::{closure#2} as core[13280c881f35522b]::ops::function::FnOnce<(rustc_middle[ca4af2868b1ce88d]::ty::context::TyCtxt, ())>>::call_once
  31:        0x10cf52d98 - rustc_query_system[49d49f6d7647d37d]::query::plumbing::try_execute_query::<rustc_query_impl[c8aba89b8a3b468f]::DynamicConfig<rustc_query_system[49d49f6d7647d37d]::query::caches::SingleCache<rustc_middle[ca4af2868b1ce88d]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[c8aba89b8a3b468f]::plumbing::QueryCtxt, true>
  32:        0x10d0ef96c - rustc_query_impl[c8aba89b8a3b468f]::query_impl::analysis::get_query_incr::__rust_end_short_backtrace
  33:        0x109b78a1c - <rustc_middle[ca4af2868b1ce88d]::ty::context::GlobalCtxt>::enter::<rustc_driver_impl[64327daa3a5146a5]::run_compiler::{closure#0}::{closure#0}::{closure#3}, core[13280c881f35522b]::result::Result<(), rustc_span[4db8343918321063]::ErrorGuaranteed>>
  34:        0x109b78338 - <rustc_interface[4bd36eacb978473d]::interface::Compiler>::enter::<rustc_driver_impl[64327daa3a5146a5]::run_compiler::{closure#0}::{closure#0}, core[13280c881f35522b]::result::Result<core[13280c881f35522b]::option::Option<rustc_interface[4bd36eacb978473d]::queries::Linker>, rustc_span[4db8343918321063]::ErrorGuaranteed>>
  35:        0x109ba4ec4 - rustc_span[4db8343918321063]::create_session_globals_then::<core[13280c881f35522b]::result::Result<(), rustc_span[4db8343918321063]::ErrorGuaranteed>, rustc_interface[4bd36eacb978473d]::interface::run_compiler<core[13280c881f35522b]::result::Result<(), rustc_span[4db8343918321063]::ErrorGuaranteed>, rustc_driver_impl[64327daa3a5146a5]::run_compiler::{closure#0}>::{closure#0}>
  36:        0x109b92400 - std[d41acc809eeea868]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[4bd36eacb978473d]::util::run_in_thread_with_globals<rustc_interface[4bd36eacb978473d]::interface::run_compiler<core[13280c881f35522b]::result::Result<(), rustc_span[4db8343918321063]::ErrorGuaranteed>, rustc_driver_impl[64327daa3a5146a5]::run_compiler::{closure#0}>::{closure#0}, core[13280c881f35522b]::result::Result<(), rustc_span[4db8343918321063]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[13280c881f35522b]::result::Result<(), rustc_span[4db8343918321063]::ErrorGuaranteed>>
  37:        0x109badad4 - <<std[d41acc809eeea868]::thread::Builder>::spawn_unchecked_<rustc_interface[4bd36eacb978473d]::util::run_in_thread_with_globals<rustc_interface[4bd36eacb978473d]::interface::run_compiler<core[13280c881f35522b]::result::Result<(), rustc_span[4db8343918321063]::ErrorGuaranteed>, rustc_driver_impl[64327daa3a5146a5]::run_compiler::{closure#0}>::{closure#0}, core[13280c881f35522b]::result::Result<(), rustc_span[4db8343918321063]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[13280c881f35522b]::result::Result<(), rustc_span[4db8343918321063]::ErrorGuaranteed>>::{closure#1} as core[13280c881f35522b]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  38:        0x10144f378 - std::sys::pal::unix::thread::Thread::new::thread_start::h028c70d4ad289ac9
  39:        0x1940d2f94 - __pthread_joiner_wake

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.77.1 (7cf61ebde 2024-03-27) running on aarch64-apple-darwin

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

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

query stack during panic:
#0 [analysis] running analysis passes on this crate
end of query stack
there was a panic while trying to force a dep node
try_mark_green dep node stack:
#0 proc_macro_decls_static(0-0)
end of try_mark_green dep node stack
error: could not compile `fjalar-database` (lib

@michaelwoerister
Copy link
Member

Thanks for the report, @vegardgs-ksat!

This looks like a different issue. It's the same error but triggered by a different code path. Do you have a reproducer for the ICE? Then it would be best to open a new issue.

@vegardgs-ksat
Copy link

Thanks for the report, @vegardgs-ksat!

This looks like a different issue. It's the same error but triggered by a different code path. Do you have a reproducer for the ICE? Then it would be best to open a new issue.

I was not aware it was a different issue.

I do not have a reproducer - it was a one-off error that occurred when I made two consecutive changes within sqlx::QueryBuilder string contents (I believe - I do not think it was the sqlx::query! macro). I have worked a lot with this kind of code, and I have only gotten this ICE once - so its definitely not a common issue.

@michaelwoerister
Copy link
Member

I was not aware it was a different issue.

No worries, there's no way to tell that this has a different root cause unless one knows the relevant parts of the compiler's internals. You absolutely did the right thing reporting the backtrace here.

We'll have to wait for a reproducer to dig into this more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-incr-comp Area: Incremental compilation C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ P-medium Medium priority regression-from-stable-to-stable Performance or correctness regression from one stable version to another. 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

9 participants