Skip to content

Failed to recover key for type_of with hash #79890

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

Closed
hellow554 opened this issue Dec 10, 2020 · 4 comments · Fixed by #79915
Closed

Failed to recover key for type_of with hash #79890

hellow554 opened this issue Dec 10, 2020 · 4 comments · Fixed by #79915
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) ❄️ P-high High priority regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@hellow554
Copy link
Contributor

This seems to be an incremental error‽
We need an external crate for this to work. Haven't managed it to work in an internal mod only :/
Also this only happens with cargo test. Haven't managed to get it running with cargo check sadly

Code

extern crate (let's call it f)

pub trait F {}

code

use f::F

Then just remove and add f::F afterwards again (or the other way round, it doesn't matter).

This script does it for you:

#! /bin/bash

cargo clean

echo '' > src/main.rs
cargo test
echo 'use f::F;' > src/main.rs
cargo test
echo '' > src/main.rs
cargo test

Meta

rustc --version --verbose:

rustc 1.50.0-nightly (f0f68778f 2020-12-09)
binary: rustc
commit-hash: f0f68778f798d6d34649745b41770829b17ba5b8
commit-date: 2020-12-09
host: x86_64-unknown-linux-gnu
release: 1.50.0-nightly
Backtrace

thread 'rustc' panicked at 'Failed to recover key for type_of(3739ed735b1bc82c-29bc8a543e26e1e2) with hash 3739ed735b1bc82c-29bc8a543e26e1e2', compiler/rustc_middle/src/ty/query/mod.rs:235:5
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.50.0-nightly (f0f68778f 2020-12-09) running on x86_64-unknown-linux-gnu

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

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

query stack during panic:
end of query stack
thread '<unnamed>' panicked at 'assertion failed: `(left == right)`
  left: `LLVMing`,
 right: `Codegenning`', /rustc/f0f68778f798d6d34649745b41770829b17ba5b8/compiler/rustc_codegen_ssa/src/back/write.rs:1425:21

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.50.0-nightly (f0f68778f 2020-12-09) running on x86_64-unknown-linux-gnu

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

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

query stack during panic:
end of query stack
error: could not compile `day10`

and with RUST_BACKTRACE=full the LLVMing assert vanishes

thread 'rustc' panicked at 'Failed to recover key for type_of(3739ed735b1bc82c-29bc8a543e26e1e2) with hash 3739ed735b1bc82c-29bc8a543e26e1e2', compiler/rustc_middle/src/ty/query/mod.rs:235:5
stack backtrace:
   0:     0x7f20c54546b7 - std::backtrace_rs::backtrace::libunwind::trace::h746c3e9529d524bc
                               at /rustc/f0f68778f798d6d34649745b41770829b17ba5b8/library/std/src/../../backtrace/src/backtrace/libunwind.rs:90:5
   1:     0x7f20c54546b7 - std::backtrace_rs::backtrace::trace_unsynchronized::h86340908ff889faa
                               at /rustc/f0f68778f798d6d34649745b41770829b17ba5b8/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7f20c54546b7 - std::sys_common::backtrace::_print_fmt::h43f85f9b18230404
                               at /rustc/f0f68778f798d6d34649745b41770829b17ba5b8/library/std/src/sys_common/backtrace.rs:67:5
   3:     0x7f20c54546b7 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::hc132ae1a5b5aa7cd
                               at /rustc/f0f68778f798d6d34649745b41770829b17ba5b8/library/std/src/sys_common/backtrace.rs:46:22
   4:     0x7f20c54c852c - core::fmt::write::hdf023a0036d2a25f
                               at /rustc/f0f68778f798d6d34649745b41770829b17ba5b8/library/core/src/fmt/mod.rs:1078:17
   5:     0x7f20c54466a2 - std::io::Write::write_fmt::h8580846154bcb66a
                               at /rustc/f0f68778f798d6d34649745b41770829b17ba5b8/library/std/src/io/mod.rs:1519:15
   6:     0x7f20c54583b5 - std::sys_common::backtrace::_print::h7ee55fed88d107a3
                               at /rustc/f0f68778f798d6d34649745b41770829b17ba5b8/library/std/src/sys_common/backtrace.rs:49:5
   7:     0x7f20c54583b5 - std::sys_common::backtrace::print::h54a7d3e52a524177
                               at /rustc/f0f68778f798d6d34649745b41770829b17ba5b8/library/std/src/sys_common/backtrace.rs:36:9
   8:     0x7f20c54583b5 - std::panicking::default_hook::{{closure}}::h60921e857bf55a40
                               at /rustc/f0f68778f798d6d34649745b41770829b17ba5b8/library/std/src/panicking.rs:208:50
   9:     0x7f20c5457f0a - std::panicking::default_hook::hf0f9afb1017317fc
                               at /rustc/f0f68778f798d6d34649745b41770829b17ba5b8/library/std/src/panicking.rs:225:9
  10:     0x7f20c5d103d8 - rustc_driver::report_ice::hff78d76a39ffbb86
  11:     0x7f20c5458cb6 - std::panicking::rust_panic_with_hook::h8d66bf42b407aaea
                               at /rustc/f0f68778f798d6d34649745b41770829b17ba5b8/library/std/src/panicking.rs:595:17
  12:     0x7f20c54587d7 - std::panicking::begin_panic_handler::{{closure}}::hde71edcd925d0c5e
                               at /rustc/f0f68778f798d6d34649745b41770829b17ba5b8/library/std/src/panicking.rs:497:13
  13:     0x7f20c5454b7c - std::sys_common::backtrace::__rust_end_short_backtrace::h8a3c7d6cea578919
                               at /rustc/f0f68778f798d6d34649745b41770829b17ba5b8/library/std/src/sys_common/backtrace.rs:141:18
  14:     0x7f20c5458739 - rust_begin_unwind
                               at /rustc/f0f68778f798d6d34649745b41770829b17ba5b8/library/std/src/panicking.rs:493:5
  15:     0x7f20c54586eb - std::panicking::begin_panic_fmt::hee67ce14b77d0396
                               at /rustc/f0f68778f798d6d34649745b41770829b17ba5b8/library/std/src/panicking.rs:435:5
  16:     0x7f20c86f3400 - rustc_middle::ty::query::try_load_from_on_disk_cache::{{closure}}::h0702bbc1f260c0e9
  17:     0x7f20c86f337b - rustc_middle::ty::query::try_load_from_on_disk_cache::hfa4775df5c5e0180
  18:     0x7f20c79cf1ce - rustc_query_system::dep_graph::graph::DepGraph<K>::exec_cache_promotions::h8caa69177622351e
  19:     0x7f20c79e7aa1 - rustc_middle::dep_graph::<impl rustc_query_system::dep_graph::DepKind for rustc_middle::dep_graph::dep_node::DepKind>::with_deps::hab5675af7737b3e6
  20:     0x7f20c798a84b - rustc_incremental::persist::save::save_in::h7f4f43356280dc0a
  21:     0x7f20c7985c21 - rustc_data_structures::sync::join::h0120008f852881ce
  22:     0x7f20c79e6b42 - rustc_middle::dep_graph::<impl rustc_query_system::dep_graph::DepKind for rustc_middle::dep_graph::dep_node::DepKind>::with_deps::h2893ce60eec57bb6
  23:     0x7f20c7989d7f - rustc_incremental::persist::save::save_dep_graph::hffd3fb2ecc639a78
  24:     0x7f20c786653a - rustc_codegen_ssa::base::finalize_tcx::h68106e2729498b3e
  25:     0x7f20c617ee97 - <rustc_codegen_llvm::LlvmCodegenBackend as rustc_codegen_ssa::traits::backend::CodegenBackend>::codegen_crate::h067fffb3870bc5b0
  26:     0x7f20c5f2e03e - rustc_session::utils::<impl rustc_session::session::Session>::time::had158f21ec5bf4d1
  27:     0x7f20c5f7052c - rustc_interface::passes::QueryContext::enter::h40067ad7feabcbd0
  28:     0x7f20c5fc87b3 - rustc_interface::queries::Queries::ongoing_codegen::h4fc36fc05972247d
  29:     0x7f20c5cb89e9 - rustc_interface::queries::<impl rustc_interface::interface::Compiler>::enter::hd899306a06575d0c
  30:     0x7f20c5d39797 - rustc_span::with_source_map::ha4e07ff263d0dc1d
  31:     0x7f20c5cb9b9b - rustc_interface::interface::create_compiler_and_run::h1d6d732867d1f489
  32:     0x7f20c5d66be0 - scoped_tls::ScopedKey<T>::set::h39c0aa543118d3f3
  33:     0x7f20c5d6d1e6 - std::sys_common::backtrace::__rust_begin_short_backtrace::h1e5aa72fb9cd6d86
  34:     0x7f20c5cc1a5a - core::ops::function::FnOnce::call_once{{vtable.shim}}::hc793837e985b77ce
  35:     0x7f20c546866a - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hea1090dbdcecbf5a
                               at /rustc/f0f68778f798d6d34649745b41770829b17ba5b8/library/alloc/src/boxed.rs:1328:9
  36:     0x7f20c546866a - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h8d5723d3912bd325
                               at /rustc/f0f68778f798d6d34649745b41770829b17ba5b8/library/alloc/src/boxed.rs:1328:9
  37:     0x7f20c546866a - std::sys::unix::thread::Thread::new::thread_start::hc17a425ca2995724
                               at /rustc/f0f68778f798d6d34649745b41770829b17ba5b8/library/std/src/sys/unix/thread.rs:71:17
  38:     0x7f20c5394609 - start_thread
  39:     0x7f20c52a8293 - clone
  40:                0x0 - <unknown>

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.50.0-nightly (f0f68778f 2020-12-09) running on x86_64-unknown-linux-gnu

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

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

query stack during panic:
end of query stack
error: could not compile `day10`

@hellow554 hellow554 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 Dec 10, 2020
@hellow554 hellow554 changed the title Failed to recover key for type_of Failed to recover key for type_of with hash Dec 10, 2020
@hellow554
Copy link
Contributor Author

searched nightlies: from nightly-2020-12-08 to nightly-2020-12-10
regressed nightly: nightly-2020-12-10
searched commits: from 1700ca0 to f0f6877
regressed commit: fa55f66

bisected with cargo-bisect-rustc v0.6.0

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

cargo bisect-rustc ./test.sh --end 2020-12-10

cc #79721 @Aaron1011

@jonas-schievink jonas-schievink added the A-incr-comp Area: Incremental compilation label Dec 10, 2020
@jyn514 jyn514 added the regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. label Dec 10, 2020
@rustbot rustbot added the I-prioritize Issue: Indicates that prioritization has been requested for this issue. label Dec 10, 2020
@apiraino
Copy link
Contributor

Assigning P-high as discussed as part of the Prioritization Working Group procedure and removing I-prioritize.

@apiraino apiraino added P-high High priority and removed I-prioritize Issue: Indicates that prioritization has been requested for this issue. labels Dec 10, 2020
@Aaron1011 Aaron1011 self-assigned this Dec 10, 2020
@Aaron1011
Copy link
Member

I've fixed the issue locally, and I'm working on a PR.

@Aaron1011
Copy link
Member

Opened #79915

Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this issue Dec 10, 2020
…sh, r=petrochenkov

Use `def_path_hash_to_def_id` when re-using a `RawDefId`

Fixes rust-lang#79890

Previously, we just copied a `RawDefId` from the 'old' map to the 'new'
map. However, the `RawDefId` for a given `DefPathHash` may be different
in the current compilation session. Using `def_path_hash_to_def_id`
ensures that the `RawDefId` we use is valid in the current session.
bors added a commit to rust-lang-ci/rust that referenced this issue Dec 11, 2020
…, r=petrochenkov

Use `def_path_hash_to_def_id` when re-using a `RawDefId`

Fixes rust-lang#79890

Previously, we just copied a `RawDefId` from the 'old' map to the 'new'
map. However, the `RawDefId` for a given `DefPathHash` may be different
in the current compilation session. Using `def_path_hash_to_def_id`
ensures that the `RawDefId` we use is valid in the current session.
@bors bors closed this as completed in 3918b82 Dec 11, 2020
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) ❄️ P-high High priority regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. 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.

6 participants