rust-lang / rust

Empowering everyone to build reliable and efficient software.
https://www.rust-lang.org
Other
98.22k stars 12.7k forks source link

ICE: get_adt_def called on a non-ADT, caused by build caching issues #83742

Open sebschmi opened 3 years ago

sebschmi commented 3 years ago

Code

See https://github.com/algbio/practical-omnitigs. Branch sebschmi/ICE The Rust code is in the subfolder implementation.

Run cargo test to reproduce.

I am sorry, but I am not able to provide a minimal example at the moment.

Meta

rustc --version --verbose:

rustc 1.51.0 (2fd73fabe 2021-03-23)
binary: rustc
commit-hash: 2fd73fabe469357a12c2c974c140f67e7cdd76d0
commit-date: 2021-03-23
host: x86_64-unknown-linux-gnu
release: 1.51.0
LLVM version: 11.0.1

Full error output

Backtrace

``` error: internal compiler error: compiler/rustc_metadata/src/rmeta/decoder.rs:838:18: get_adt_def called on a non-ADT DefId(21:855 ~ traitgraph[39ee]::walks::VecNodeWalk) thread 'rustc' panicked at 'Box', /rustc/2fd73fabe469357a12c2c974c140f67e7cdd76d0/library/std/src/panic.rs:59:5 stack backtrace: 0: std::panicking::begin_panic 1: std::panic::panic_any 2: rustc_errors::HandlerInner::bug 3: rustc_errors::Handler::bug 4: rustc_middle::ty::context::tls::with_opt 5: rustc_middle::util::bug::opt_span_bug_fmt 6: rustc_middle::util::bug::bug_fmt 7: rustc_metadata::rmeta::decoder::::get_adt_def 8: rustc_metadata::rmeta::decoder::cstore_impl::provide_extern::adt_def 9: rustc_middle::dep_graph::::with_deps 10: rustc_query_system::dep_graph::graph::DepGraph::with_task_impl 11: rustc_query_system::dep_graph::graph::DepGraph::with_task 12: rustc_data_structures::stack::ensure_sufficient_stack 13: rustc_query_system::query::plumbing::force_query_with_job 14: rustc_query_system::query::plumbing::force_query_impl 15: rustc_middle::dep_graph::dep_node::dep_kind::adt_def::force_from_dep_node 16: rustc_query_system::dep_graph::graph::DepGraph::try_mark_previous_green 17: rustc_query_system::dep_graph::graph::DepGraph::try_mark_previous_green 18: rustc_query_system::dep_graph::graph::DepGraph::try_mark_previous_green 19: rustc_query_system::dep_graph::graph::DepGraph::try_mark_previous_green 20: rustc_query_system::dep_graph::graph::DepGraph::try_mark_previous_green 21: rustc_query_system::dep_graph::graph::DepGraph::try_mark_previous_green 22: rustc_query_system::dep_graph::graph::DepGraph::try_mark_green_and_read 23: rustc_data_structures::stack::ensure_sufficient_stack 24: rustc_query_system::query::plumbing::get_query_impl 25: ::evaluate_obligation 26: ::evaluate_obligation_no_overflow 27: rustc_trait_selection::traits::fulfill::FulfillProcessor::process_trait_obligation 28: rustc_trait_selection::traits::fulfill::FulfillProcessor::progress_changed_obligations 29: ::select_where_possible 30: ::select_all_or_error 31: rustc_trait_selection::traits::codegen::drain_fulfillment_cx_or_panic 32: rustc_infer::infer::InferCtxtBuilder::enter 33: rustc_trait_selection::traits::codegen::codegen_fulfill_obligation 34: rustc_middle::ty::query:: for rustc_middle::ty::query::queries::codegen_fulfill_obligation>::compute 35: rustc_middle::dep_graph::::with_deps 36: rustc_query_system::dep_graph::graph::DepGraph::with_task_impl 37: rustc_data_structures::stack::ensure_sufficient_stack 38: rustc_query_system::query::plumbing::force_query_with_job 39: rustc_query_system::query::plumbing::get_query_impl 40: rustc_ty_utils::instance::inner_resolve_instance 41: rustc_ty_utils::instance::resolve_instance 42: rustc_middle::ty::query:: for rustc_middle::ty::query::queries::resolve_instance>::compute 43: rustc_middle::dep_graph::::with_deps 44: rustc_query_system::dep_graph::graph::DepGraph::with_task_impl 45: rustc_data_structures::stack::ensure_sufficient_stack 46: rustc_query_system::query::plumbing::force_query_with_job 47: rustc_query_system::query::plumbing::get_query_impl 48: rustc_middle::ty::instance::Instance::resolve_opt_const_arg 49: rustc_middle::ty::instance::Instance::resolve 50: ::visit_terminator 51: rustc_mir::monomorphize::collector::collect_neighbours 52: rustc_mir::monomorphize::collector::collect_items_rec 53: rustc_mir::monomorphize::collector::collect_items_rec 54: rustc_mir::monomorphize::collector::collect_items_rec 55: rustc_mir::monomorphize::collector::collect_items_rec 56: rustc_mir::monomorphize::collector::collect_items_rec 57: rustc_mir::monomorphize::collector::collect_items_rec 58: rustc_mir::monomorphize::collector::collect_items_rec 59: rustc_mir::monomorphize::collector::collect_items_rec 60: rustc_session::utils::::time 61: rustc_mir::monomorphize::collector::collect_crate_mono_items 62: rustc_mir::monomorphize::partitioning::collect_and_partition_mono_items 63: rustc_middle::ty::query:: for rustc_middle::ty::query::queries::collect_and_partition_mono_items>::compute 64: rustc_middle::dep_graph::::with_deps 65: rustc_query_system::dep_graph::graph::DepGraph::with_task_impl 66: rustc_data_structures::stack::ensure_sufficient_stack 67: rustc_query_system::query::plumbing::force_query_with_job 68: rustc_query_system::query::plumbing::get_query_impl 69: rustc_codegen_ssa::base::codegen_crate 70: ::codegen_crate 71: rustc_session::utils::::time 72: rustc_interface::passes::QueryContext::enter 73: rustc_interface::queries::Queries::ongoing_codegen 74: rustc_interface::queries::::enter 75: rustc_span::with_source_map 76: rustc_interface::interface::create_compiler_and_run 77: rustc_span::with_session_globals note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace. note: the compiler unexpectedly panicked. this is a bug. note: we would appreciate a bug report: https://github.com/rust-lang/rust/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md note: rustc 1.51.0 (2fd73fabe 2021-03-23) running on x86_64-unknown-linux-gnu note: compiler flags: -C embed-bitcode=no -C debuginfo=2 -C incremental note: some of the compiler flags provided by cargo are hidden query stack during panic: #0 [adt_def] computing ADT definition for `traitgraph::walks::VecNodeWalk` #1 [evaluate_obligation] evaluating trait selection obligation `std::iter::Map>>, [closure@omnitigs/src/macrotigs/macronodes/strongly_connected_macronode_algorithm.rs:14:21: 18:14]>, fn(unitigs::NodeUnitig>) -> std::vec::Vec< as traitgraph::interface::GraphBase>::NodeIndex> {unitigs::NodeUnitig::>::into_node_walk}>: std::vec::source_iter_marker::SourceIterMarker` #2 [codegen_fulfill_obligation] checking if `std::vec::spec_from_iter::SpecFromIter` fulfills its obligations #3 [resolve_instance] resolving instance `>> as std::vec::spec_from_iter::SpecFromIter>, std::iter::Map>>, [closure@omnitigs/src/macrotigs/macronodes/strongly_connected_macronode_algorithm.rs:14:21: 18:14]>, fn(unitigs::NodeUnitig>) -> std::vec::Vec< as traitgraph::interface::GraphBase>::NodeIndex> {unitigs::NodeUnitig::>::into_node_walk}>>>::from_iter` #4 [collect_and_partition_mono_items] collect_and_partition_mono_items end of query stack error: aborting due to previous error; 2 warnings emitted error: could not compile `omnitigs` To learn more, run the command again with --verbose. ```

What I tried

cargo update as of today updated the dependencies to a state that seem to circumvent the ICE.

Without the cargo update, using beta the ICE does not occur.

cargo 1.52.0-beta (90691f2bf 2021-03-16)
release: 1.52.0
commit-hash: 90691f2bfe9a50291a98983b1ed2feab51d5ca55
commit-date: 2021-03-16

Also without the cargo update, using nightly the ICE does not occur.

cargo 1.52.0-nightly (90691f2bf 2021-03-16)
release: 1.52.0
commit-hash: 90691f2bfe9a50291a98983b1ed2feab51d5ca55
commit-date: 2021-03-16

What solved it

Deleting the target folder (after reverting the cargo update) fixed the ICE. I could then run cargo test again and no ICE occurred.

I might have clicked the test button too fast in my IDE while debugging, so possibly cargo was run concurrently.

teor2345 commented 3 years ago

I've also seen this ICE on:

rustc 1.57.0-nightly (d7c97a02d 2021-10-12)
binary: rustc
commit-hash: d7c97a02d1215e4ef26c31cb72dbaf16fd548b2c
commit-date: 2021-10-12
host: x86_64-unknown-linux-gnu
release: 1.57.0-nightly
LLVM version: 13.0.0

It was reproducible with the same cache state, but it was resolved by clearing the cache.

Here is the backtrace:

``` error: internal compiler error: compiler/rustc_metadata/src/rmeta/decoder.rs:900:18: get_adt_def called on a non-ADT DefId(250:1108 ~ zebra_consensus[2792]::transaction::Response) thread 'rustc' panicked at 'Box', compiler/rustc_errors/src/lib.rs:1146:9 stack backtrace: 0: std::panicking::begin_panic 1: std::panic::panic_any 2: rustc_errors::HandlerInner::bug 3: rustc_errors::Handler::bug 4: rustc_middle::ty::context::tls::with_opt 5: rustc_middle::util::bug::opt_span_bug_fmt 6: rustc_middle::util::bug::bug_fmt 7: rustc_metadata::rmeta::decoder::::get_adt_def 8: rustc_metadata::rmeta::decoder::cstore_impl::provide_extern::adt_def 9: rustc_query_system::dep_graph::graph::DepGraph::with_task 10: rustc_data_structures::stack::ensure_sufficient_stack 11: rustc_query_system::query::plumbing::try_execute_query 12: rustc_query_system::query::plumbing::force_query_impl 13: rustc_query_system::query::plumbing::force_query 14: rustc_query_system::dep_graph::graph::DepGraph::try_mark_previous_green 15: rustc_query_system::dep_graph::graph::DepGraph::try_mark_previous_green 16: rustc_query_system::query::plumbing::ensure_must_run 17: rustc_query_system::query::plumbing::get_query 18: rustc_session::session::Session::track_errors 19: rustc_typeck::check_crate 20: rustc_interface::passes::analysis 21: rustc_query_system::dep_graph::graph::DepGraph::with_task 22: rustc_data_structures::stack::ensure_sufficient_stack 23: rustc_query_system::query::plumbing::try_execute_query 24: ::analysis 25: rustc_interface::queries::::enter 26: rustc_span::with_source_map 27: scoped_tls::ScopedKey::set note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace. note: the compiler unexpectedly panicked. this is a bug. note: we would appreciate a bug report: https://github.com/rust-lang/rust/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md note: rustc 1.57.0-nightly (d7c97a02d 2021-10-12) running on x86_64-unknown-linux-gnu note: compiler flags: -Z share-generics=y -C panic=abort -C embed-bitcode=no -C debuginfo=2 -C linker=clang -C incremental -C link-arg=-fuse-ld=lld --crate-type lib note: some of the compiler flags provided by cargo are hidden query stack during panic: #0 [adt_def] computing ADT definition for `zebra_consensus::transaction::Response` #1 [analysis] running analysis passes on this crate end of query stack ```
VladasZ commented 2 years ago

I've seen the same error on:

rustc 1.59.0-nightly (efec54529 2021-12-04)
binary: rustc
commit-hash: efec545293b9263be9edfb283a7aa66350b3acbf
commit-date: 2021-12-04
host: x86_64-apple-darwin
release: 1.59.0-nightly
LLVM version: 13.0.0

It was resolved by cargo clean but unfortunately I can't reproduce it again and provide the backtrace.

Aaron1011 commented 2 years ago

I strongly suspect that this has the same underlying cause as https://github.com/rust-lang/rust/issues/91696#issuecomment-993043710