Skip to content

ICE: Failed to extract DefId: opt_local_def_id_to_hir_id #114768

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

Open
8051Enthusiast opened this issue Aug 13, 2023 · 3 comments
Open

ICE: Failed to extract DefId: opt_local_def_id_to_hir_id #114768

8051Enthusiast opened this issue Aug 13, 2023 · 3 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) ❄️ S-has-mcve Status: A Minimal Complete and Verifiable Example has been found for this issue T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@8051Enthusiast
Copy link

8051Enthusiast commented Aug 13, 2023

Code

Can be reproduced by first building (in debug mode) crates/yaboc-hir of https://github.com/8051enthusiast/yabo at commit 442536c09df2fe898bfeda81a2788bf9dce9dc19 after a cargo clean and then building at commit 5d5d795041d55d3bcbe21c5052807711dd307f13:

git clone https://github.com/8051enthusiast/yabo
cd yabo/crates/yaboc-hir
git checkout 442536c09df2fe898bfeda81a2788bf9dce9dc19
cargo clean
cargo build
git checkout 5d5d795041d55d3bcbe21c5052807711dd307f13
cargo build # ICE

diff: 8051Enthusiast/yabo@442536c...5d5d795

Meta

rustc --version --verbose:

rustc 1.73.0-nightly (a6f8aa5a0 2023-08-11)
binary: rustc
commit-hash: a6f8aa5a092c5e46fcbdafe4c80b4e55ba0de41c
commit-date: 2023-08-11
host: x86_64-unknown-linux-gnu
release: 1.73.0-nightly
LLVM version: 17.0.0

Also fails on stable.

Error output

Backtrace

thread 'rustc' panicked at compiler/rustc_middle/src/dep_graph/dep_node.rs:181:17:
Failed to extract DefId: opt_local_def_id_to_hir_id 11356bd1ee60cec5-ced77525c7774080
stack backtrace:
   0: rust_begin_unwind
             at /rustc/a6f8aa5a092c5e46fcbdafe4c80b4e55ba0de41c/library/std/src/panicking.rs:617:5
   1: core::panicking::panic_fmt
             at /rustc/a6f8aa5a092c5e46fcbdafe4c80b4e55ba0de41c/library/core/src/panicking.rs:67:14
   2: <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::{closure#0}
   3: <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
   4: <rustc_query_impl::plumbing::query_callback<rustc_query_impl::query_impl::opt_local_def_id_to_hir_id::QueryType>::{closure#0} as core::ops::function::FnOnce<(rustc_middle::ty::context::TyCtxt, rustc_query_system::dep_graph::dep_node::DepNode<rustc_middle::dep_graph::dep_node::DepKind>)>>::call_once
   5: <rustc_query_system::dep_graph::graph::DepGraphData<rustc_middle::dep_graph::dep_node::DepKind>>::try_mark_previous_green::<rustc_query_impl::plumbing::QueryCtxt>
   6: <rustc_query_system::dep_graph::graph::DepGraphData<rustc_middle::dep_graph::dep_node::DepKind>>::try_mark_previous_green::<rustc_query_impl::plumbing::QueryCtxt>
   7: <rustc_query_system::dep_graph::graph::DepGraphData<rustc_middle::dep_graph::dep_node::DepKind>>::try_mark_previous_green::<rustc_query_impl::plumbing::QueryCtxt>
   8: <rustc_query_system::dep_graph::graph::DepGraphData<rustc_middle::dep_graph::dep_node::DepKind>>::try_mark_previous_green::<rustc_query_impl::plumbing::QueryCtxt>
   9: <rustc_query_system::dep_graph::graph::DepGraphData<rustc_middle::dep_graph::dep_node::DepKind>>::try_mark_previous_green::<rustc_query_impl::plumbing::QueryCtxt>
  10: <rustc_query_system::dep_graph::graph::DepGraphData<rustc_middle::dep_graph::dep_node::DepKind>>::try_mark_previous_green::<rustc_query_impl::plumbing::QueryCtxt>
  11: <rustc_query_system::dep_graph::graph::DepGraphData<rustc_middle::dep_graph::dep_node::DepKind>>::try_mark_previous_green::<rustc_query_impl::plumbing::QueryCtxt>
  12: <rustc_query_system::dep_graph::graph::DepGraphData<rustc_middle::dep_graph::dep_node::DepKind>>::try_mark_previous_green::<rustc_query_impl::plumbing::QueryCtxt>
  13: <rustc_query_system::dep_graph::graph::DepGraphData<rustc_middle::dep_graph::dep_node::DepKind>>::try_mark_previous_green::<rustc_query_impl::plumbing::QueryCtxt>
  14: <rustc_query_system::dep_graph::graph::DepGraphData<rustc_middle::dep_graph::dep_node::DepKind>>::try_mark_previous_green::<rustc_query_impl::plumbing::QueryCtxt>
  15: <rustc_query_system::dep_graph::graph::DepGraphData<rustc_middle::dep_graph::dep_node::DepKind>>::try_mark_previous_green::<rustc_query_impl::plumbing::QueryCtxt>
  16: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::DynamicConfig<rustc_query_system::query::caches::DefaultCache<rustc_middle::ty::ParamEnvAnd<(rustc_middle::ty::instance::Instance, &rustc_middle::ty::list::List<rustc_middle::ty::Ty>)>, rustc_middle::query::erase::Erased<[u8; 16]>>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, true>
  17: rustc_codegen_llvm::callee::get_fn
  18: rustc_codegen_ssa::mir::codegen_mir::<rustc_codegen_llvm::builder::Builder>
  19: rustc_codegen_llvm::base::compile_codegen_unit::module_codegen
  20: <rustc_middle::dep_graph::dep_node::DepKind as rustc_query_system::dep_graph::DepKind>::with_deps::<<rustc_query_system::dep_graph::graph::DepGraphData<rustc_middle::dep_graph::dep_node::DepKind>>::with_task<rustc_middle::ty::context::TyCtxt, rustc_span::symbol::Symbol, rustc_codegen_ssa::ModuleCodegen<rustc_codegen_llvm::ModuleLlvm>>::{closure#0}::{closure#0}, rustc_codegen_ssa::ModuleCodegen<rustc_codegen_llvm::ModuleLlvm>>
  21: rustc_codegen_llvm::base::compile_codegen_unit
  22: rustc_codegen_ssa::base::codegen_crate::<rustc_codegen_llvm::LlvmCodegenBackend>
  23: <rustc_codegen_llvm::LlvmCodegenBackend as rustc_codegen_ssa::traits::backend::CodegenBackend>::codegen_crate
  24: <rustc_session::session::Session>::time::<alloc::boxed::Box<dyn core::any::Any>, rustc_interface::passes::start_codegen::{closure#0}>
  25: rustc_interface::passes::start_codegen
  26: <rustc_middle::ty::context::GlobalCtxt>::enter::<<rustc_interface::queries::Queries>::ongoing_codegen::{closure#0}, core::result::Result<alloc::boxed::Box<dyn core::any::Any>, rustc_span::ErrorGuaranteed>>
  27: rustc_span::set_source_map::<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_interface::interface::run_compiler<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_driver_impl::run_compiler::{closure#1}>::{closure#0}::{closure#0}>
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

error: 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: please attach the file at `/home/name/programs/rust/yabo/rustc-ice-2023-08-13T01:26:59.209853937Z-135604.txt` to your bug report

note: compiler flags: --crate-type lib -C embed-bitcode=no -C debuginfo=2 -C linker=clang -C incremental=[REDACTED] -C link-arg=-fuse-ld=/usr/bin/mold

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

query stack during panic:
#0 [fn_abi_of_instance] computing call ABI of `core::ptr::drop_in_place::<salsa::derived::slot::PanicGuard<'_, HirNodeQuery, salsa::derived::AlwaysMemoizeValue>> - shim(Some(salsa::derived::slot::PanicGuard<'_, HirNodeQuery, salsa::derived::AlwaysMemoizeValue>))`
end of query stack
there was a panic while trying to force a dep node
try_mark_green dep node stack:
#0 opt_def_kind(thread 'rustc' panicked at compiler/rustc_middle/src/dep_graph/dep_node.rs:181:17:
Failed to extract DefId: opt_def_kind 11356bd1ee60cec5-ced77525c7774080
stack backtrace:
   0: rust_begin_unwind
             at /rustc/a6f8aa5a092c5e46fcbdafe4c80b4e55ba0de41c/library/std/src/panicking.rs:617:5
   1: core::panicking::panic_fmt
             at /rustc/a6f8aa5a092c5e46fcbdafe4c80b4e55ba0de41c/library/core/src/panicking.rs:67:14
   2: <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::{closure#0}
   3: <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
   4: <rustc_middle::dep_graph::dep_node::DepKind as rustc_query_system::dep_graph::DepKind>::debug_node
   5: core::fmt::rt::Argument::fmt
             at /rustc/a6f8aa5a092c5e46fcbdafe4c80b4e55ba0de41c/library/core/src/fmt/rt.rs:138:9
   6: core::fmt::write
             at /rustc/a6f8aa5a092c5e46fcbdafe4c80b4e55ba0de41c/library/core/src/fmt/mod.rs:1094:21
   7: std::io::Write::write_fmt
             at /rustc/a6f8aa5a092c5e46fcbdafe4c80b4e55ba0de41c/library/std/src/io/mod.rs:1714:15
   8: <&std::io::stdio::Stderr as std::io::Write>::write_fmt
             at /rustc/a6f8aa5a092c5e46fcbdafe4c80b4e55ba0de41c/library/std/src/io/stdio.rs:945:9
   9: <std::io::stdio::Stderr as std::io::Write>::write_fmt
             at /rustc/a6f8aa5a092c5e46fcbdafe4c80b4e55ba0de41c/library/std/src/io/stdio.rs:919:9
  10: std::io::stdio::print_to
             at /rustc/a6f8aa5a092c5e46fcbdafe4c80b4e55ba0de41c/library/std/src/io/stdio.rs:1018:21
  11: std::io::stdio::_eprint
             at /rustc/a6f8aa5a092c5e46fcbdafe4c80b4e55ba0de41c/library/std/src/io/stdio.rs:1106:5
  12: rustc_query_system::dep_graph::graph::print_markframe_trace::<rustc_middle::dep_graph::dep_node::DepKind>
  13: <rustc_query_system::dep_graph::graph::DepGraphData<rustc_middle::dep_graph::dep_node::DepKind>>::try_mark_previous_green::<rustc_query_impl::plumbing::QueryCtxt>
  14: <rustc_query_system::dep_graph::graph::DepGraphData<rustc_middle::dep_graph::dep_node::DepKind>>::try_mark_previous_green::<rustc_query_impl::plumbing::QueryCtxt>
  15: <rustc_query_system::dep_graph::graph::DepGraphData<rustc_middle::dep_graph::dep_node::DepKind>>::try_mark_previous_green::<rustc_query_impl::plumbing::QueryCtxt>
  16: <rustc_query_system::dep_graph::graph::DepGraphData<rustc_middle::dep_graph::dep_node::DepKind>>::try_mark_previous_green::<rustc_query_impl::plumbing::QueryCtxt>
  17: <rustc_query_system::dep_graph::graph::DepGraphData<rustc_middle::dep_graph::dep_node::DepKind>>::try_mark_previous_green::<rustc_query_impl::plumbing::QueryCtxt>
  18: <rustc_query_system::dep_graph::graph::DepGraphData<rustc_middle::dep_graph::dep_node::DepKind>>::try_mark_previous_green::<rustc_query_impl::plumbing::QueryCtxt>
  19: <rustc_query_system::dep_graph::graph::DepGraphData<rustc_middle::dep_graph::dep_node::DepKind>>::try_mark_previous_green::<rustc_query_impl::plumbing::QueryCtxt>
  20: <rustc_query_system::dep_graph::graph::DepGraphData<rustc_middle::dep_graph::dep_node::DepKind>>::try_mark_previous_green::<rustc_query_impl::plumbing::QueryCtxt>
  21: <rustc_query_system::dep_graph::graph::DepGraphData<rustc_middle::dep_graph::dep_node::DepKind>>::try_mark_previous_green::<rustc_query_impl::plumbing::QueryCtxt>
  22: <rustc_query_system::dep_graph::graph::DepGraphData<rustc_middle::dep_graph::dep_node::DepKind>>::try_mark_previous_green::<rustc_query_impl::plumbing::QueryCtxt>
  23: <rustc_query_system::dep_graph::graph::DepGraphData<rustc_middle::dep_graph::dep_node::DepKind>>::try_mark_previous_green::<rustc_query_impl::plumbing::QueryCtxt>
  24: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::DynamicConfig<rustc_query_system::query::caches::DefaultCache<rustc_middle::ty::ParamEnvAnd<(rustc_middle::ty::instance::Instance, &rustc_middle::ty::list::List<rustc_middle::ty::Ty>)>, rustc_middle::query::erase::Erased<[u8; 16]>>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, true>
  25: rustc_codegen_llvm::callee::get_fn
  26: rustc_codegen_ssa::mir::codegen_mir::<rustc_codegen_llvm::builder::Builder>
  27: rustc_codegen_llvm::base::compile_codegen_unit::module_codegen
  28: <rustc_middle::dep_graph::dep_node::DepKind as rustc_query_system::dep_graph::DepKind>::with_deps::<<rustc_query_system::dep_graph::graph::DepGraphData<rustc_middle::dep_graph::dep_node::DepKind>>::with_task<rustc_middle::ty::context::TyCtxt, rustc_span::symbol::Symbol, rustc_codegen_ssa::ModuleCodegen<rustc_codegen_llvm::ModuleLlvm>>::{closure#0}::{closure#0}, rustc_codegen_ssa::ModuleCodegen<rustc_codegen_llvm::ModuleLlvm>>
  29: rustc_codegen_llvm::base::compile_codegen_unit
  30: rustc_codegen_ssa::base::codegen_crate::<rustc_codegen_llvm::LlvmCodegenBackend>
  31: <rustc_codegen_llvm::LlvmCodegenBackend as rustc_codegen_ssa::traits::backend::CodegenBackend>::codegen_crate
  32: <rustc_session::session::Session>::time::<alloc::boxed::Box<dyn core::any::Any>, rustc_interface::passes::start_codegen::{closure#0}>
  33: rustc_interface::passes::start_codegen
  34: <rustc_middle::ty::context::GlobalCtxt>::enter::<<rustc_interface::queries::Queries>::ongoing_codegen::{closure#0}, core::result::Result<alloc::boxed::Box<dyn core::any::Any>, rustc_span::ErrorGuaranteed>>
  35: rustc_span::set_source_map::<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_interface::interface::run_compiler<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_driver_impl::run_compiler::{closure#1}>::{closure#0}::{closure#0}>
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

error: 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: please attach the file at `/home/name/programs/rust/yabo/rustc-ice-2023-08-13T01:26:59.209853937Z-135604.txt` to your bug report

note: compiler flags: --crate-type lib -C embed-bitcode=no -C debuginfo=2 -C linker=clang -C incremental=[REDACTED] -C link-arg=-fuse-ld=/usr/bin/mold

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

query stack during panic:
#0 [fn_abi_of_instance] computing call ABI of `core::ptr::drop_in_place::<salsa::derived::slot::PanicGuard<'_, HirNodeQuery, salsa::derived::AlwaysMemoizeValue>> - shim(Some(salsa::derived::slot::PanicGuard<'_, HirNodeQuery, salsa::derived::AlwaysMemoizeValue>))`
end of query stack

@8051Enthusiast 8051Enthusiast 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 Aug 13, 2023
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Aug 13, 2023
@compiler-errors compiler-errors added the E-needs-mcve Call for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example label Aug 13, 2023
@lukas-code
Copy link
Member

lukas-code commented Aug 13, 2023

Reduced:

#![allow(dead_code)]

trait Query {
    type Value;
}

struct Slot<Q>
where
    Q: Query,
{
    state: std::cell::Cell<QueryState<Q>>,
}

enum QueryState<Q>
where
    Q: Query,
{
    InProgress(Q::Value),
    Memoized(Memo<Q>),
}

struct Memo<Q>
where
    Q: Query,
{
    value: Q::Value,
    inputs: Box<()>,
}

struct HirNodeQuery;

impl Query for HirNodeQuery {
    type Value = HirNode;
}

enum HirNode {
    A,
    #[cfg(a)]
    B(()),
}

fn conjure<T>() -> T {
    todo!()
}

fn main() {
    let _slot = conjure::<Slot<HirNodeQuery>>();
}
rustc src/main.rs --crate-name incr_comp_ice -C incremental=incr --cfg a
rustc src/main.rs --crate-name incr_comp_ice -C incremental=incr --cfg b

@rustbot label -E-needs-mcve +S-has-mcve +A-incr-comp

@rustbot rustbot added A-incr-comp Area: Incremental compilation S-has-mcve Status: A Minimal Complete and Verifiable Example has been found for this issue and removed E-needs-mcve Call for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example labels Aug 13, 2023
@lukas-code
Copy link
Member

searched nightlies: from nightly-2023-05-13 to nightly-2023-08-13
regressed nightly: nightly-2023-05-24
searched commit range: 8b4b208...5ea3f0a
regressed commit: f3d597b -> #111807

bisected with cargo-bisect-rustc v0.6.6

Host triple: x86_64-unknown-linux-gnu
Reproduce with:

cargo bisect-rustc --script script.sh -- build 

script.sh:

#!/bin/sh
rm -rf incr* && rustc src/main.rs --crate-name incr_comp_ice -C incremental=incr --cfg a && rustc src/main.rs --crate-name incr_comp_ice -C incremental=incr --cfg b

@saethlin saethlin removed the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Aug 13, 2023
@chenyukang
Copy link
Member

triggered when calling is_unpin:

Some(PointerKind::MutableRef { unpin: pointee.is_unpin(cx.tcx, cx.param_env()) })

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) ❄️ S-has-mcve Status: A Minimal Complete and Verifiable Example has been found for this issue 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