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

ICE on stable (1.57) in inremental compilation in hir_module_items. Likely related to issue #84970 #92218

Closed
vcfxb opened this issue Dec 23, 2021 · 9 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

@vcfxb
Copy link
Contributor

vcfxb commented Dec 23, 2021

Code

See rcos/Telescope@5b86ad5. This is hard to minimize because it is unclear to me what is causing this bug.

Meta

rustc --version --verbose:

rustc 1.57.0 (f1edd0429 2021-11-29)
binary: rustc
commit-hash: f1edd0429582dd29cccacaf50fd134b05593bd9c
commit-date: 2021-11-29
host: x86_64-unknown-linux-gnu
release: 1.57.0
LLVM version: 13.0.0

Error output

error: internal compiler error: encountered incremental compilation error with hir_module_items(telescope[5c81]::api::rcos::meetings::edit::edit_meeting)
  |
  = help: This is a known issue with the compiler. Run `cargo clean -p telescope` or `cargo clean` to allow your project to compile
  = note: Please follow the instructions below to create a bug report with the provided information
  = note: See <https://github.com/rust-lang/rust/issues/84970> for more information

thread 'rustc' panicked at 'Found unstable fingerprints for hir_module_items(telescope[5c81]::api::rcos::meetings::edit::edit_meeting): ModuleItems { submodules: [], items: [ItemId { def_id: DefId(0:3779 ~ telescope[5c81]::api::rcos::meetings::edit::edit_meeting::{misc#0}) }, ItemId { def_id: DefId(0:3782 ~ telescope[5c81]::api::rcos::meetings::edit::edit_meeting::OPERATION_NAME) }, ItemId { def_id: DefId(0:3783 ~ telescope[5c81]::api::rcos::meetings::edit::edit_meeting::QUERY) }, ItemId { def_id: DefId(0:3784 ~ telescope[5c81]::api::rcos::meetings::edit::edit_meeting::__QUERY_WORKAROUND) }, ItemId { def_id: DefId(0:3785 ~ telescope[5c81]::api::rcos::meetings::edit::edit_meeting::{misc#3}) }, ItemId { def_id: DefId(0:3786 ~ telescope[5c81]::api::rcos::meetings::edit::edit_meeting::{misc#4}) }, ItemId { def_id: DefId(0:3787 ~ telescope[5c81]::api::rcos::meetings::edit::edit_meeting::{misc#5}) }, ItemId { def_id: DefId(0:3789 ~ telescope[5c81]::api::rcos::meetings::edit::edit_meeting::{misc#7}) }, ItemId { def_id: DefId(0:3790 ~ telescope[5c81]::api::rcos::meetings::edit::edit_meeting::{misc#8}) }, ItemId { def_id: DefId(0:3792 ~ telescope[5c81]::api::rcos::meetings::edit::edit_meeting::{misc#10}) }, ItemId { def_id: DefId(0:3793 ~ telescope[5c81]::api::rcos::meetings::edit::edit_meeting::Boolean) }, ItemId { def_id: DefId(0:3794 ~ telescope[5c81]::api::rcos::meetings::edit::edit_meeting::Float) }, ItemId { def_id: DefId(0:3795 ~ telescope[5c81]::api::rcos::meetings::edit::edit_meeting::Int) }, ItemId { def_id: DefId(0:3796 ~ telescope[5c81]::api::rcos::meetings::edit::edit_meeting::ID) }, ItemId { def_id: DefId(0:3797 ~ telescope[5c81]::api::rcos::meetings::edit::edit_meeting::uuid) }, ItemId { def_id: DefId(0:3798 ~ telescope[5c81]::api::rcos::meetings::edit::edit_meeting::timestamptz) }, ItemId { def_id: DefId(0:3799 ~ telescope[5c81]::api::rcos::meetings::edit::edit_meeting::meeting_type) }, ItemId { def_id: DefId(0:14127 ~ telescope[5c81]::api::rcos::meetings::edit::edit_meeting::Variables) }, ItemId { def_id: DefId(0:14142 ~ telescope[5c81]::api::rcos::meetings::edit::edit_meeting::_#4) }, ItemId { def_id: DefId(0:14143 ~ telescope[5c81]::api::rcos::meetings::edit::edit_meeting::_#4::_serde) }, ItemId { def_id: DefId(0:14144 ~ telescope[5c81]::api::rcos::meetings::edit::edit_meeting::_#4::try) }, ItemId { def_id: DefId(0:14145 ~ telescope[5c81]::api::rcos::meetings::edit::edit_meeting::_#4::{impl#0}) }, ItemId { def_id: DefId(0:3800 ~ telescope[5c81]::api::rcos::meetings::edit::edit_meeting::{impl#0}) }, ItemId { def_id: DefId(0:14073 ~ telescope[5c81]::api::rcos::meetings::edit::edit_meeting::ResponseData) }, ItemId { def_id: DefId(0:14075 ~ telescope[5c81]::api::rcos::meetings::edit::edit_meeting::_#2) }, ItemId { def_id: DefId(0:14076 ~ telescope[5c81]::api::rcos::meetings::edit::edit_meeting::_#2::_serde) }, ItemId { def_id: DefId(0:14077 ~ telescope[5c81]::api::rcos::meetings::edit::edit_meeting::_#2::try) }, ItemId { def_id: DefId(0:14078 ~ telescope[5c81]::api::rcos::meetings::edit::edit_meeting::_#2::{impl#0}) }, ItemId { def_id: DefId(0:14082 ~ telescope[5c81]::api::rcos::meetings::edit::edit_meeting::_#2::{impl#0}::deserialize::__Field) }, ItemId { def_id: DefId(0:14087 ~ telescope[5c81]::api::rcos::meetings::edit::edit_meeting::_#2::{impl#0}::deserialize::__FieldVisitor) }, ItemId { def_id: DefId(0:14089 ~ telescope[5c81]::api::rcos::meetings::edit::edit_meeting::_#2::{impl#0}::deserialize::{impl#0}) }, ItemId { def_id: DefId(0:14099 ~ telescope[5c81]::api::rcos::meetings::edit::edit_meeting::_#2::{impl#0}::deserialize::{impl#1}) }, ItemId { def_id: DefId(0:14103 ~ telescope[5c81]::api::rcos::meetings::edit::edit_meeting::_#2::{impl#0}::deserialize::__Visitor) }, ItemId { def_id: DefId(0:14107 ~ telescope[5c81]::api::rcos::meetings::edit::edit_meeting::_#2::{impl#0}::deserialize::{impl#2}) }, ItemId { def_id: DefId(0:14115 ~ telescope[5c81]::api::rcos::meetings::edit::edit_meeting::_#2::{impl#0}::deserialize::FIELDS) }, ItemId { def_id: DefId(0:14116 ~ telescope[5c81]::api::rcos::meetings::edit::edit_meeting::{impl#4}) }, ItemId { def_id: DefId(0:14118 ~ telescope[5c81]::api::rcos::meetings::edit::edit_meeting::{impl#5}) }, ItemId { def_id: DefId(0:14119 ~ telescope[5c81]::api::rcos::meetings::edit::edit_meeting::{impl#6}) }, ItemId { def_id: DefId(0:14121 ~ telescope[5c81]::api::rcos::meetings::edit::edit_meeting::_#3) }, ItemId { def_id: DefId(0:14122 ~ telescope[5c81]::api::rcos::meetings::edit::edit_meeting::_#3::_serde) }, ItemId { def_id: DefId(0:14123 ~ telescope[5c81]::api::rcos::meetings::edit::edit_meeting::_#3::try) }, ItemId { def_id: DefId(0:14124 ~ telescope[5c81]::api::rcos::meetings::edit::edit_meeting::_#3::{impl#0}) }, ItemId { def_id: DefId(0:14019 ~ telescope[5c81]::api::rcos::meetings::edit::edit_meeting::EditMeetingUpdateMeetingsByPk) }, ItemId { def_id: DefId(0:14021 ~ telescope[5c81]::api::rcos::meetings::edit::edit_meeting::_) }, ItemId { def_id: DefId(0:14022 ~ telescope[5c81]::api::rcos::meetings::edit::edit_meeting::_::_serde) }, ItemId { def_id: DefId(0:14023 ~ telescope[5c81]::api::rcos::meetings::edit::edit_meeting::_::try) }, ItemId { def_id: DefId(0:14024 ~ telescope[5c81]::api::rcos::meetings::edit::edit_meeting::_::{impl#0}) }, ItemId { def_id: DefId(0:14028 ~ telescope[5c81]::api::rcos::meetings::edit::edit_meeting::_::{impl#0}::deserialize::__Field) }, ItemId { def_id: DefId(0:14033 ~ telescope[5c81]::api::rcos::meetings::edit::edit_meeting::_::{impl#0}::deserialize::__FieldVisitor) }, ItemId { def_id: DefId(0:14035 ~ telescope[5c81]::api::rcos::meetings::edit::edit_meeting::_::{impl#0}::deserialize::{impl#0}) }, ItemId { def_id: DefId(0:14045 ~ telescope[5c81]::api::rcos::meetings::edit::edit_meeting::_::{impl#0}::deserialize::{impl#1}) }, ItemId { def_id: DefId(0:14049 ~ telescope[5c81]::api::rcos::meetings::edit::edit_meeting::_::{impl#0}::deserialize::__Visitor) }, ItemId { def_id: DefId(0:14053 ~ telescope[5c81]::api::rcos::meetings::edit::edit_meeting::_::{impl#0}::deserialize::{impl#2}) }, ItemId { def_id: DefId(0:14061 ~ telescope[5c81]::api::rcos::meetings::edit::edit_meeting::_::{impl#0}::deserialize::FIELDS) }, ItemId { def_id: DefId(0:14062 ~ telescope[5c81]::api::rcos::meetings::edit::edit_meeting::{impl#1}) }, ItemId { def_id: DefId(0:14064 ~ telescope[5c81]::api::rcos::meetings::edit::edit_meeting::{impl#2}) }, ItemId { def_id: DefId(0:14065 ~ telescope[5c81]::api::rcos::meetings::edit::edit_meeting::{impl#3}) }, ItemId { def_id: DefId(0:14067 ~ telescope[5c81]::api::rcos::meetings::edit::edit_meeting::_#1) }, ItemId { def_id: DefId(0:14068 ~ telescope[5c81]::api::rcos::meetings::edit::edit_meeting::_#1::_serde) }, ItemId { def_id: DefId(0:14069 ~ telescope[5c81]::api::rcos::meetings::edit::edit_meeting::_#1::try) }, ItemId { def_id: DefId(0:14070 ~ telescope[5c81]::api::rcos::meetings::edit::edit_meeting::_#1::{impl#0}) }], trait_items: [], impl_items: [ImplItemId { def_id: DefId(0:14146 ~ telescope[5c81]::api::rcos::meetings::edit::edit_meeting::_#4::{impl#0}::serialize) }, ImplItemId { def_id: DefId(0:14080 ~ telescope[5c81]::api::rcos::meetings::edit::edit_meeting::_#2::{impl#0}::deserialize) }, ImplItemId { def_id: DefId(0:14091 ~ telescope[5c81]::api::rcos::meetings::edit::edit_meeting::_#2::{impl#0}::deserialize::{impl#0}::Value) }, ImplItemId { def_id: DefId(0:14092 ~ telescope[5c81]::api::rcos::meetings::edit::edit_meeting::_#2::{impl#0}::deserialize::{impl#0}::expecting) }, ImplItemId { def_id: DefId(0:14093 ~ telescope[5c81]::api::rcos::meetings::edit::edit_meeting::_#2::{impl#0}::deserialize::{impl#0}::visit_u64) }, ImplItemId { def_id: DefId(0:14095 ~ telescope[5c81]::api::rcos::meetings::edit::edit_meeting::_#2::{impl#0}::deserialize::{impl#0}::visit_str) }, ImplItemId { def_id: DefId(0:14097 ~ telescope[5c81]::api::rcos::meetings::edit::edit_meeting::_#2::{impl#0}::deserialize::{impl#0}::visit_bytes) }, ImplItemId { def_id: DefId(0:14101 ~ telescope[5c81]::api::rcos::meetings::edit::edit_meeting::_#2::{impl#0}::deserialize::{impl#1}::deserialize) }, ImplItemId { def_id: DefId(0:14109 ~ telescope[5c81]::api::rcos::meetings::edit::edit_meeting::_#2::{impl#0}::deserialize::{impl#2}::Value) }, ImplItemId { def_id: DefId(0:14110 ~ telescope[5c81]::api::rcos::meetings::edit::edit_meeting::_#2::{impl#0}::deserialize::{impl#2}::expecting) }, ImplItemId { def_id: DefId(0:14111 ~ telescope[5c81]::api::rcos::meetings::edit::edit_meeting::_#2::{impl#0}::deserialize::{impl#2}::visit_seq) }, ImplItemId { def_id: DefId(0:14113 ~ telescope[5c81]::api::rcos::meetings::edit::edit_meeting::_#2::{impl#0}::deserialize::{impl#2}::visit_map) }, ImplItemId { def_id: DefId(0:14117 ~ telescope[5c81]::api::rcos::meetings::edit::edit_meeting::{impl#4}::fmt) }, ImplItemId { def_id: DefId(0:14120 ~ telescope[5c81]::api::rcos::meetings::edit::edit_meeting::{impl#6}::clone) }, ImplItemId { def_id: DefId(0:14125 ~ telescope[5c81]::api::rcos::meetings::edit::edit_meeting::_#3::{impl#0}::serialize) }, ImplItemId { def_id: DefId(0:14026 ~ telescope[5c81]::api::rcos::meetings::edit::edit_meeting::_::{impl#0}::deserialize) }, ImplItemId { def_id: DefId(0:14037 ~ telescope[5c81]::api::rcos::meetings::edit::edit_meeting::_::{impl#0}::deserialize::{impl#0}::Value) }, ImplItemId { def_id: DefId(0:14038 ~ telescope[5c81]::api::rcos::meetings::edit::edit_meeting::_::{impl#0}::deserialize::{impl#0}::expecting) }, ImplItemId { def_id: DefId(0:14039 ~ telescope[5c81]::api::rcos::meetings::edit::edit_meeting::_::{impl#0}::deserialize::{impl#0}::visit_u64) }, ImplItemId { def_id: DefId(0:14041 ~ telescope[5c81]::api::rcos::meetings::edit::edit_meeting::_::{impl#0}::deserialize::{impl#0}::visit_str) }, ImplItemId { def_id: DefId(0:14043 ~ telescope[5c81]::api::rcos::meetings::edit::edit_meeting::_::{impl#0}::deserialize::{impl#0}::visit_bytes) }, ImplItemId { def_id: DefId(0:14047 ~ telescope[5c81]::api::rcos::meetings::edit::edit_meeting::_::{impl#0}::deserialize::{impl#1}::deserialize) }, ImplItemId { def_id: DefId(0:14055 ~ telescope[5c81]::api::rcos::meetings::edit::edit_meeting::_::{impl#0}::deserialize::{impl#2}::Value) }, ImplItemId { def_id: DefId(0:14056 ~ telescope[5c81]::api::rcos::meetings::edit::edit_meeting::_::{impl#0}::deserialize::{impl#2}::expecting) }, ImplItemId { def_id: DefId(0:14057 ~ telescope[5c81]::api::rcos::meetings::edit::edit_meeting::_::{impl#0}::deserialize::{impl#2}::visit_seq) }, ImplItemId { def_id: DefId(0:14059 ~ telescope[5c81]::api::rcos::meetings::edit::edit_meeting::_::{impl#0}::deserialize::{impl#2}::visit_map) }, ImplItemId { def_id: DefId(0:14063 ~ telescope[5c81]::api::rcos::meetings::edit::edit_meeting::{impl#1}::fmt) }, ImplItemId { def_id: DefId(0:14066 ~ telescope[5c81]::api::rcos::meetings::edit::edit_meeting::{impl#3}::clone) }, ImplItemId { def_id: DefId(0:14071 ~ telescope[5c81]::api::rcos::meetings::edit::edit_meeting::_#1::{impl#0}::serialize) }], foreign_items: [] }', /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c/compiler/rustc_query_system/src/query/plumbing.rs:615:13
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.

Backtrace

<backtrace>

This issue is likely related to #84970

@vcfxb vcfxb 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 23, 2021
@vcfxb vcfxb changed the title ICE on stable (1.57) in inremental compilation in hir_module_items. Likely related to https://github.com/rust-lang/rust/issues/84970 ICE on stable (1.57) in inremental compilation in hir_module_items. Likely related to #84970 Dec 23, 2021
@vcfxb vcfxb changed the title ICE on stable (1.57) in inremental compilation in hir_module_items. Likely related to #84970 ICE on stable (1.57) in inremental compilation in hir_module_items. Likely related to [#84970](https://github.com/rust-lang/rust/issues/84970) Dec 23, 2021
@vcfxb vcfxb changed the title ICE on stable (1.57) in inremental compilation in hir_module_items. Likely related to [#84970](https://github.com/rust-lang/rust/issues/84970) ICE on stable (1.57) in inremental compilation in hir_module_items. Likely related to issue #84970 Dec 23, 2021
@Aaron1011 Aaron1011 self-assigned this Dec 23, 2021
@Aaron1011
Copy link
Member

@alfriadox Do you know what changes you were making before this ICE occured?

@vcfxb
Copy link
Contributor Author

vcfxb commented Dec 23, 2021

@Aaron1011 I was adding code to an entirely separate module in a different folder. Only other thing that changed was that I updated crate version in cargo and added a dependency.

@vcfxb
Copy link
Contributor Author

vcfxb commented Dec 23, 2021

It it helps, a large amount of the module errorring is generated by a proc macro from the graphql_client crate

@Aaron1011
Copy link
Member

I've managed to reproduce a similar crash in the incremental compilation system, which I think has the same root cause as your issue. I'll be opening a pull request later today.

@vcfxb
Copy link
Contributor Author

vcfxb commented Dec 23, 2021

Oh that's great! Please tag me or reference this issue so that I can stay up to date if this gets fixed :)

Aaron1011 added a commit to Aaron1011/rust that referenced this issue Dec 24, 2021
All other 'containers' (e.g. `impl` blocks) hashed their contents
in the normal, order-dependent way. However, `Mod` was hashing
its contents in a (sort-of) order-independent way. However, the
exact order is exposed to consumers through `Mod.item_ids`,
and through query results like `hir_module_items`. Therefore,
stable hashing needs to take the order of items into account,
to avoid fingerprint ICEs.

Unforuntately, I was unable to directly build a reproducer
for the ICE, due to the behavior of `Fingerprint::combine_commutative`.
This operation swaps the upper and lower `u64` when constructing the
result, which makes the function non-associative. Since we start
the hashing of module items by combining `Fingerprint::ZERO` with
the first item, it's difficult to actually build an example where
changing the order of module items leaves the final hash unchanged.

However, this appears to have been hit in practice in rust-lang#92218
While we're not able to reproduce it, the fact that proc-macros
are involved (which can give an entire module the same span, preventing
any span-related invalidations) makes me confident that the root
cause of that issue is our method of hashing module items.

This PR removes all of the special handling for `Mod`, instead deriving
a `HashStable` implementation. This makes `Mod` consistent with other
'contains' like `Impl`, which hash their contents through the typical
derive of `HashStable`.
@Aaron1011
Copy link
Member

I've opened #92259 which should fix this issue.

@vcfxb
Copy link
Contributor Author

vcfxb commented Dec 24, 2021

Awesome! Looking forward to it's merge

bors added a commit to rust-lang-ci/rust that referenced this issue Jan 4, 2022
…elwoerister

Remove special-cased stable hashing for HIR module

All other 'containers' (e.g. `impl` blocks) hashed their contents
in the normal, order-dependent way. However, `Mod` was hashing
its contents in a (sort-of) order-independent way. However, the
exact order is exposed to consumers through `Mod.item_ids`,
and through query results like `hir_module_items`. Therefore,
stable hashing needs to take the order of items into account,
to avoid fingerprint ICEs.

Unforuntately, I was unable to directly build a reproducer
for the ICE, due to the behavior of `Fingerprint::combine_commutative`.
This operation swaps the upper and lower `u64` when constructing the
result, which makes the function non-associative. Since we start
the hashing of module items by combining `Fingerprint::ZERO` with
the first item, it's difficult to actually build an example where
changing the order of module items leaves the final hash unchanged.

However, this appears to have been hit in practice in rust-lang#92218
While we're not able to reproduce it, the fact that proc-macros
are involved (which can give an entire module the same span, preventing
any span-related invalidations) makes me confident that the root
cause of that issue is our method of hashing module items.

This PR removes all of the special handling for `Mod`, instead deriving
a `HashStable` implementation. This makes `Mod` consistent with other
'contains' like `Impl`, which hash their contents through the typical
derive of `HashStable`.
@pierwill
Copy link
Member

@rustbot label +A-incr-comp

@rustbot rustbot added the A-incr-comp Area: Incremental compilation label Jan 12, 2022
@Enselic
Copy link
Member

Enselic commented Sep 7, 2023

Triage: Since the fix was not reported to not work, let's assume it worked. Feel free to reopen if that is wrong. Closing.

@Enselic Enselic closed this as completed Sep 7, 2023
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

5 participants