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

Panic after changing field name on cached builds #96319

Closed
imlazyeye opened this issue Apr 22, 2022 · 4 comments
Closed

Panic after changing field name on cached builds #96319

imlazyeye opened this issue Apr 22, 2022 · 4 comments
Assignees
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

@imlazyeye
Copy link

In the project linked below, changing a specific field to have a different name will ice the compiler. cargo check passes, but cargo run / cargo build will fail.

If you run cargo clean the issue will go away. However, if you then change the field name again, the ice returns. This feels to me like an issue with incremental complication?

Repo: https://github.com/imlazyeye/duck
Branch: rust-ice
Location: In src/parse/gml/stmt.rs, the field tag on Stmt.

Meta

rustc --version --verbose:

❯ rustc --version --verbose
rustc 1.60.0 (7737e0b5c 2022-04-04)
binary: rustc
commit-hash: 7737e0b5c4103216d6fd8cf941b7ab9bdbaace7c
commit-date: 2022-04-04
host: aarch64-apple-darwin
release: 1.60.0
LLVM version: 14.0.0

Error output

thread 'rustc' panicked at 'Failed to extract DefId: local_def_id_to_hir_id bc0d0a5ef7cff5bc-6d59dfaffc699752', compiler/rustc_middle/src/dep_graph/dep_node.rs:270:17
Backtrace

❯ cargo run
   Compiling duck v0.1.0 (/Users/gabe/Documents/repos/duck)
warning: unused import: `duck_bug`
 --> src/solve/solver.rs:3:17
  |
3 |     adt, array, duck_bug, duck_error,
  |                 ^^^^^^^^
  |
  = note: `#[warn(unused_imports)]` on by default

thread 'rustc' panicked at 'Failed to extract DefId: local_def_id_to_hir_id bc0d0a5ef7cff5bc-6d59dfaffc699752', compiler/rustc_middle/src/dep_graph/dep_node.rs:270:17
stack backtrace:
   0:        0x100ee3118 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h10cf06316d33e2a9
   1:        0x100f2f808 - core::fmt::write::h1faf18c959c3a8df
   2:        0x100ed5104 - std::io::Write::write_fmt::h86ab231360bc97d2
   3:        0x100ee6e44 - std::panicking::default_hook::{{closure}}::h36e628ffaf3cd44f
   4:        0x100ee6abc - std::panicking::default_hook::h3ee1564a7544e58f
   5:        0x1082bc5c4 - rustc_driver[3e35567b0507961a]::DEFAULT_HOOK::{closure#0}::{closure#0}
   6:        0x100ee7634 - std::panicking::rust_panic_with_hook::h191339fbd2fe2360
   7:        0x100ee7388 - std::panicking::begin_panic_handler::{{closure}}::h91c230befd9929e3
   8:        0x100ee3600 - std::sys_common::backtrace::__rust_end_short_backtrace::haaaeebb1d37476b3
   9:        0x100ee70c4 - _rust_begin_unwind
  10:        0x100f5d7fc - core::panicking::panic_fmt::h4fe1013b011ef602
  11:        0x10bd2bb5c - <rustc_query_system[91d58cadb6adb151]::dep_graph::dep_node::DepNode<rustc_middle[48a4de8117124789]::dep_graph::dep_node::DepKind> as rustc_middle[48a4de8117124789]::dep_graph::dep_node::DepNodeExt>::extract_def_id::{closure#0}
  12:        0x10bccd070 - <rustc_middle[48a4de8117124789]::ty::context::TyCtxt>::def_path_hash_to_def_id
  13:        0x10bd2bad0 - <rustc_query_system[91d58cadb6adb151]::dep_graph::dep_node::DepNode<rustc_middle[48a4de8117124789]::dep_graph::dep_node::DepKind> as rustc_middle[48a4de8117124789]::dep_graph::dep_node::DepNodeExt>::extract_def_id
  14:        0x10b19d5d8 - rustc_query_impl[9309ed91bf96ef41]::query_callbacks::local_def_id_to_hir_id::force_from_dep_node
  15:        0x10bcb6538 - <rustc_middle[48a4de8117124789]::ty::context::TyCtxt as rustc_query_system[91d58cadb6adb151]::dep_graph::DepContext>::try_force_from_dep_node
  16:        0x10b2bc174 - <rustc_query_system[91d58cadb6adb151]::dep_graph::graph::DepGraph<rustc_middle[48a4de8117124789]::dep_graph::dep_node::DepKind>>::try_mark_previous_green::<rustc_query_impl[9309ed91bf96ef41]::plumbing::QueryCtxt>
  17:        0x10b2bc144 - <rustc_query_system[91d58cadb6adb151]::dep_graph::graph::DepGraph<rustc_middle[48a4de8117124789]::dep_graph::dep_node::DepKind>>::try_mark_previous_green::<rustc_query_impl[9309ed91bf96ef41]::plumbing::QueryCtxt>
  18:        0x10b2bc144 - <rustc_query_system[91d58cadb6adb151]::dep_graph::graph::DepGraph<rustc_middle[48a4de8117124789]::dep_graph::dep_node::DepKind>>::try_mark_previous_green::<rustc_query_impl[9309ed91bf96ef41]::plumbing::QueryCtxt>
  19:        0x10b2bc144 - <rustc_query_system[91d58cadb6adb151]::dep_graph::graph::DepGraph<rustc_middle[48a4de8117124789]::dep_graph::dep_node::DepKind>>::try_mark_previous_green::<rustc_query_impl[9309ed91bf96ef41]::plumbing::QueryCtxt>
  20:        0x10b2bc144 - <rustc_query_system[91d58cadb6adb151]::dep_graph::graph::DepGraph<rustc_middle[48a4de8117124789]::dep_graph::dep_node::DepKind>>::try_mark_previous_green::<rustc_query_impl[9309ed91bf96ef41]::plumbing::QueryCtxt>
  21:        0x10b2bc144 - <rustc_query_system[91d58cadb6adb151]::dep_graph::graph::DepGraph<rustc_middle[48a4de8117124789]::dep_graph::dep_node::DepKind>>::try_mark_previous_green::<rustc_query_impl[9309ed91bf96ef41]::plumbing::QueryCtxt>
  22:        0x10b2bc144 - <rustc_query_system[91d58cadb6adb151]::dep_graph::graph::DepGraph<rustc_middle[48a4de8117124789]::dep_graph::dep_node::DepKind>>::try_mark_previous_green::<rustc_query_impl[9309ed91bf96ef41]::plumbing::QueryCtxt>
  23:        0x10b08c82c - rustc_query_system[91d58cadb6adb151]::query::plumbing::try_load_from_disk_and_cache_in_memory::<rustc_query_impl[9309ed91bf96ef41]::plumbing::QueryCtxt, rustc_middle[48a4de8117124789]::infer::canonical::Canonical<rustc_middle[48a4de8117124789]::ty::ParamEnvAnd<rustc_middle[48a4de8117124789]::ty::Predicate>>, core[e180da0f2c78f25f]::result::Result<rustc_middle[48a4de8117124789]::traits::select::EvaluationResult, rustc_middle[48a4de8117124789]::traits::select::OverflowError>>
  24:        0x10b0f0ab4 - rustc_query_system[91d58cadb6adb151]::query::plumbing::get_query::<rustc_query_impl[9309ed91bf96ef41]::queries::evaluate_obligation, rustc_query_impl[9309ed91bf96ef41]::plumbing::QueryCtxt>
  25:        0x10b158498 - <rustc_query_impl[9309ed91bf96ef41]::Queries as rustc_middle[48a4de8117124789]::ty::query::QueryEngine>::evaluate_obligation
  26:        0x10ba4ca78 - <rustc_infer[85aec4995fa1aeb4]::infer::InferCtxt as rustc_trait_selection[95de940f5ebd95bc]::traits::query::evaluate_obligation::InferCtxtExt>::evaluate_obligation
  27:        0x10ba4cbbc - <rustc_infer[85aec4995fa1aeb4]::infer::InferCtxt as rustc_trait_selection[95de940f5ebd95bc]::traits::query::evaluate_obligation::InferCtxtExt>::evaluate_obligation_no_overflow
  28:        0x10bac1134 - <rustc_trait_selection[95de940f5ebd95bc]::traits::fulfill::FulfillProcessor>::process_trait_obligation
  29:        0x10babcfa4 - <rustc_trait_selection[95de940f5ebd95bc]::traits::fulfill::FulfillProcessor>::progress_changed_obligations
  30:        0x10bad9388 - <rustc_data_structures[6a7bec35f5e261c6]::obligation_forest::ObligationForest<rustc_trait_selection[95de940f5ebd95bc]::traits::fulfill::PendingPredicateObligation>>::process_obligations::<rustc_trait_selection[95de940f5ebd95bc]::traits::fulfill::FulfillProcessor, rustc_data_structures[6a7bec35f5e261c6]::obligation_forest::Outcome<rustc_trait_selection[95de940f5ebd95bc]::traits::fulfill::PendingPredicateObligation, rustc_infer[85aec4995fa1aeb4]::traits::FulfillmentErrorCode>>
  31:        0x10babc8ec - <rustc_trait_selection[95de940f5ebd95bc]::traits::fulfill::FulfillmentContext as rustc_infer[85aec4995fa1aeb4]::traits::engine::TraitEngine>::select_where_possible
  32:        0x10a6d08a0 - <rustc_typeck[761806a90de36c46]::check::fn_ctxt::FnCtxt>::resolve_generator_interiors
  33:        0x10a7d307c - <rustc_infer[85aec4995fa1aeb4]::infer::InferCtxtBuilder>::enter::<&rustc_middle[48a4de8117124789]::ty::context::TypeckResults, <rustc_typeck[761806a90de36c46]::check::inherited::InheritedBuilder>::enter<rustc_typeck[761806a90de36c46]::check::typeck_with_fallback<rustc_typeck[761806a90de36c46]::check::typeck::{closure#0}>::{closure#1}, &rustc_middle[48a4de8117124789]::ty::context::TypeckResults>::{closure#0}>
  34:        0x10a789188 - rustc_typeck[761806a90de36c46]::check::typeck
  35:        0x10b25a320 - <rustc_query_system[91d58cadb6adb151]::dep_graph::graph::DepGraph<rustc_middle[48a4de8117124789]::dep_graph::dep_node::DepKind>>::with_task::<rustc_middle[48a4de8117124789]::ty::context::TyCtxt, rustc_span[dd8cd730fd24a84e]::def_id::LocalDefId, &rustc_middle[48a4de8117124789]::ty::context::TypeckResults>
  36:        0x10b3ad8a0 - rustc_data_structures[6a7bec35f5e261c6]::stack::ensure_sufficient_stack::<(&rustc_middle[48a4de8117124789]::ty::context::TypeckResults, rustc_query_system[91d58cadb6adb151]::dep_graph::graph::DepNodeIndex), rustc_query_system[91d58cadb6adb151]::query::plumbing::execute_job<rustc_query_impl[9309ed91bf96ef41]::plumbing::QueryCtxt, rustc_span[dd8cd730fd24a84e]::def_id::LocalDefId, &rustc_middle[48a4de8117124789]::ty::context::TypeckResults>::{closure#3}>
  37:        0x10b04e6bc - rustc_query_system[91d58cadb6adb151]::query::plumbing::try_execute_query::<rustc_query_impl[9309ed91bf96ef41]::plumbing::QueryCtxt, rustc_query_system[91d58cadb6adb151]::query::caches::DefaultCache<rustc_span[dd8cd730fd24a84e]::def_id::LocalDefId, &rustc_middle[48a4de8117124789]::ty::context::TypeckResults>>
  38:        0x10b13e648 - rustc_query_system[91d58cadb6adb151]::query::plumbing::force_query::<rustc_query_impl[9309ed91bf96ef41]::queries::typeck, rustc_query_impl[9309ed91bf96ef41]::plumbing::QueryCtxt>
  39:        0x10b1a3564 - rustc_query_impl[9309ed91bf96ef41]::query_callbacks::typeck::force_from_dep_node
  40:        0x10bcb6538 - <rustc_middle[48a4de8117124789]::ty::context::TyCtxt as rustc_query_system[91d58cadb6adb151]::dep_graph::DepContext>::try_force_from_dep_node
  41:        0x10b2bc174 - <rustc_query_system[91d58cadb6adb151]::dep_graph::graph::DepGraph<rustc_middle[48a4de8117124789]::dep_graph::dep_node::DepKind>>::try_mark_previous_green::<rustc_query_impl[9309ed91bf96ef41]::plumbing::QueryCtxt>
  42:        0x10b0d3288 - rustc_query_system[91d58cadb6adb151]::query::plumbing::ensure_must_run::<rustc_query_impl[9309ed91bf96ef41]::plumbing::QueryCtxt, rustc_span[dd8cd730fd24a84e]::def_id::LocalDefId, rustc_span[dd8cd730fd24a84e]::def_id::LocalDefId>
  43:        0x10b11c8c8 - rustc_query_system[91d58cadb6adb151]::query::plumbing::get_query::<rustc_query_impl[9309ed91bf96ef41]::queries::typeck, rustc_query_impl[9309ed91bf96ef41]::plumbing::QueryCtxt>
  44:        0x10a81cc58 - <rustc_middle[48a4de8117124789]::hir::map::Map>::par_body_owners::<rustc_typeck[761806a90de36c46]::check::typeck_item_bodies::{closure#0}>
  45:        0x10a78ccf4 - rustc_typeck[761806a90de36c46]::check::typeck_item_bodies
  46:        0x10b28cfec - <rustc_query_system[91d58cadb6adb151]::dep_graph::graph::DepGraph<rustc_middle[48a4de8117124789]::dep_graph::dep_node::DepKind>>::with_task::<rustc_middle[48a4de8117124789]::ty::context::TyCtxt, (), ()>
  47:        0x10b3b2224 - rustc_data_structures[6a7bec35f5e261c6]::stack::ensure_sufficient_stack::<((), rustc_query_system[91d58cadb6adb151]::dep_graph::graph::DepNodeIndex), rustc_query_system[91d58cadb6adb151]::query::plumbing::execute_job<rustc_query_impl[9309ed91bf96ef41]::plumbing::QueryCtxt, (), ()>::{closure#3}>
  48:        0x10b086520 - rustc_query_system[91d58cadb6adb151]::query::plumbing::try_execute_query::<rustc_query_impl[9309ed91bf96ef41]::plumbing::QueryCtxt, rustc_query_system[91d58cadb6adb151]::query::caches::DefaultCache<(), ()>>
  49:        0x10b0f0004 - rustc_query_system[91d58cadb6adb151]::query::plumbing::get_query::<rustc_query_impl[9309ed91bf96ef41]::queries::typeck_item_bodies, rustc_query_impl[9309ed91bf96ef41]::plumbing::QueryCtxt>
  50:        0x10a79d514 - <rustc_session[d383daeae0c11292]::session::Session>::time::<(), rustc_typeck[761806a90de36c46]::check_crate::{closure#7}>
  51:        0x10a77e7e0 - rustc_typeck[761806a90de36c46]::check_crate
  52:        0x1083a2010 - rustc_interface[2280aded15839b11]::passes::analysis
  53:        0x10b283df0 - <rustc_query_system[91d58cadb6adb151]::dep_graph::graph::DepGraph<rustc_middle[48a4de8117124789]::dep_graph::dep_node::DepKind>>::with_task::<rustc_middle[48a4de8117124789]::ty::context::TyCtxt, (), core[e180da0f2c78f25f]::result::Result<(), rustc_errors[677d6d214e1093d1]::ErrorReported>>
  54:        0x10b3a4a34 - rustc_data_structures[6a7bec35f5e261c6]::stack::ensure_sufficient_stack::<(core[e180da0f2c78f25f]::result::Result<(), rustc_errors[677d6d214e1093d1]::ErrorReported>, rustc_query_system[91d58cadb6adb151]::dep_graph::graph::DepNodeIndex), rustc_query_system[91d58cadb6adb151]::query::plumbing::execute_job<rustc_query_impl[9309ed91bf96ef41]::plumbing::QueryCtxt, (), core[e180da0f2c78f25f]::result::Result<(), rustc_errors[677d6d214e1093d1]::ErrorReported>>::{closure#3}>
  55:        0x10b07d464 - rustc_query_system[91d58cadb6adb151]::query::plumbing::try_execute_query::<rustc_query_impl[9309ed91bf96ef41]::plumbing::QueryCtxt, rustc_query_system[91d58cadb6adb151]::query::caches::DefaultCache<(), core[e180da0f2c78f25f]::result::Result<(), rustc_errors[677d6d214e1093d1]::ErrorReported>>>
  56:        0x10b11cdc4 - rustc_query_system[91d58cadb6adb151]::query::plumbing::get_query::<rustc_query_impl[9309ed91bf96ef41]::queries::analysis, rustc_query_impl[9309ed91bf96ef41]::plumbing::QueryCtxt>
  57:        0x1082afd38 - <rustc_interface[2280aded15839b11]::passes::QueryContext>::enter::<rustc_driver[3e35567b0507961a]::run_compiler::{closure#1}::{closure#2}::{closure#3}, core[e180da0f2c78f25f]::result::Result<(), rustc_errors[677d6d214e1093d1]::ErrorReported>>
  58:        0x10826344c - rustc_interface[2280aded15839b11]::interface::create_compiler_and_run::<core[e180da0f2c78f25f]::result::Result<(), rustc_errors[677d6d214e1093d1]::ErrorReported>, rustc_driver[3e35567b0507961a]::run_compiler::{closure#1}>
  59:        0x10824acb0 - std[8541ff70ccfedbb0]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[2280aded15839b11]::util::run_in_thread_pool_with_globals<rustc_interface[2280aded15839b11]::interface::run_compiler<core[e180da0f2c78f25f]::result::Result<(), rustc_errors[677d6d214e1093d1]::ErrorReported>, rustc_driver[3e35567b0507961a]::run_compiler::{closure#1}>::{closure#0}, core[e180da0f2c78f25f]::result::Result<(), rustc_errors[677d6d214e1093d1]::ErrorReported>>::{closure#0}, core[e180da0f2c78f25f]::result::Result<(), rustc_errors[677d6d214e1093d1]::ErrorReported>>
  60:        0x1082c4648 - <<std[8541ff70ccfedbb0]::thread::Builder>::spawn_unchecked_<rustc_interface[2280aded15839b11]::util::run_in_thread_pool_with_globals<rustc_interface[2280aded15839b11]::interface::run_compiler<core[e180da0f2c78f25f]::result::Result<(), rustc_errors[677d6d214e1093d1]::ErrorReported>, rustc_driver[3e35567b0507961a]::run_compiler::{closure#1}>::{closure#0}, core[e180da0f2c78f25f]::result::Result<(), rustc_errors[677d6d214e1093d1]::ErrorReported>>::{closure#0}, core[e180da0f2c78f25f]::result::Result<(), rustc_errors[677d6d214e1093d1]::ErrorReported>>::{closure#1} as core[e180da0f2c78f25f]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  61:        0x100ef2b70 - std::sys::unix::thread::Thread::new::thread_start::h8ccdabc567c5eee0
  62:        0x190e1d4ec - _pthread_from_mach_thread_np

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.60.0 (7737e0b5c 2022-04-04) running on aarch64-apple-darwin

note: compiler flags: --crate-type lib -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 [evaluate_obligation] evaluating trait selection obligation `parse::gml::statements::r#return::Return: core::marker::Send`
#1 [typeck] type-checking `core::driver::start_parse`
#2 [typeck_item_bodies] type-checking all item bodies
#3 [analysis] running analysis passes on this crate
end of query stack
warning: `duck` (lib) generated 1 warning
error: could not compile `duck`; 1 warning emitted

@imlazyeye imlazyeye 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 Apr 22, 2022
@imlazyeye
Copy link
Author

Some additional testing: the issue does occur on nightly (rustc 1.62.0-nightly), but does not occur on rustc 1.59.0.

@lqd
Copy link
Member

lqd commented Apr 22, 2022

In this zulip thread, I've bisected this to nightly-2021-09-19 ( 9dd4ce8...aa8f2d4) which is 1.57.

The reason it does not occur on stable 1.59 is that incremental compilation was disabled for that release. It'll still ICE with RUSTC_FORCE_INCREMENTAL=1 cargo check (but back then the ICE had a different message).

@Aaron1011
Copy link
Member

I've been having some difficulty minimizing this ICE (though I've been able to reproduce it locally). I'd appreciate it someone would be able to take a shot a minimizing this.

@lqd
Copy link
Member

lqd commented May 6, 2022

@Aaron1011

pub struct Stmt {
    pub stmt_type: StmtKind,
    pub stmt_tag: Option<LintTag>,
}
pub struct LintTag;
pub enum StmtKind {
    If(If),
    Block(&'static str),
    Return(Return),
}
pub struct If {
    pub condition: Function,
}
pub struct Return {
    pub value: Function,
}
pub struct Function {
    pub parameters: Box<Stmt>,
}
pub fn start_late_pass(stmt_receiver: Box<Stmt>) {
    spawn(async { stmt_receiver });
}

pub fn spawn<T>(_: T)
where
    T: Send,
{
}

Steps: cargo check, then rename the stmt_tag field, now cargo check will ICE.

@bors bors closed this as completed in 40c6d83 May 7, 2022
Aaron1011 added a commit to Aaron1011/rust that referenced this issue May 7, 2022
compiler-errors added a commit to compiler-errors/rust that referenced this issue May 7, 2022
bors added a commit to rust-lang-ci/rust that referenced this issue May 7, 2022
…piler-errors

Rollup of 8 pull requests

Successful merges:

 - rust-lang#96660 ([bootstrap] Give a better error when trying to run a path with no registered step)
 - rust-lang#96701 (update `jemallocator` example to use 2018 edition import syntax)
 - rust-lang#96746 (Fix an ICE on rust-lang#96738)
 - rust-lang#96758 (bootstrap: bsd platform flags for split debuginfo)
 - rust-lang#96778 (Remove closures on `expect_local` to apply `#[track_caller]`)
 - rust-lang#96781 (Fix an incorrect link in The Unstable Book)
 - rust-lang#96783 (Link to correct issue in issue-95034 known-bug)
 - rust-lang#96801 (Add regression test for rust-lang#96319)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
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

4 participants