Skip to content

ICE unwrap in compiler/rustc_hir/src/definitions.rs:452:14 #90715

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
jbr opened this issue Nov 8, 2021 · 6 comments
Closed

ICE unwrap in compiler/rustc_hir/src/definitions.rs:452:14 #90715

jbr opened this issue Nov 8, 2021 · 6 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) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@jbr
Copy link
Contributor

jbr commented Nov 8, 2021

Code

Unfortunately I changed a lot of things in a large codebase and am not sure which resulted in this ICE, but thought I'd report anyway. Sorry and thanks!

Meta

rustc --version --verbose:

rustc 1.58.0-nightly (0d1754e8b 2021-11-05)
binary: rustc
commit-hash: 0d1754e8bf6942b4c1d24d7c923438782129ba5a
commit-date: 2021-11-05
host: x86_64-apple-darwin
release: 1.58.0-nightly
LLVM version: 13.0.0

Error output

thread 'rustc' panicked at 'called `Option::unwrap()` on a `None` value', /rustc/0d1754e8bf6942b4c1d24d7c923438782129ba5a/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-nightly (0d1754e8b 2021-11-05) 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 [analysis] running analysis passes on this crate
end of query stack
Backtrace

thread 'rustc' panicked at 'called `Option::unwrap()` on a `None` value', /rustc/0d1754e8bf6942b4c1d24d7c923438782129ba5a/compiler/rustc_hir/src/definitions.rs:452:14
stack backtrace:
   0:        0x10d8b6861 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h9c9c2c58a5e55211
   1:        0x10d90772b - core::fmt::write::h2d5ecb4b9764759c
   2:        0x10d8a7e3a - std::io::Write::write_fmt::hbb2ed9492eac32a2
   3:        0x10d8b99c5 - std::panicking::default_hook::{{closure}}::h39365228a3bf0aa2
   4:        0x10d8b95af - std::panicking::default_hook::h8ca622aa16a42db0
   5:        0x11bfccc60 - rustc_driver[8702e6016a2d953f]::DEFAULT_HOOK::{closure#0}::{closure#0}
   6:        0x10d8ba206 - std::panicking::rust_panic_with_hook::ha8b89b2b3829767b
   7:        0x10d8b9c54 - std::panicking::begin_panic_handler::{{closure}}::h92845c1f420a7f41
   8:        0x10d8b6ce7 - std::sys_common::backtrace::__rust_end_short_backtrace::hdae352311dc8769f
   9:        0x10d8b9bea - _rust_begin_unwind
  10:        0x10d93259f - core::panicking::panic_fmt::h88a1b6fbb9084d2c
  11:        0x10d9324f7 - core::panicking::panic::hf0752d57e0382e6d
  12:        0x1203859db - <rustc_middle[5473db7a6f082ce6]::ty::context::TyCtxt>::def_path_hash_to_def_id
  13:        0x1204827bb - <rustc_query_system[af5ff6f8e7ca742d]::dep_graph::dep_node::DepNode<rustc_middle[5473db7a6f082ce6]::dep_graph::dep_node::DepKind> as rustc_middle[5473db7a6f082ce6]::dep_graph::dep_node::DepNodeExt>::extract_def_id
  14:        0x11f723e1a - rustc_query_impl[ef74b726d3255e86]::query_callbacks::hir_owner::force_from_dep_node
  15:        0x12036d9cc - <rustc_middle[5473db7a6f082ce6]::ty::context::TyCtxt as rustc_query_system[af5ff6f8e7ca742d]::dep_graph::DepContext>::try_force_from_dep_node
  16:        0x11f787c6d - <rustc_query_system[af5ff6f8e7ca742d]::dep_graph::graph::DepGraph<rustc_middle[5473db7a6f082ce6]::dep_graph::dep_node::DepKind>>::try_mark_previous_green::<rustc_query_impl[ef74b726d3255e86]::plumbing::QueryCtxt>
  17:        0x11f787c37 - <rustc_query_system[af5ff6f8e7ca742d]::dep_graph::graph::DepGraph<rustc_middle[5473db7a6f082ce6]::dep_graph::dep_node::DepKind>>::try_mark_previous_green::<rustc_query_impl[ef74b726d3255e86]::plumbing::QueryCtxt>
  18:        0x11f787c37 - <rustc_query_system[af5ff6f8e7ca742d]::dep_graph::graph::DepGraph<rustc_middle[5473db7a6f082ce6]::dep_graph::dep_node::DepKind>>::try_mark_previous_green::<rustc_query_impl[ef74b726d3255e86]::plumbing::QueryCtxt>
  19:        0x11f787c37 - <rustc_query_system[af5ff6f8e7ca742d]::dep_graph::graph::DepGraph<rustc_middle[5473db7a6f082ce6]::dep_graph::dep_node::DepKind>>::try_mark_previous_green::<rustc_query_impl[ef74b726d3255e86]::plumbing::QueryCtxt>
  20:        0x11f749fb0 - <rustc_query_system[af5ff6f8e7ca742d]::dep_graph::graph::DepGraph<rustc_middle[5473db7a6f082ce6]::dep_graph::dep_node::DepKind>>::try_mark_green::<rustc_query_impl[ef74b726d3255e86]::plumbing::QueryCtxt>
  21:        0x11f4fa7a0 - rustc_query_system[af5ff6f8e7ca742d]::query::plumbing::ensure_must_run::<rustc_query_impl[ef74b726d3255e86]::plumbing::QueryCtxt, rustc_span[a08cc5ade0305263]::def_id::DefId, alloc[6b2a4c4c8c58ee9a]::vec::Vec<&rustc_middle[5473db7a6f082ce6]::mir::coverage::CodeRegion>>
  22:        0x11f5fb0ea - rustc_query_system[af5ff6f8e7ca742d]::query::plumbing::get_query::<rustc_query_impl[ef74b726d3255e86]::queries::coherent_trait, rustc_query_impl[ef74b726d3255e86]::plumbing::QueryCtxt>
  23:        0x11ea79d87 - <rustc_session[84d5bb8c04871b82]::session::Session>::track_errors::<rustc_typeck[72f05ee69e92895f]::check_crate::{closure#3}, ()>
  24:        0x11ea483f2 - rustc_typeck[72f05ee69e92895f]::check_crate
  25:        0x11c1079da - rustc_interface[36a618782d12d380]::passes::analysis
  26:        0x11f7cdd8c - <rustc_query_system[af5ff6f8e7ca742d]::dep_graph::graph::DepGraph<rustc_middle[5473db7a6f082ce6]::dep_graph::dep_node::DepKind>>::with_task::<rustc_middle[5473db7a6f082ce6]::ty::context::TyCtxt, (), core[f4889159fda6615f]::result::Result<(), rustc_errors[7f9540041f075328]::ErrorReported>>
  27:        0x11f6f1e15 - rustc_data_structures[5e52a2b4416cafe3]::stack::ensure_sufficient_stack::<(core[f4889159fda6615f]::result::Result<(), rustc_errors[7f9540041f075328]::ErrorReported>, rustc_query_system[af5ff6f8e7ca742d]::dep_graph::graph::DepNodeIndex), rustc_query_system[af5ff6f8e7ca742d]::query::plumbing::execute_job<rustc_query_impl[ef74b726d3255e86]::plumbing::QueryCtxt, (), core[f4889159fda6615f]::result::Result<(), rustc_errors[7f9540041f075328]::ErrorReported>>::{closure#3}>
  28:        0x11f590715 - rustc_query_system[af5ff6f8e7ca742d]::query::plumbing::try_execute_query::<rustc_query_impl[ef74b726d3255e86]::plumbing::QueryCtxt, rustc_query_system[af5ff6f8e7ca742d]::query::caches::DefaultCache<(), core[f4889159fda6615f]::result::Result<(), rustc_errors[7f9540041f075328]::ErrorReported>>>
  29:        0x11f627eb5 - rustc_query_system[af5ff6f8e7ca742d]::query::plumbing::get_query::<rustc_query_impl[ef74b726d3255e86]::queries::analysis, rustc_query_impl[ef74b726d3255e86]::plumbing::QueryCtxt>
  30:        0x11c035e2b - <rustc_interface[36a618782d12d380]::passes::QueryContext>::enter::<rustc_driver[8702e6016a2d953f]::run_compiler::{closure#1}::{closure#2}::{closure#3}, core[f4889159fda6615f]::result::Result<(), rustc_errors[7f9540041f075328]::ErrorReported>>
  31:        0x11c017e60 - <rustc_interface[36a618782d12d380]::interface::Compiler>::enter::<rustc_driver[8702e6016a2d953f]::run_compiler::{closure#1}::{closure#2}, core[f4889159fda6615f]::result::Result<core[f4889159fda6615f]::option::Option<rustc_interface[36a618782d12d380]::queries::Linker>, rustc_errors[7f9540041f075328]::ErrorReported>>
  32:        0x11bfdb9aa - rustc_span[a08cc5ade0305263]::with_source_map::<core[f4889159fda6615f]::result::Result<(), rustc_errors[7f9540041f075328]::ErrorReported>, rustc_interface[36a618782d12d380]::interface::create_compiler_and_run<core[f4889159fda6615f]::result::Result<(), rustc_errors[7f9540041f075328]::ErrorReported>, rustc_driver[8702e6016a2d953f]::run_compiler::{closure#1}>::{closure#0}>
  33:        0x11c018ddc - <scoped_tls[504a04b5a30bb02b]::ScopedKey<rustc_span[a08cc5ade0305263]::SessionGlobals>>::set::<rustc_interface[36a618782d12d380]::util::setup_callbacks_and_run_in_thread_pool_with_globals<rustc_interface[36a618782d12d380]::interface::run_compiler<core[f4889159fda6615f]::result::Result<(), rustc_errors[7f9540041f075328]::ErrorReported>, rustc_driver[8702e6016a2d953f]::run_compiler::{closure#1}>::{closure#0}, core[f4889159fda6615f]::result::Result<(), rustc_errors[7f9540041f075328]::ErrorReported>>::{closure#0}::{closure#0}, core[f4889159fda6615f]::result::Result<(), rustc_errors[7f9540041f075328]::ErrorReported>>
  34:        0x11bfe5c82 - std[69c2830741c23f7e]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[36a618782d12d380]::util::setup_callbacks_and_run_in_thread_pool_with_globals<rustc_interface[36a618782d12d380]::interface::run_compiler<core[f4889159fda6615f]::result::Result<(), rustc_errors[7f9540041f075328]::ErrorReported>, rustc_driver[8702e6016a2d953f]::run_compiler::{closure#1}>::{closure#0}, core[f4889159fda6615f]::result::Result<(), rustc_errors[7f9540041f075328]::ErrorReported>>::{closure#0}, core[f4889159fda6615f]::result::Result<(), rustc_errors[7f9540041f075328]::ErrorReported>>
  35:        0x11bfd2a75 - <<std[69c2830741c23f7e]::thread::Builder>::spawn_unchecked<rustc_interface[36a618782d12d380]::util::setup_callbacks_and_run_in_thread_pool_with_globals<rustc_interface[36a618782d12d380]::interface::run_compiler<core[f4889159fda6615f]::result::Result<(), rustc_errors[7f9540041f075328]::ErrorReported>, rustc_driver[8702e6016a2d953f]::run_compiler::{closure#1}>::{closure#0}, core[f4889159fda6615f]::result::Result<(), rustc_errors[7f9540041f075328]::ErrorReported>>::{closure#0}, core[f4889159fda6615f]::result::Result<(), rustc_errors[7f9540041f075328]::ErrorReported>>::{closure#1} as core[f4889159fda6615f]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  36:        0x10d8c4017 - std::sys::unix::thread::Thread::new::thread_start::h96b3fd9d7d5e1337
  37:     0x7ff80f41e514 - __pthread_start

@jbr jbr 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 Nov 8, 2021
@michaelwoerister
Copy link
Member

Thanks for the bug report, @jbr! Do you by any chance also use cargo clippy?

@Badel2
Copy link
Contributor

Badel2 commented Nov 9, 2021

Duplicate of #90697, which is also a duplicate of #90682

@michaelwoerister
Copy link
Member

@cjgillot, are we missing some kind dep-tracking that causes a query to be re-run even though one of its preconditions isn't met?

@cjgillot cjgillot self-assigned this Nov 15, 2021
@cjgillot
Copy link
Contributor

@michaelwoerister yes, I believe we some dep-tracking here, but I have no idea which one beyond the usual suspects.

The failing query is hir_owner (backtrace, line 14). There is no information on which is the caller query, as it happens after inside several levels of try_mark_parent_green.

@BGR360
Copy link
Contributor

BGR360 commented Dec 21, 2021

Hopefully fixed by #91919.

@rustbot label +A-incr-comp

@rustbot rustbot added the A-incr-comp Area: Incremental compilation label Dec 21, 2021
bors added a commit to rust-lang-ci/rust that referenced this issue Feb 24, 2023
Print a backtrace when query forcing fails.

The aim of this PR is to help debugging incremental compilation bugs where query forcing panics.
For instance: rust-lang#90682 rust-lang#90697 rust-lang#90715 rust-lang#90739 rust-lang#91401

These bugs happen when the dep-graph attempts to force a dep-node whose fingerprint does not correspond to an actual DefPathHash. PR rust-lang#91741 attempts to hide this bug.

I still don't know how to reproduce these bugs, so I sadly could not test this debugging device.
RalfJung pushed a commit to RalfJung/miri that referenced this issue Feb 26, 2023
Print a backtrace when query forcing fails.

The aim of this PR is to help debugging incremental compilation bugs where query forcing panics.
For instance: rust-lang/rust#90682 rust-lang/rust#90697 rust-lang/rust#90715 rust-lang/rust#90739 rust-lang/rust#91401

These bugs happen when the dep-graph attempts to force a dep-node whose fingerprint does not correspond to an actual DefPathHash. PR rust-lang/rust#91741 attempts to hide this bug.

I still don't know how to reproduce these bugs, so I sadly could not test this debugging device.
RalfJung pushed a commit to RalfJung/rust-analyzer that referenced this issue Apr 20, 2024
Print a backtrace when query forcing fails.

The aim of this PR is to help debugging incremental compilation bugs where query forcing panics.
For instance: rust-lang/rust#90682 rust-lang/rust#90697 rust-lang/rust#90715 rust-lang/rust#90739 rust-lang/rust#91401

These bugs happen when the dep-graph attempts to force a dep-node whose fingerprint does not correspond to an actual DefPathHash. PR rust-lang/rust#91741 attempts to hide this bug.

I still don't know how to reproduce these bugs, so I sadly could not test this debugging device.
RalfJung pushed a commit to RalfJung/rust-analyzer that referenced this issue Apr 27, 2024
Print a backtrace when query forcing fails.

The aim of this PR is to help debugging incremental compilation bugs where query forcing panics.
For instance: rust-lang/rust#90682 rust-lang/rust#90697 rust-lang/rust#90715 rust-lang/rust#90739 rust-lang/rust#91401

These bugs happen when the dep-graph attempts to force a dep-node whose fingerprint does not correspond to an actual DefPathHash. PR rust-lang/rust#91741 attempts to hide this bug.

I still don't know how to reproduce these bugs, so I sadly could not test this debugging device.
# for free to join this conversation on GitHub. Already have an account? # 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

Successfully merging a pull request may close this issue.

7 participants