rust-analyzer icon indicating copy to clipboard operation
rust-analyzer copied to clipboard

Rare ICE in cstore_impl.rs with proc macro

Open konnorandrews opened this issue 6 months ago • 1 comments

I'm reporting a rare ICE that another developer is experiencing. The ICE appears to be related to using the snafu crate in a proc macro, and only happens rarely (once a day type of rare). This makes me suspect some type of incremental compilation issue with RA's proc macro server.

I am unable to provide a repo or reproducer at this time. (see community discord for more context)

rust-analyzer version:

rustc version: 1.89.0-nightly (8da623945 2025-06-13)

thread 'rustc' panicked at compiler/rustc_metadata/src/rmeta/decoder/cstore_impl.rs:696:32:
Box<dyn Any>
stack backtrace:
   0:        0x110e05f30 - std::backtrace::Backtrace::create::h22ea715f59ec3ed0
   1:        0x10ef30af0 - std[df31d5d2efadd756]::panicking::update_hook::<alloc[9129d48d0341a7c4]::boxed::Box<rustc_driver_impl[1b35cf4ad33a8386]::install_ice_hook::{closure#1}>>::{closure#0}
   2:        0x110e23a28 - std::panicking::rust_panic_with_hook::h8625bb980bd8ff09
   3:        0x10efb4758 - std[df31d5d2efadd756]::panicking::begin_panic::<rustc_errors[cdab23ccf35dce2f]::ExplicitBug>::{closure#0}
   4:        0x10efa2938 - std[df31d5d2efadd756]::sys::backtrace::__rust_end_short_backtrace::<std[df31d5d2efadd756]::panicking::begin_panic<rustc_errors[cdab23ccf35dce2f]::ExplicitBug>::{closure#0}, !>
   5:        0x113ac6cc8 - std[df31d5d2efadd756]::panicking::begin_panic::<rustc_errors[cdab23ccf35dce2f]::ExplicitBug>
   6:        0x113ac70a0 - <rustc_errors[cdab23ccf35dce2f]::diagnostic::BugAbort as rustc_errors[cdab23ccf35dce2f]::diagnostic::EmissionGuarantee>::emit_producing_guarantee
   7:        0x113b40bc0 - rustc_middle[f8a6d707848327d8]::util::bug::opt_span_bug_fmt::<rustc_span[9a68fd476b92126f]::span_encoding::Span>::{closure#0}
   8:        0x10fbe60a4 - rustc_middle[f8a6d707848327d8]::ty::context::tls::with_opt::<rustc_middle[f8a6d707848327d8]::util::bug::opt_span_bug_fmt<rustc_span[9a68fd476b92126f]::span_encoding::Span>::{closure#0}, !>::{closure#0}
   9:        0x10fbe5b74 - rustc_middle[f8a6d707848327d8]::ty::context::tls::with_context_opt::<rustc_middle[f8a6d707848327d8]::ty::context::tls::with_opt<rustc_middle[f8a6d707848327d8]::util::bug::opt_span_bug_fmt<rustc_span[9a68fd476b92126f]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
  10:        0x113b40ad8 - rustc_middle[f8a6d707848327d8]::util::bug::bug_fmt
  11:        0x10fa4cfcc - <rustc_metadata[3c511df3e6d27a03]::rmeta::decoder::cstore_impl::provide_cstore_hooks::{closure#0} as core[7caada9627f18b09]::ops::function::FnOnce<(rustc_middle[f8a6d707848327d8]::ty::context::TyCtxt, rustc_span[9a68fd476b92126f]::def_id::DefPathHash, rustc_span[9a68fd476b92126f]::def_id::StableCrateId)>>::call_once
  12:        0x10fbf6dcc - <rustc_middle[f8a6d707848327d8]::ty::context::TyCtxt>::def_path_hash_to_def_id
  13:        0x11056cc68 - rustc_query_impl[82f6920132d9c7e1]::plumbing::force_from_dep_node::<rustc_query_impl[82f6920132d9c7e1]::DynamicConfig<rustc_data_structures[80586ddf1de41c48]::vec_cache::VecCache<rustc_span[9a68fd476b92126f]::def_id::LocalDefId, rustc_middle[f8a6d707848327d8]::query::erase::Erased<[u8; 8usize]>, rustc_query_system[4741a984835d9de2]::dep_graph::graph::DepNodeIndex>, false, false, false>>
  14:        0x1104fa314 - <rustc_query_impl[82f6920132d9c7e1]::plumbing::query_callback<rustc_query_impl[82f6920132d9c7e1]::query_impl::local_def_id_to_hir_id::QueryType>::{closure#0} as core[7caada9627f18b09]::ops::function::FnOnce<(rustc_middle[f8a6d707848327d8]::ty::context::TyCtxt, rustc_query_system[4741a984835d9de2]::dep_graph::dep_node::DepNode, rustc_query_system[4741a984835d9de2]::dep_graph::serialized::SerializedDepNodeIndex)>>::call_once
  15:        0x1102fe4c8 - <rustc_query_system[4741a984835d9de2]::dep_graph::graph::DepGraphData<rustc_middle[f8a6d707848327d8]::dep_graph::DepsType>>::try_mark_previous_green::<rustc_query_impl[82f6920132d9c7e1]::plumbing::QueryCtxt>
  16:        0x1102fe28c - <rustc_query_system[4741a984835d9de2]::dep_graph::graph::DepGraphData<rustc_middle[f8a6d707848327d8]::dep_graph::DepsType>>::try_mark_green::<rustc_query_impl[82f6920132d9c7e1]::plumbing::QueryCtxt>
  17:        0x110348280 - rustc_query_system[4741a984835d9de2]::query::plumbing::try_execute_query::<rustc_query_impl[82f6920132d9c7e1]::DynamicConfig<rustc_query_system[4741a984835d9de2]::query::caches::DefIdCache<rustc_middle[f8a6d707848327d8]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[82f6920132d9c7e1]::plumbing::QueryCtxt, true>
  18:        0x1105affa0 - rustc_query_impl[82f6920132d9c7e1]::query_impl::def_span::get_query_incr::__rust_end_short_backtrace
  19:        0x1101fe468 - rustc_passes[8601956eadf0dd58]::entry::entry_fn
  20:        0x110574a38 - rustc_query_impl[82f6920132d9c7e1]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[82f6920132d9c7e1]::query_impl::entry_fn::dynamic_query::{closure#2}::{closure#0}, rustc_middle[f8a6d707848327d8]::query::erase::Erased<[u8; 12usize]>>
  21:        0x110357448 - rustc_query_system[4741a984835d9de2]::query::plumbing::try_execute_query::<rustc_query_impl[82f6920132d9c7e1]::DynamicConfig<rustc_query_system[4741a984835d9de2]::query::caches::SingleCache<rustc_middle[f8a6d707848327d8]::query::erase::Erased<[u8; 12usize]>>, false, false, false>, rustc_query_impl[82f6920132d9c7e1]::plumbing::QueryCtxt, true>
  22:        0x1105d0170 - rustc_query_impl[82f6920132d9c7e1]::query_impl::entry_fn::get_query_incr::__rust_end_short_backtrace
  23:        0x10f83dbc4 - rustc_interface[41d3ece343fba094]::passes::run_required_analyses
  24:        0x10f8400c4 - rustc_interface[41d3ece343fba094]::passes::analysis
  25:        0x11057497c - rustc_query_impl[82f6920132d9c7e1]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[82f6920132d9c7e1]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[f8a6d707848327d8]::query::erase::Erased<[u8; 0usize]>>
  26:        0x11034bebc - rustc_query_system[4741a984835d9de2]::query::plumbing::try_execute_query::<rustc_query_impl[82f6920132d9c7e1]::DynamicConfig<rustc_query_system[4741a984835d9de2]::query::caches::SingleCache<rustc_middle[f8a6d707848327d8]::query::erase::Erased<[u8; 0usize]>>, false, false, false>, rustc_query_impl[82f6920132d9c7e1]::plumbing::QueryCtxt, true>
  27:        0x11058094c - rustc_query_impl[82f6920132d9c7e1]::query_impl::analysis::get_query_incr::__rust_end_short_backtrace
  28:        0x10eee1e4c - rustc_interface[41d3ece343fba094]::passes::create_and_enter_global_ctxt::<core[7caada9627f18b09]::option::Option<rustc_interface[41d3ece343fba094]::queries::Linker>, rustc_driver_impl[1b35cf4ad33a8386]::run_compiler::{closure#0}::{closure#2}>
  29:        0x10ef2d8c0 - rustc_interface[41d3ece343fba094]::interface::run_compiler::<(), rustc_driver_impl[1b35cf4ad33a8386]::run_compiler::{closure#0}>::{closure#1}
  30:        0x10ef2005c - std[df31d5d2efadd756]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[41d3ece343fba094]::util::run_in_thread_with_globals<rustc_interface[41d3ece343fba094]::util::run_in_thread_pool_with_globals<rustc_interface[41d3ece343fba094]::interface::run_compiler<(), rustc_driver_impl[1b35cf4ad33a8386]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
  31:        0x10ef340d8 - <<std[df31d5d2efadd756]::thread::Builder>::spawn_unchecked_<rustc_interface[41d3ece343fba094]::util::run_in_thread_with_globals<rustc_interface[41d3ece343fba094]::util::run_in_thread_pool_with_globals<rustc_interface[41d3ece343fba094]::interface::run_compiler<(), rustc_driver_impl[1b35cf4ad33a8386]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[7caada9627f18b09]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  32:        0x110e26de8 - std::sys::pal::unix::thread::Thread::new::thread_start::hcd1d9414b76a54c1
  33:        0x188b4c2e4 - __pthread_deallocate


rustc version: 1.89.0-nightly (8da623945 2025-06-13)
platform: aarch64-apple-darwin

query stack during panic:
#0 [def_span] looking up span for `main`
#1 [entry_fn] looking up the entry function of a crate
#2 [analysis] running analysis passes on this crate
end of query stack

konnorandrews avatar Jun 15 '25 20:06 konnorandrews

Did you report in the correct repo?

ChayimFriedman2 avatar Jun 15 '25 20:06 ChayimFriedman2

I believe this to be a bug caused by rust analyzer since it has not appeared when using cargo/rustc directly.

konnorandrews avatar Jun 24 '25 20:06 konnorandrews

I don't really see how rust-analyzer could cause an ICE in rustc that can't be otherwise triggered. We're only running cargo as normal subprocesses. So this should still be reported in the rustc repo.

flodiebold avatar Jun 25 '25 07:06 flodiebold