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

thread 'rustc' panicked at 'called Option::unwrap() on a None value', /rustc/c1026539bd22e9d070988deaa47b1360cbc76436/compiler/rustc_hir/src/definitions.rs:452:14 #89962

Closed
moshevds opened this issue Oct 16, 2021 · 4 comments
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) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@moshevds
Copy link

moshevds commented Oct 16, 2021

I was cleaning up some code, attempting to replace an empty enum with the never type.

My changes encountered some sort of bug with the cache. Trying to create a minimal verifiable example fails entirely, probably related to this being a caching issue. Even if I copy my entire project directory without any other changes, the crash disappears.

The crash is reproducible in the original directory for now. With some guidance on what (cache)files I should look at, I think it should be possible to describe a way to reproduce this.

Another relevant bit of information might be that I updated my nightly toolchain about 30 minutes before. I did fix a number of clippy warnings with the new toolchain before the crash occurred, so maybe this is not part of the problem.

Code

Before:

pub enum NoFData {}
pub enum NoEData {}

pub enum JSendResponse<
    SData,
    FData=NoFData,
    EData=NoEData,
    EMsg=&'static str,
    ECode=usize,
>
where
    EMsg: std::fmt::Display,
    ECode: num::Num + std::fmt::Display,
{
    ...
}

After:

pub enum JSendResponse<
    SData,
    FData=!,
    EData=!,
    EMsg=&'static str,
    ECode=usize,
>
where
    EMsg: std::fmt::Display,
    ECode: num::Num + std::fmt::Display,
{
    ...
}

Meta

rustc --version --verbose:

rustc 1.57.0-nightly (c1026539b 2021-10-15)
binary: rustc
commit-hash: c1026539bd22e9d070988deaa47b1360cbc76436
commit-date: 2021-10-15
host: x86_64-unknown-linux-gnu
release: 1.57.0-nightly
LLVM version: 13.0.0

Error output

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

stack backtrace:
   0: rust_begin_unwind
             at /rustc/c1026539bd22e9d070988deaa47b1360cbc76436/library/std/src/panicking.rs:517:5
   1: core::panicking::panic_fmt
             at /rustc/c1026539bd22e9d070988deaa47b1360cbc76436/library/core/src/panicking.rs:100:14
   2: core::panicking::panic
             at /rustc/c1026539bd22e9d070988deaa47b1360cbc76436/library/core/src/panicking.rs:50:5
   3: <rustc_query_impl::on_disk_cache::OnDiskCache as rustc_middle::ty::context::OnDiskCache>::def_path_hash_to_def_id
   4: rustc_middle::dep_graph::dep_node::<impl rustc_query_system::dep_graph::dep_node::DepNodeParams<rustc_middle::ty::context::TyCtxt> for rustc_span::def_id::LocalDefId>::recover
   5: rustc_query_impl::query_callbacks::hir_owner::force_from_dep_node
   6: rustc_query_system::dep_graph::graph::DepGraph<K>::try_mark_previous_green
   7: rustc_query_system::dep_graph::graph::DepGraph<K>::try_mark_previous_green
   8: rustc_query_system::query::plumbing::ensure_must_run
   9: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::typeck
  10: rustc_data_structures::sync::par_for_each_in
  11: rustc_typeck::check::typeck_item_bodies
  12: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task
  13: rustc_data_structures::stack::ensure_sufficient_stack
  14: rustc_query_system::query::plumbing::try_execute_query
  15: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::typeck_item_bodies
  16: rustc_session::utils::<impl rustc_session::session::Session>::time
  17: rustc_typeck::check_crate
  18: rustc_interface::passes::analysis
  19: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task
  20: rustc_data_structures::stack::ensure_sufficient_stack
  21: rustc_query_system::query::plumbing::try_execute_query
  22: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::analysis
  23: rustc_interface::passes::QueryContext::enter
  24: rustc_interface::queries::<impl rustc_interface::interface::Compiler>::enter
  25: rustc_span::with_source_map
  26: scoped_tls::ScopedKey<T>::set

@moshevds moshevds 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 Oct 16, 2021
@Thomasdezeeuw
Copy link
Contributor

Thomasdezeeuw commented Oct 23, 2021

I just hit this as well with rustc 1.58.0-nightly (547a6ffee 2021-10-21) running on x86_64-apple-darwin.

Remove the target dir and compiling again "fixed" the issue.

@ralfbiedert
Copy link
Contributor

Same issue here. Happens in large project, can't reliably reproduce. My backtrace differs a bit, but panic location is the same:

thread 'rustc' panicked at 'called `Option::unwrap()` on a `None` value', /rustc/00d5e42e776da900049fe19087bc9b0057ec70cd\compiler\rustc_hir\src\definitions.rs:452:14
stack backtrace:
   0:     0x7fff784a8c0f - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h4287336b592e4e30
   1:     0x7fff784d28ca - core::fmt::write::h8a2c40ddb66ccc71
   2:     0x7fff7849b5b8 - <std::io::IoSliceMut as core::fmt::Debug>::fmt::hd15f09e3fd3eac54
   3:     0x7fff784ac366 - std::panicking::take_hook::hf14c76592f73c762
   4:     0x7fff784abe4c - std::panicking::take_hook::hf14c76592f73c762
   5:     0x7fff5ce5a945 - <rustc_metadata[dfdfc7113336e1f8]::native_libs::Collector as rustc_hir[c1b1b26d2913040d]::itemlikevisit::ItemLikeVisitor>::visit_trait_item
   6:     0x7fff784acc79 - std::panicking::rust_panic_with_hook::hbc0e9c80ca88eac0
   7:     0x7fff784ac6ef - rust_begin_unwind
   8:     0x7fff784a9547 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h4287336b592e4e30
   9:     0x7fff784ac679 - rust_begin_unwind
  10:     0x7fff78508de0 - core::panicking::panic_fmt::hc1b1ca620e7a2c9f
  11:     0x7fff78508d2c - core::panicking::panic::hfef5cee9afdef02a
  12:     0x7fff6131a89a - <rustc_middle[68438b5bfe988d4e]::ty::context::TyCtxt>::def_path_hash_to_def_id
  13:     0x7fff61418fce - <rustc_query_system[993d4a9a8633e257]::dep_graph::dep_node::DepNode<rustc_middle[68438b5bfe988d4e]::dep_graph::dep_node::DepKind> as rustc_middle[68438b5bfe988d4e]::dep_graph::dep_node::DepNodeExt>::extract_def_id
  14:     0x7fff606fc5e4 - rustc_query_impl[2492acdb0e5eb4f6]::query_callbacks::hir_owner
  15:     0x7fff61301773 - <rustc_middle[68438b5bfe988d4e]::ty::context::TyCtxt as rustc_query_system[993d4a9a8633e257]::dep_graph::DepContext>::try_force_from_dep_node
  16:     0x7fff6067dabb - <rustc_query_impl[2492acdb0e5eb4f6]::Queries as rustc_middle[68438b5bfe988d4e]::ty::query::QueryEngine>::try_mark_green
  17:     0x7fff6067da97 - <rustc_query_impl[2492acdb0e5eb4f6]::Queries as rustc_middle[68438b5bfe988d4e]::ty::query::QueryEngine>::try_mark_green
  18:     0x7fff6067da97 - <rustc_query_impl[2492acdb0e5eb4f6]::Queries as rustc_middle[68438b5bfe988d4e]::ty::query::QueryEngine>::try_mark_green
  19:     0x7fff6067da97 - <rustc_query_impl[2492acdb0e5eb4f6]::Queries as rustc_middle[68438b5bfe988d4e]::ty::query::QueryEngine>::try_mark_green
  20:     0x7fff60655dda - <rustc_query_impl[2492acdb0e5eb4f6]::Queries as rustc_middle[68438b5bfe988d4e]::ty::query::QueryEngine>::try_mark_green
  21:     0x7fff60370147 - <rustc_mir_dataflow[b218101e43c2c97d]::framework::cursor::CursorPosition as core[3b5640218fb446b]::fmt::Debug>::fmt
  22:     0x7fff6050cda5 - <rustc_mir_dataflow[b218101e43c2c97d]::framework::cursor::CursorPosition as core[3b5640218fb446b]::fmt::Debug>::fmt
  23:     0x7fff5f865760 - <rustc_typeck[2dede4d9058b9b75]::outlives::explicit::ExplicitPredicatesMap as core[3b5640218fb446b]::fmt::Debug>::fmt
  24:     0x7fff5f82f840 - rustc_typeck[2dede4d9058b9b75]::check_crate
  25:     0x7fff5cfb72ff - rustc_interface[ff1d7c07a753e82f]::passes::analysis
  26:     0x7fff60603c7b - <rustc_span[abfcba77a0dab5e7]::def_id::DefIndex as rustc_query_impl[2492acdb0e5eb4f6]::profiling_support::SpecIntoSelfProfilingString>::spec_to_self_profile_string
  27:     0x7fff606b142e - <rustc_query_impl[2492acdb0e5eb4f6]::Queries as rustc_middle[68438b5bfe988d4e]::ty::query::QueryEngine>::try_mark_green
  28:     0x7fff605de5f1 - <rustc_span[abfcba77a0dab5e7]::def_id::DefIndex as rustc_query_impl[2492acdb0e5eb4f6]::profiling_support::SpecIntoSelfProfilingString>::spec_to_self_profile_string
  29:     0x7fff60487c29 - <rustc_mir_dataflow[b218101e43c2c97d]::framework::cursor::CursorPosition as core[3b5640218fb446b]::fmt::Debug>::fmt
  30:     0x7fff60521e79 - <rustc_mir_dataflow[b218101e43c2c97d]::framework::cursor::CursorPosition as core[3b5640218fb446b]::fmt::Debug>::fmt
  31:     0x7fff5cebadc0 - <rustc_middle[68438b5bfe988d4e]::ty::SymbolName as core[3b5640218fb446b]::fmt::Display>::fmt
  32:     0x7fff5cebb85b - <rustc_middle[68438b5bfe988d4e]::ty::SymbolName as core[3b5640218fb446b]::fmt::Display>::fmt
  33:     0x7fff5ce746e6 - rustc_driver[af3c8dcfa508860b]::pretty::print_after_hir_lowering
  34:     0x7fff5ced8a76 - <rustc_middle[68438b5bfe988d4e]::ty::SymbolName as core[3b5640218fb446b]::fmt::Display>::fmt
  35:     0x7fff5ce7ddb7 - <rustc_middle[68438b5bfe988d4e]::ty::SymbolName as core[3b5640218fb446b]::fmt::Display>::fmt
  36:     0x7fff5ce7b00c - <tracing_subscriber[281ba6a53a80a207]::util::TryInitError as core[3b5640218fb446b]::fmt::Display>::fmt
  37:     0x7fff5cef6668 - <rustc_driver[af3c8dcfa508860b]::args::Error as core[3b5640218fb446b]::fmt::Debug>::fmt
  38:     0x7fff784b933c - std::sys::windows::thread::Thread::new::he49a5cdb1d3d1cfc
  39:     0x7fffd6db7034 - BaseThreadInitThunk
  40:     0x7fffd6f22651 - 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-nightly (00d5e42e7 2021-10-24) running on x86_64-pc-windows-msvc

note: compiler flags: -C embed-bitcode=no -C debuginfo=2 -C linker=rust-lld.exe -C incremental --crate-type lib --crate-type cdylib

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

@BGR360
Copy link
Contributor

BGR360 commented Dec 21, 2021

Looks like a known incremental compilation bug. That's why cleaning the target directory fixes it.

See #91696. Hopefully fixed by #91919.

@rustbot label +A-incr-comp

@rustbot rustbot added the A-incr-comp Area: Incremental compilation label Dec 21, 2021
@workingjubilee
Copy link
Contributor

Closing assuming the previous "it's a duplicate" is correct, because it seems so to my eyes. Should be fixed by either that or #93064

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) ❄️ 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

6 participants