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

compiler panic when moving struct definition #93096

Closed
zvkemp opened this issue Jan 19, 2022 · 10 comments
Closed

compiler panic when moving struct definition #93096

zvkemp opened this issue Jan 19, 2022 · 10 comments
Labels
C-bug Category: This is a bug. 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.

Comments

@zvkemp
Copy link

zvkemp commented Jan 19, 2022

Code

Code is part of a private repo, so I can't share everything. The change involved moving a struct definition (the ApplicationSummaryKey in the below example) from one module to a new submodule of that module. It is triggered by cargo build or cargo test (possibly other commands). Was not triggered by nightly, but it's unclear if that's because there wasn't a stale nightly build already.

This is the function at the top of the query stack when the panic occurs:

    pub(crate) async fn commit_buffer_in_transaction(
        &mut self,
        db: &mut sqlx::Transaction<'_, Postgres>,
    ) -> Result<HashSet<ApplicationSummaryKey<T::Span>>, Error> {
        let mut keys = HashSet::new();

        for (key, summary) in self.data.drain() {
            summary.commit(&mut *db).await?;
            keys.insert(key);
        }

        Ok(keys)
    }

Also note this crate is part of a workspace, and the panic only happens when run from the workspace root; it does not happen if run in the crate's subdirectory. A cargo clean -p {crate} fixed the issue, and now I cannot reproduce it.

Meta

rustc --version --verbose:

rustc 1.58.0 (02072b482 2022-01-11)
binary: rustc
commit-hash: 02072b482a8b5357f7fb5e5637444ae30e423c40
commit-date: 2022-01-11
host: aarch64-apple-darwin
release: 1.58.0
LLVM version: 13.0.0

Error output

thread 'rustc' panicked at 'called `Option::unwrap()` on a `None` value', /rustc/02072b482a8b5357f7fb5e5637444ae30e423c40/compiler/rustc_hir/src/definitions.rs:452:14
Backtrace

stack backtrace:
   0: _rust_begin_unwind
   1: core::panicking::panic_fmt
   2: core::panicking::panic
   3: <rustc_middle::ty::context::TyCtxt>::def_path_hash_to_def_id
   4: <rustc_query_system::dep_graph::dep_node::DepNode<rustc_middle::dep_graph::dep_node::DepKind> as rustc_middle::dep_graph::dep_node::DepNodeExt>::extract_def_id
   5: rustc_query_impl::query_callbacks::hir_owner::force_from_dep_node
   6: <rustc_middle::ty::context::TyCtxt as rustc_query_system::dep_graph::DepContext>::try_force_from_dep_node
   7: <rustc_query_system::dep_graph::graph::DepGraph<rustc_middle::dep_graph::dep_node::DepKind>>::try_mark_previous_green::<rustc_query_impl::plumbing::QueryCtxt>
   8: <rustc_query_system::dep_graph::graph::DepGraph<rustc_middle::dep_graph::dep_node::DepKind>>::try_mark_previous_green::<rustc_query_impl::plumbing::QueryCtxt>
   9: <rustc_query_system::dep_graph::graph::DepGraph<rustc_middle::dep_graph::dep_node::DepKind>>::try_mark_previous_green::<rustc_query_impl::plumbing::QueryCtxt>
  10: <rustc_query_system::dep_graph::graph::DepGraph<rustc_middle::dep_graph::dep_node::DepKind>>::try_mark_green::<rustc_query_impl::plumbing::QueryCtxt>
  11: rustc_query_system::query::plumbing::try_load_from_disk_and_cache_in_memory::<rustc_query_impl::plumbing::QueryCtxt, rustc_span::def_id::LocalDefId, &rustc_middle::mir::query::UnsafetyCheckResult>
  12: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::plumbing::QueryCtxt, rustc_query_system::query::caches::DefaultCache<rustc_span::def_id::LocalDefId, &rustc_middle::mir::query::UnsafetyCheckResult>>
  13: rustc_query_system::query::plumbing::get_query::<rustc_query_impl::queries::unsafety_check_result, rustc_query_impl::plumbing::QueryCtxt>
  14: <rustc_mir_transform::check_unsafety::UnsafetyChecker as rustc_middle::mir::visit::Visitor>::visit_rvalue
  15: rustc_mir_transform::check_unsafety::unsafety_check_result
  16: <rustc_mir_transform::check_unsafety::provide::{closure#0} as core::ops::function::FnOnce<(rustc_middle::ty::context::TyCtxt, rustc_span::def_id::LocalDefId)>>::call_once
  17: <rustc_query_system::dep_graph::graph::DepGraph<rustc_middle::dep_graph::dep_node::DepKind>>::with_task::<rustc_middle::ty::context::TyCtxt, rustc_span::def_id::LocalDefId, &rustc_middle::mir::query::UnsafetyCheckResult>
  18: rustc_data_structures::stack::ensure_sufficient_stack::<(&rustc_middle::mir::query::UnsafetyCheckResult, rustc_query_system::dep_graph::graph::DepNodeIndex), rustc_query_system::query::plumbing::execute_job<rustc_query_impl::plumbing::QueryCtx
t, rustc_span::def_id::LocalDefId, &rustc_middle::mir::query::UnsafetyCheckResult>::{closure#3}>
  19: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::plumbing::QueryCtxt, rustc_query_system::query::caches::DefaultCache<rustc_span::def_id::LocalDefId, &rustc_middle::mir::query::UnsafetyCheckResult>>
  20: rustc_query_system::query::plumbing::force_query::<rustc_query_impl::queries::unsafety_check_result, rustc_query_impl::plumbing::QueryCtxt>
  21: rustc_query_impl::query_callbacks::unsafety_check_result::force_from_dep_node
  22: <rustc_middle::ty::context::TyCtxt as rustc_query_system::dep_graph::DepContext>::try_force_from_dep_node
  23: <rustc_query_system::dep_graph::graph::DepGraph<rustc_middle::dep_graph::dep_node::DepKind>>::try_mark_previous_green::<rustc_query_impl::plumbing::QueryCtxt>
  24: <rustc_query_system::dep_graph::graph::DepGraph<rustc_middle::dep_graph::dep_node::DepKind>>::try_mark_previous_green::<rustc_query_impl::plumbing::QueryCtxt>
  25: <rustc_query_system::dep_graph::graph::DepGraph<rustc_middle::dep_graph::dep_node::DepKind>>::try_mark_previous_green::<rustc_query_impl::plumbing::QueryCtxt>
  26: <rustc_query_system::dep_graph::graph::DepGraph<rustc_middle::dep_graph::dep_node::DepKind>>::try_mark_green::<rustc_query_impl::plumbing::QueryCtxt>
  27: rustc_query_system::query::plumbing::try_load_from_disk_and_cache_in_memory::<rustc_query_impl::plumbing::QueryCtxt, rustc_span::def_id::LocalDefId, &rustc_middle::mir::query::BorrowCheckResult>
  28: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::plumbing::QueryCtxt, rustc_query_system::query::caches::DefaultCache<rustc_span::def_id::LocalDefId, &rustc_middle::mir::query::BorrowCheckResult>>
  29: rustc_query_system::query::plumbing::get_query::<rustc_query_impl::queries::mir_borrowck, rustc_query_impl::plumbing::QueryCtxt>
  30: rustc_typeck::collect::type_of::type_of
  31: <rustc_query_system::dep_graph::graph::DepGraph<rustc_middle::dep_graph::dep_node::DepKind>>::with_task::<rustc_middle::ty::context::TyCtxt, rustc_span::def_id::DefId, &rustc_middle::ty::TyS>
  32: rustc_data_structures::stack::ensure_sufficient_stack::<(&rustc_middle::ty::TyS, rustc_query_system::dep_graph::graph::DepNodeIndex), rustc_query_system::query::plumbing::execute_job<rustc_query_impl::plumbing::QueryCtxt, rustc_span::def_id::D
efId, &rustc_middle::ty::TyS>::{closure#3}>
  33: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::plumbing::QueryCtxt, rustc_query_system::query::caches::DefaultCache<rustc_span::def_id::DefId, &rustc_middle::ty::TyS>>
  34: rustc_query_system::query::plumbing::get_query::<rustc_query_impl::queries::type_of, rustc_query_impl::plumbing::QueryCtxt>
  35: <rustc_middle::ty::util::OpaqueTypeExpander>::expand_opaque_ty
  36: <smallvec::SmallVec<[&rustc_middle::ty::TyS; 8]> as core::iter::traits::collect::Extend<&rustc_middle::ty::TyS>>::extend::<core::iter::adapters::map::Map<core::iter::adapters::copied::Copied<core::slice::iter::Iter<&rustc_middle::ty::TyS>>, ru
stc_middle::ty::util::fold_list<rustc_middle::ty::util::OpaqueTypeExpander, &rustc_middle::ty::TyS, <&rustc_middle::ty::list::List<&rustc_middle::ty::TyS> as rustc_middle::ty::fold::TypeFoldable>::super_fold_with<rustc_middle::ty::util::OpaqueTypeEx
pander>::{closure#0}>::{closure#1}>>
  37: rustc_middle::ty::util::fold_list::<rustc_middle::ty::util::OpaqueTypeExpander, &rustc_middle::ty::TyS, <&rustc_middle::ty::list::List<&rustc_middle::ty::TyS> as rustc_middle::ty::fold::TypeFoldable>::super_fold_with<rustc_middle::ty::util::Op
aqueTypeExpander>::{closure#0}>
  38: <&rustc_middle::ty::TyS as rustc_middle::ty::fold::TypeFoldable>::super_fold_with::<rustc_middle::ty::util::OpaqueTypeExpander>
  39: <smallvec::SmallVec<[rustc_middle::ty::subst::GenericArg; 8]> as core::iter::traits::collect::Extend<rustc_middle::ty::subst::GenericArg>>::extend::<core::iter::adapters::map::Map<core::iter::adapters::copied::Copied<core::slice::iter::Iter<ru
stc_middle::ty::subst::GenericArg>>, <&rustc_middle::ty::list::List<rustc_middle::ty::subst::GenericArg> as rustc_middle::ty::fold::TypeFoldable>::super_fold_with<rustc_middle::ty::util::OpaqueTypeExpander>::{closure#0}>>
  40: <&rustc_middle::ty::list::List<rustc_middle::ty::subst::GenericArg> as rustc_middle::ty::fold::TypeFoldable>::fold_with::<rustc_middle::ty::util::OpaqueTypeExpander>
  41: <&rustc_middle::ty::TyS as rustc_middle::ty::fold::TypeFoldable>::super_fold_with::<rustc_middle::ty::util::OpaqueTypeExpander>
  42: <&rustc_middle::ty::list::List<rustc_middle::ty::subst::GenericArg> as rustc_middle::ty::fold::TypeFoldable>::fold_with::<rustc_middle::ty::util::OpaqueTypeExpander>
  43: <rustc_middle::ty::util::OpaqueTypeExpander>::expand_opaque_ty
  44: <rustc_middle::ty::util::OpaqueTypeExpander>::expand_opaque_ty
  45: <rustc_middle::ty::context::TyCtxt>::try_expand_impl_trait_type
  46: rustc_typeck::check::check::check_item_type
  47: <rustc_middle::hir::map::Map>::visit_item_likes_in_module::<rustc_typeck::check::CheckItemTypesVisitor>
  48: rustc_typeck::check::check::check_mod_item_types
  49: <rustc_query_system::dep_graph::graph::DepGraph<rustc_middle::dep_graph::dep_node::DepKind>>::with_task::<rustc_middle::ty::context::TyCtxt, rustc_span::def_id::LocalDefId, ()>
  50: rustc_data_structures::stack::ensure_sufficient_stack::<((), rustc_query_system::dep_graph::graph::DepNodeIndex), rustc_query_system::query::plumbing::execute_job<rustc_query_impl::plumbing::QueryCtxt, rustc_span::def_id::LocalDefId, ()>::{clo
sure#3}>
  51: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::plumbing::QueryCtxt, rustc_query_system::query::caches::DefaultCache<rustc_span::def_id::LocalDefId, ()>>
  52: rustc_query_system::query::plumbing::get_query::<rustc_query_impl::queries::check_mod_item_types, rustc_query_impl::plumbing::QueryCtxt>
  53: <rustc_middle::hir::map::Map>::for_each_module::<rustc_typeck::check_crate::{closure#6}::{closure#0}>
  54: rustc_typeck::check_crate
  55: rustc_interface::passes::analysis
  56: <rustc_query_system::dep_graph::graph::DepGraph<rustc_middle::dep_graph::dep_node::DepKind>>::with_task::<rustc_middle::ty::context::TyCtxt, (), core::result::Result<(), rustc_errors::ErrorReported>>
  57: rustc_data_structures::stack::ensure_sufficient_stack::<(core::result::Result<(), rustc_errors::ErrorReported>, rustc_query_system::dep_graph::graph::DepNodeIndex), rustc_query_system::query::plumbing::execute_job<rustc_query_impl::plumbing::Q
ueryCtxt, (), core::result::Result<(), rustc_errors::ErrorReported>>::{closure#3}>
  58: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::plumbing::QueryCtxt, rustc_query_system::query::caches::DefaultCache<(), core::result::Result<(), rustc_errors::ErrorReported>>>
  59: rustc_query_system::query::plumbing::get_query::<rustc_query_impl::queries::analysis, rustc_query_impl::plumbing::QueryCtxt>
  60: <rustc_interface::passes::QueryContext>::enter::<rustc_driver::run_compiler::{closure#1}::{closure#2}::{closure#3}, core::result::Result<(), rustc_errors::ErrorReported>>
  61: <rustc_interface::interface::Compiler>::enter::<rustc_driver::run_compiler::{closure#1}::{closure#2}, core::result::Result<core::option::Option<rustc_interface::queries::Linker>, rustc_errors::ErrorReported>>
  62: rustc_span::with_source_map::<core::result::Result<(), rustc_errors::ErrorReported>, rustc_interface::interface::create_compiler_and_run<core::result::Result<(), rustc_errors::ErrorReported>, rustc_driver::run_compiler::{closure#1}>::{closure#
1}>
  63: <scoped_tls::ScopedKey<rustc_span::SessionGlobals>>::set::<rustc_interface::util::setup_callbacks_and_run_in_thread_pool_with_globals<rustc_interface::interface::run_compiler<core::result::Result<(), rustc_errors::ErrorReported>, rustc_driver:
:run_compiler::{closure#1}>::{closure#0}, core::result::Result<(), rustc_errors::ErrorReported>>::{closure#0}::{closure#0}, core::result::Result<(), rustc_errors::ErrorReported>>
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.



query stack during panic:
#0 [unsafety_check_result] unsafety-checking `rollups::rollup_buffer::<impl at application-summarizer/src/rollups/rollup_buffer.rs:19:1: 109:2>::commit_buffer_in_transaction::{closure#0}`
#1 [unsafety_check_result] unsafety-checking `rollups::rollup_buffer::<impl at application-summarizer/src/rollups/rollup_buffer.rs:19:1: 109:2>::commit_buffer_in_transaction`
#2 [mir_borrowck] borrow-checking `rollups::rollup_buffer::<impl at application-summarizer/src/rollups/rollup_buffer.rs:19:1: 109:2>::commit_buffer_in_transaction`
#3 [type_of] computing type of `rollups::rollup_buffer::<impl at application-summarizer/src/rollups/rollup_buffer.rs:19:1: 109:2>::commit_buffer_in_transaction::{opaque#0}`
#4 [check_mod_item_types] checking item types in top-level module
#5 [analysis] running analysis passes on this crate

@zvkemp zvkemp added C-bug Category: This is a bug. 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 Jan 19, 2022
Aaron1011 added a commit to Aaron1011/rust that referenced this issue Jan 19, 2022
This should hopefully make it easier to debug incremental compilation
bugs like rust-lang#93096 without affecting performance.
@Aaron1011
Copy link
Member

@zvkemp Can you try the following to see if you can reproduce this again:

  1. Run cargo clean
  2. Undo the change you made (e.g. move ApplicationSummaryKey back to its original location, and undo any other changes you made)
  3. Run cargo build from the workspace root
  4. Re-apply the change (move ApplicationSummaryKey to the new location)
  5. Run cargo build again

@zvkemp
Copy link
Author

zvkemp commented Jan 20, 2022

@aaron1101 Unfortunately I can't reproduce the issue again using that procedure; in hindsight I should have copied the target directory state before running cargo clean. I'll reply to this issue again if I end up getting it working (or rather not working).

@bergmark
Copy link

bergmark commented Jan 20, 2022

I think I ran across the same issue, but it was after switching git branches multiple times so finding a reproduction seems hard :( I ran cargo test in crate-a and while cargo was compiling crate-b i got:

thread 'rustc' panicked at 'called `Option::unwrap()` on a `None` value', /rustc/02072b482a8b5357f7fb5e5637444ae30e423c40/compiler/rustc_hir/src/definitions.rs:452:14
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

error: internal compiler error: unexpected panic

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.58.0 (02072b482 2022-01-11) running on x86_64-apple-darwin

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

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

query stack during panic:
#0 [unsafety_check_result] unsafety-checking `handler::account::account_get::{closure#0}`
#1 [unsafety_check_result] unsafety-checking `handler::account::account_get`
end of query stack
error: could not compile `crate-b`

a clean build resolved it.

@zvkemp
Copy link
Author

zvkemp commented Jan 20, 2022

I've had another panic with a similar stacktrace, again after globally renaming a struct. This one is only triggered by cargo test.

@aaron1101 I've backed up the target directory this time, so please let me know if there's anything you'd like me to look at in more detail.

Backtrace

thread 'rustc' panicked at 'called `Option::unwrap()` on a `None` value', /rustc/02072b482a8b5357f7fb5e5637444ae30e423c40/compiler/rustc_hir/src/definitions.rs:452:14
stack backtrace:
   0: _rust_begin_unwind
   1: core::panicking::panic_fmt
   2: core::panicking::panic
   3: <rustc_middle::ty::context::TyCtxt>::def_path_hash_to_def_id
   4: <rustc_query_system::dep_graph::dep_node::DepNode<rustc_middle::dep_graph::dep_node::DepKind> as rustc_middle::dep_graph::dep_node::DepNodeExt>::extract_def_id
   5: rustc_query_impl::query_callbacks::hir_owner::force_from_dep_node
   6: <rustc_middle::ty::context::TyCtxt as rustc_query_system::dep_graph::DepContext>::try_force_from_dep_node
   7: <rustc_query_system::dep_graph::graph::DepGraph<rustc_middle::dep_graph::dep_node::DepKind>>::try_mark_previous_green::<rustc_query_impl::plumbing::QueryCtxt>
   8: <rustc_query_system::dep_graph::graph::DepGraph<rustc_middle::dep_graph::dep_node::DepKind>>::try_mark_previous_green::<rustc_query_impl::plumbing::QueryCtxt>
   9: <rustc_query_system::dep_graph::graph::DepGraph<rustc_middle::dep_graph::dep_node::DepKind>>::try_mark_green::<rustc_query_impl::plumbing::QueryCtxt>
  10: rustc_query_system::query::plumbing::ensure_must_run::<rustc_query_impl::plumbing::QueryCtxt, rustc_span::def_id::LocalDefId, rustc_span::def_id::LocalDefId>
  11: rustc_query_system::query::plumbing::get_query::<rustc_query_impl::queries::check_impl_item_well_formed, rustc_query_impl::plumbing::QueryCtxt>
  12: <core::panic::unwind_safe::AssertUnwindSafe<rustc_data_structures::sync::par_for_each_in<&alloc::vec::Vec<core::option::Option<rustc_hir::hir::OwnerInfo>>, <rustc_middle::hir::map::Map>::par_visit_all_item_likes<rustc_typeck::check::wfcheck::CheckTypeWellFormedVisitor>::{closure#0}>::{closure#0}::{closure#0}> as core::ops::function::FnOnce<()>>::call_once
  13: rustc_data_structures::sync::par_for_each_in::<&alloc::vec::Vec<core::option::Option<rustc_hir::hir::OwnerInfo>>, <rustc_middle::hir::map::Map>::par_visit_all_item_likes<rustc_typeck::check::wfcheck::CheckTypeWellFormedVisitor>::{closure#0}>
  14: <rustc_session::session::Session>::track_errors::<rustc_typeck::check_crate::{closure#5}, ()>
  15: rustc_typeck::check_crate
  16: rustc_interface::passes::analysis
  17: <rustc_query_system::dep_graph::graph::DepGraph<rustc_middle::dep_graph::dep_node::DepKind>>::with_task::<rustc_middle::ty::context::TyCtxt, (), core::result::Result<(), rustc_errors::ErrorReported>>
  18: rustc_data_structures::stack::ensure_sufficient_stack::<(core::result::Result<(), rustc_errors::ErrorReported>, rustc_query_system::dep_graph::graph::DepNodeIndex), rustc_query_system::query::plumbing::execute_job<rustc_query_impl::plumbing::QueryCtxt, (), core::result::Result<(), rustc_errors::ErrorReported>>::{closure#3}>
  19: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::plumbing::QueryCtxt, rustc_query_system::query::caches::DefaultCache<(), core::result::Result<(), rustc_errors::ErrorReported>>>
  20: rustc_query_system::query::plumbing::get_query::<rustc_query_impl::queries::analysis, rustc_query_impl::plumbing::QueryCtxt>
  21: <rustc_interface::passes::QueryContext>::enter::<rustc_driver::run_compiler::{closure#1}::{closure#2}::{closure#3}, core::result::Result<(), rustc_errors::ErrorReported>>
  22: <rustc_interface::interface::Compiler>::enter::<rustc_driver::run_compiler::{closure#1}::{closure#2}, core::result::Result<core::option::Option<rustc_interface::queries::Linker>, rustc_errors::ErrorReported>>
  23: rustc_span::with_source_map::<core::result::Result<(), rustc_errors::ErrorReported>, rustc_interface::interface::create_compiler_and_run<core::result::Result<(), rustc_errors::ErrorReported>, rustc_driver::run_compiler::{closure#1}>::{closure#1}>
  24: <scoped_tls::ScopedKey<rustc_span::SessionGlobals>>::set::<rustc_interface::util::setup_callbacks_and_run_in_thread_pool_with_globals<rustc_interface::interface::run_compiler<core::result::Result<(), rustc_errors::ErrorReported>, rustc_driver::run_compiler::{closure#1}>::{closure#0}, core::result::Result<(), rustc_errors::ErrorReported>>::{closure#0}::{closure#0}, core::result::Result<(), rustc_errors::ErrorReported>>
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

error: internal compiler error: unexpected panic

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.58.0 (02072b482 2022-01-11) running on aarch64-apple-darwin

note: compiler flags: -C embed-bitcode=no -C split-debuginfo=unpacked -C debuginfo=2 -C incremental

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

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

@Aaron1011
Copy link
Member

@zvkemp Are you able to consistently reproduce the crash after running cargo clean by re-applying the sequence of building and editing that you performed?

@rsalmei
Copy link

rsalmei commented Jan 20, 2022

I've just had it too, going to try cargo clean afterwards:

thread 'rustc' panicked at 'called `Option::unwrap()` on a `None` value', /rustc/02072b482a8b5357f7fb5e5637444ae30e423c40/compiler/rustc_hir/src/definitions.rs:452:14
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

error: internal compiler error: unexpected panic

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.58.0 (02072b482 2022-01-11) running on x86_64-apple-darwin

note: compiler flags: -C embed-bitcode=no -C split-debuginfo=unpacked -C debuginfo=2 -C incremental --crate-type bin

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

query stack during panic:
#0 [evaluate_obligation] evaluating trait selection obligation `impl core::future::future::Future<Output = core::result::Result<alloc::boxed::Box<(dyn warp::reply::Reply + 'static)>, core::convert::Infallible>>: core::marker::Send`  |  = note: this failure-note originates in the macro `mk_route` (in Nightly builds, run with -Z macro-backtrace for more info)

#1 [typeck] type-checking `api::run`
end of query stack

EDIT:
cargo clean did fix it.
I was refactoring some things and moved a module inside another directory. I think that was the trigger.

matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Jan 20, 2022
…i-obk

Show a more informative panic message when `DefPathHash` does not exist

This should hopefully make it easier to debug incremental compilation
bugs like rust-lang#93096 without affecting performance.
@ineiti
Copy link

ineiti commented Jan 24, 2022

Same thing here, but cargo clean fixed it. I had a not-too-old git-commit, so I tried to do:

git stash
cargo clean
cargo build
git stash pop
cargo build

But it didn't trigger the error...

@xanathar
Copy link
Contributor

Same here.

Running cargo test after an important refactoring made rustc panic on x86_64-pc-windows-msvc.

Without thinking twice I ran cargo clean and that fixed everything, so I assume it was some intermediate files which were inconsistent, maybe caused by rust analyzer running cargo check while editing?

Anyway, the gist is that I can't provide a minimal source code reproing because 1) it seems unrelated to the specific source code 2) if clean fixes, code probably wouldn't repro anyway.

Meta

rustc --version --verbose:

rustc 1.58.0 (02072b482 2022-01-11)
binary: rustc
commit-hash: 02072b482a8b5357f7fb5e5637444ae30e423c40
commit-date: 2022-01-11
host: x86_64-pc-windows-msvc
release: 1.58.0
LLVM version: 13.0.0

Error output

thread 'rustc' panicked at 'called `Option::unwrap()` on a `None` value', /rustc/02072b482a8b5357f7fb5e5637444ae30e423c40\compiler\rustc_hir\src\definitions.rs:452:14
Backtrace

thread 'rustc' panicked at 'called `Option::unwrap()` on a `None` value', /rustc/02072b482a8b5357f7fb5e5637444ae30e423c40\compiler\rustc_hir\src\definitions.rs:452:14
stack backtrace:
   0:     0x7ffd2ba19c3f - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h4e35ab114ce29e2e
   1:     0x7ffd2ba44aea - core::fmt::write::h83a1b8a9a204aefd
   2:     0x7ffd2ba0b538 - <std::io::IoSlice as core::fmt::Debug>::fmt::h1ddade45cf8208fa
   3:     0x7ffd2ba1d556 - std::panicking::take_hook::h2b301730edd12368
   4:     0x7ffd2ba1cf35 - std::panicking::take_hook::h2b301730edd12368
   5:     0x7ffd2bffd5de - <rustc_ast_lowering[d6169e6a755f4cc5]::item::ItemLowerer as rustc_ast[a9e976c478ba2cc6]::visit::Visitor>::visit_attribute
   6:     0x7ffd2ba1de69 - std::panicking::rust_panic_with_hook::hcafb622216ee7b39
   7:     0x7ffd2ba1d8df - rust_begin_unwind
   8:     0x7ffd2ba1a587 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h4e35ab114ce29e2e
   9:     0x7ffd2ba1d869 - rust_begin_unwind
  10:     0x7ffd2ba78f20 - core::panicking::panic_fmt::h642c5216f3cb43f3
  11:     0x7ffd2ba78e6c - core::panicking::panic::h4fc2634ac0de5286
  12:     0x7ffd3045391a - <rustc_middle[fc5481cb4acc12cb]::ty::context::TyCtxt>::def_path_hash_to_def_id
  13:     0x7ffd3054714e - <rustc_query_system[7858547ed395856b]::dep_graph::dep_node::DepNode<rustc_middle[fc5481cb4acc12cb]::dep_graph::dep_node::DepKind> as rustc_middle[fc5481cb4acc12cb]::dep_graph::dep_node::DepNodeExt>::extract_def_id
  14:     0x7ffd2f7bdd0e - rustc_query_impl[e09ea31778da6781]::query_callbacks::hir_owner
  15:     0x7ffd30438613 - <rustc_middle[fc5481cb4acc12cb]::ty::context::TyCtxt as rustc_query_system[7858547ed395856b]::dep_graph::DepContext>::try_force_from_dep_node
  16:     0x7ffd2f7f40fb - rustc_query_impl[e09ea31778da6781]::query_callbacks::diagnostic_hir_wf_check
  17:     0x7ffd2f7f40d7 - rustc_query_impl[e09ea31778da6781]::query_callbacks::diagnostic_hir_wf_check
  18:     0x7ffd2f7f40d7 - rustc_query_impl[e09ea31778da6781]::query_callbacks::diagnostic_hir_wf_check
  19:     0x7ffd2f7f40d7 - rustc_query_impl[e09ea31778da6781]::query_callbacks::diagnostic_hir_wf_check
  20:     0x7ffd2f7f40d7 - rustc_query_impl[e09ea31778da6781]::query_callbacks::diagnostic_hir_wf_check
  21:     0x7ffd2f7f40d7 - rustc_query_impl[e09ea31778da6781]::query_callbacks::diagnostic_hir_wf_check
  22:     0x7ffd2f7cc40d - rustc_query_impl[e09ea31778da6781]::query_callbacks::diagnostic_hir_wf_check
  23:     0x7ffd2f4f876c - <rustc_mir_dataflow[29483ab09f03f9e6]::framework::engine::RustcMirAttrs>::output_path
  24:     0x7ffd2f64b552 - <rustc_mir_dataflow[29483ab09f03f9e6]::framework::engine::RustcMirAttrs>::output_path
  25:     0x7ffd2c1f1a01 - <rustc_interface[f7d5b064990b81b2]::passes::boxed_resolver::BoxedResolver>::to_resolver_outputs
  26:     0x7ffd2c147af6 - rustc_interface[f7d5b064990b81b2]::passes::analysis
  27:     0x7ffd2f75282b - <rustc_span[778bd905e75c315a]::def_id::DefIndex as rustc_query_impl[e09ea31778da6781]::profiling_support::SpecIntoSelfProfilingString>::spec_to_self_profile_string
  28:     0x7ffd2f827a6e - rustc_query_impl[e09ea31778da6781]::query_callbacks::diagnostic_hir_wf_check
  29:     0x7ffd2f6f6561 - <rustc_query_impl[e09ea31778da6781]::queries::diagnostic_hir_wf_check as rustc_query_system[7858547ed395856b]::query::config::QueryDescription<rustc_query_impl[e09ea31778da6781]::plumbing::QueryCtxt>>::describe
  30:     0x7ffd2f5f0591 - <rustc_mir_dataflow[29483ab09f03f9e6]::framework::engine::RustcMirAttrs>::output_path
  31:     0x7ffd2f726d22 - <rustc_query_impl[e09ea31778da6781]::Queries as rustc_middle[fc5481cb4acc12cb]::ty::query::QueryEngine>::try_mark_green
  32:     0x7ffd2c06d62a - <rustc_driver[12b05176f1464f4f]::args::Error as core[16a571ebe10d9bcf]::fmt::Debug>::fmt
  33:     0x7ffd2c02362c - <rustc_middle[fc5481cb4acc12cb]::ty::SymbolName as core[16a571ebe10d9bcf]::fmt::Display>::fmt
  34:     0x7ffd2c014e1b - <rustc_ast_passes[12f57c553c3231c3]::node_count::NodeCounter as rustc_ast[a9e976c478ba2cc6]::visit::Visitor>::visit_ident
  35:     0x7ffd2c041141 - <rustc_middle[fc5481cb4acc12cb]::ty::SymbolName as core[16a571ebe10d9bcf]::fmt::Display>::fmt
  36:     0x7ffd2c020643 - rustc_driver[12b05176f1464f4f]::pretty::print_after_hir_lowering
  37:     0x7ffd2c0884b8 - <rustc_driver[12b05176f1464f4f]::args::Error as core[16a571ebe10d9bcf]::fmt::Debug>::fmt
  38:     0x7ffd2ba2b8ec - std::sys::windows::thread::Thread::new::h10c3f3613eb8c5b7
  39:     0x7ffdb36a54e0 - BaseThreadInitThunk
  40:     0x7ffdb420485b - RtlUserThreadStart

error: internal compiler error: unexpected panic

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.58.0 (02072b482 2022-01-11) running on x86_64-pc-windows-msvc

note: compiler flags: -C embed-bitcode=no -C debuginfo=2 -C incremental --crate-type lib

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

@Manishearth
Copy link
Member

I have an open source crate having this problem in https://github.com/manishearth/icu4x/tree/ice-dep-hash : cd utils/zerovec && cargo check --all-features

I'm unable to reproduce after cargo clean, but the last commit is what caused the ICE

@workingjubilee
Copy link
Member

This is almost certainly a duplicate of this issue and was probably resolved in this PR:

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. 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.
Projects
None yet
Development

No branches or pull requests

8 participants