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

error: the compiler unexpectedly panicked. this is a bug. #132920

Closed
malezjaa opened this issue Nov 11, 2024 · 7 comments · Fixed by #133304
Closed

error: the compiler unexpectedly panicked. this is a bug. #132920

malezjaa opened this issue Nov 11, 2024 · 7 comments · Fixed by #133304
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-trait-system Area: Trait system 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. 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

@malezjaa
Copy link

Code

The reproduction is a simple game in bevy: https://github.com/malezjaa/game

Meta

rustc --version --verbose:

rustc 1.84.0-nightly (143ce0920 2024-11-10)
binary: rustc
commit-hash: 143ce0920a2307b19831160a01f06f107610f1b2
commit-date: 2024-11-10
host: x86_64-pc-windows-msvc
release: 1.84.0-nightly
LLVM version: 19.1.3

Error output

thread 'rustc' panicked at compiler\rustc_trait_selection\src\error_reporting\traits\fulfillment_errors.rs:1820:44:
called `Option::unwrap()` on a `None` value
stack backtrace:
   0:     0x7ffba405c7f1 - std::backtrace_rs::backtrace::dbghelp64::trace
                               at /rustc/143ce0920a2307b19831160a01f06f107610f1b2\library/std\src\..\..\backtrace\src\backtrace\dbghelp64.rs:91
   1:     0x7ffba405c7f1 - std::backtrace_rs::backtrace::trace_unsynchronized
                               at /rustc/143ce0920a2307b19831160a01f06f107610f1b2\library/std\src\..\..\backtrace\src\backtrace\mod.rs:66
   2:     0x7ffba405c7f1 - std::sys::backtrace::_print_fmt
                               at /rustc/143ce0920a2307b19831160a01f06f107610f1b2\library/std\src\sys\backtrace.rs:66
   3:     0x7ffba405c7f1 - std::sys::backtrace::impl$0::print::impl$0::fmt
                               at /rustc/143ce0920a2307b19831160a01f06f107610f1b2\library/std\src\sys\backtrace.rs:39
   4:     0x7ffba408e51a - core::fmt::rt::Argument::fmt
                               at /rustc/143ce0920a2307b19831160a01f06f107610f1b2\library/core\src\fmt\rt.rs:177
   5:     0x7ffba408e51a - core::fmt::write
                               at /rustc/143ce0920a2307b19831160a01f06f107610f1b2\library/core\src\fmt\mod.rs:1189
   6:     0x7ffba40529a7 - std::io::Write::write_fmt<std::sys::pal::windows::stdio::Stderr>
                               at /rustc/143ce0920a2307b19831160a01f06f107610f1b2\library/std\src\io\mod.rs:1839
   7:     0x7ffba405c635 - std::sys::backtrace::BacktraceLock::print
                               at /rustc/143ce0920a2307b19831160a01f06f107610f1b2\library/std\src\sys\backtrace.rs:42
   8:     0x7ffba405f523 - std::panicking::default_hook::closure$1
                               at /rustc/143ce0920a2307b19831160a01f06f107610f1b2\library/std\src\panicking.rs:268
   9:     0x7ffba405f302 - std::panicking::default_hook
                               at /rustc/143ce0920a2307b19831160a01f06f107610f1b2\library/std\src\panicking.rs:295
  10:     0x7ffba5687737 - memchr
  11:     0x7ffba405fc62 - alloc::boxed::impl$30::call
                               at /rustc/143ce0920a2307b19831160a01f06f107610f1b2\library/alloc\src\boxed.rs:1981
  12:     0x7ffba405fc62 - std::panicking::rust_panic_with_hook
                               at /rustc/143ce0920a2307b19831160a01f06f107610f1b2\library/std\src\panicking.rs:809
  13:     0x7ffba405fa72 - std::panicking::begin_panic_handler::closure$0
                               at /rustc/143ce0920a2307b19831160a01f06f107610f1b2\library/std\src\panicking.rs:667
  14:     0x7ffba405d2af - std::sys::backtrace::__rust_end_short_backtrace<std::panicking::begin_panic_handler::closure_env$0,never$>
                               at /rustc/143ce0920a2307b19831160a01f06f107610f1b2\library/std\src\sys\backtrace.rs:170
  15:     0x7ffba405f6ae - std::panicking::begin_panic_handler
                               at /rustc/143ce0920a2307b19831160a01f06f107610f1b2\library/std\src\panicking.rs:665
  16:     0x7ffba7093af1 - core::panicking::panic_fmt
                               at /rustc/143ce0920a2307b19831160a01f06f107610f1b2\library/core\src\panicking.rs:76
  17:     0x7ffba7093bad - core::panicking::panic
                               at /rustc/143ce0920a2307b19831160a01f06f107610f1b2\library/core\src\panicking.rs:148
  18:     0x7ffba7093a6e - core::option::unwrap_failed
                               at /rustc/143ce0920a2307b19831160a01f06f107610f1b2\library/core\src\option.rs:2008
  19:     0x7ffba68fcc04 - <rustc_trait_selection[3dbf94cb46f90712]::error_reporting::TypeErrCtxt>::fuzzy_match_tys
  20:     0x7ffba6989ecd - <rustc_trait_selection[3dbf94cb46f90712]::error_reporting::traits::on_unimplemented::WrappedParserError as rustc_errors[9c488d6ae8e44ce4]::diagnostic::LintDiagnostic<()>>::decorate_lint
  21:     0x7ffba694d182 - <rustc_trait_selection[3dbf94cb46f90712]::error_reporting::TypeErrCtxt>::report_fulfillment_errors
  22:     0x7ffba42cb973 - rustc_hir_typeck[a5ddaf2af851908c]::typeck
  23:     0x7ffba4e1accb - rustc_query_impl[1314cfb4603ed7b]::plumbing::query_key_hash_verify_all
  24:     0x7ffba4d66d0a - rustc_ty_utils[c2708c13bfdf2f5f]::ty::self_ty_of_trait_impl_enabling_order_dep_trait_object_hack
  25:     0x7ffba4e23264 - rustc_query_impl[1314cfb4603ed7b]::plumbing::query_key_hash_verify_all
  26:     0x7ffba4340272 - <rustc_hir_typeck[a5ddaf2af851908c]::upvar::InferBorrowKind as rustc_hir_typeck[a5ddaf2af851908c]::expr_use_visitor::Delegate>::borrow
  27:     0x7ffba43bb399 - rustc_hir_analysis[4b8241ff32ff1736]::check_crate
  28:     0x7ffba40d1991 - rustc_interface[a39b52d048a80b08]::passes::resolver_for_lowering_raw
  29:     0x7ffba10a480e - rustc_interface[a39b52d048a80b08]::passes::analysis
  30:     0x7ffba3c53f5b - rustc_ty_utils[c2708c13bfdf2f5f]::ty::adt_sized_constraint
  31:     0x7ffba3b6bcd7 - rustc_ty_utils[c2708c13bfdf2f5f]::ty::adt_sized_constraint
  32:     0x7ffba3c59893 - rustc_query_impl[1314cfb4603ed7b]::query_system
  33:     0x7ffba10634c7 - _rust_alloc_error_handler
  34:     0x7ffba105f19f - _rust_alloc_error_handler
  35:     0x7ffba10690a7 - _rust_alloc_error_handler
  36:     0x7ffba407173d - alloc::boxed::impl$28::call_once
                               at /rustc/143ce0920a2307b19831160a01f06f107610f1b2\library/alloc\src\boxed.rs:1967
  37:     0x7ffba407173d - alloc::boxed::impl$28::call_once
                               at /rustc/143ce0920a2307b19831160a01f06f107610f1b2\library/alloc\src\boxed.rs:1967
  38:     0x7ffba407173d - std::sys::pal::windows::thread::impl$0::new::thread_start
                               at /rustc/143ce0920a2307b19831160a01f06f107610f1b2\library/std\src\sys\pal\windows\thread.rs:55
  39:     0x7ffcafe5257d - BaseThreadInitThunk
  40:     0x7ffcb176af08 - RtlUserThreadStart

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 make sure that you have updated to the latest nightly

note: please attach the file at `C:\dev\chronos-game\rustc-ice-2024-11-11T21_20_32-29384.txt` to your bug report

note: compiler flags: --crate-type bin -C opt-level=1 -C embed-bitcode=no -C debuginfo=2 -C debug-assertions=on -C incremental=[REDACTED]

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

query stack during panic:
#0 [typeck] type-checking `cursor::setup_cursor`
#1 [analysis] running analysis passes on this crate
end of query stack
warning: `chronos-game` (bin "chronos-game") generated 6 warnings (run `cargo fix --bin "chronos-game"` to apply 6 suggestions)
error: could not compile `chronos-game` (bin "chronos-game"); 6 warnings emitted

Caused by:
  process didn't exit successfully: `C:\Users\PC\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\bin\rustc.exe --crate-name chronos_game --edition=2021 src\main.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --diagnostic-width=119 --crate-type bin --emit=dep-info,link -C opt-level=1 -C embed-bitcode=no -C debuginfo=2 -C debug-assertions=on --check-cfg cfg(docsrs) --check-cfg "cfg(feature, values())" -C metadata=fa87857d082ffa4c --out-dir C:\dev\chronos-game\target\debug\deps -C incremental=C:\dev\chronos-game\target\debug\incremental -L dependency=C:\dev\chronos-game\target\debug\deps --extern bevy=C:\dev\chronos-game\target\debug\deps\libbevy-129f64a0b607358e.rlib --extern bevy_rapier2d=C:\dev\chronos-game\target\debug\deps\libbevy_rapier2d-8cf2e77811aeb84a.rlib -L native=C:\Users\PC\.cargo\registry\src\index.crates.io-6f17d22bba15001f\windows_x86_64_msvc-0.52.6\lib -L "native=C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.40.33807\atlmfc\lib\x64" -L native=C:\dev\chronos-game\target\debug\build\blake3-c1b15bbd03f1ca9d\out -L "native=C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.40.33807\atlmfc\lib\x64" -L native=C:\dev\chronos-game\target\debug\build\blake3-c1b15bbd03f1ca9d\out` (exit code: 101)

rustc-ice-2024-11-11T21_25_06-29784.txt

@malezjaa malezjaa 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 11, 2024
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Nov 11, 2024
@compiler-errors
Copy link
Member

An unwrap added in #128849 cc @estebank

@fmease fmease added E-needs-mcve Call for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example A-diagnostics Area: Messages for errors, warnings, and lints A-trait-system Area: Trait system and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Nov 12, 2024
@cyrgani
Copy link
Contributor

cyrgani commented Nov 12, 2024

The linked reproduction repo appears to no longer exist.

@malezjaa
Copy link
Author

malezjaa commented Nov 12, 2024

I'm sorry. I changed the visibility because I thought you had already found the issue. I had already modified the code to not cause a compiler error.

@malezjaa
Copy link
Author

malezjaa commented Nov 12, 2024

Made it public again. malezjaa/game@7fa40a6 this commit contains old code in src/cursor.rs

@cyrgani
Copy link
Contributor

cyrgani commented Nov 12, 2024

Thanks for making it public again.
Here is a reduced example of the ICE: https://github.com/cyrgani/rustc-ice-version-conflict
The issue why the compiler panics is that rapier depends on bevy 0.14, but the game crate depends on bevy 0.15. When importing a type from rapier in game, the ICE occurs.

@rustbot label: +S-has-mcve -E-needs-mcve +regression-from-stable-to-nightly

@rustbot rustbot added S-has-mcve Status: A Minimal Complete and Verifiable Example has been found for this issue regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. I-prioritize Issue: Indicates that prioritization has been requested 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 Nov 12, 2024
@apiraino
Copy link
Contributor

WG-prioritization assigning priority (Zulip discussion).

@rustbot label -I-prioritize +P-high

@rustbot rustbot added P-high High priority and removed I-prioritize Issue: Indicates that prioritization has been requested for this issue. labels Nov 14, 2024
@apiraino
Copy link
Contributor

cc @estebank in case the ping for this issue went under the radar

jhpratt added a commit to jhpratt/rust that referenced this issue Nov 26, 2024
Revert diagnostics hack to fix ICE 132920

This reverts 8a568d9 from rust-lang#128849 to fix the diagnostics ICE in rust-lang#132920.

The hack mentioned in that commit was supposed to be tailored to E277, but that codepath is used actually shared with other errors, e.g. at least the E283 from the linked issue.

We may have to eat the slightly worse diagnostics until a non-hacky way to make this error less verbose is implemented (or I guess a different hack specializing even more to E277's structure).

Sorry `@estebank` 🙏. I can close this if you'd prefer to fix it in a different way.

Since it seems unexpected that rust-lang#128849 would impact the repro, here's how the error used to look before that PR.

```console
warning: unused import: `minirapier::Ray`
 --> src/main.rs:2:5
  |
2 | use minirapier::Ray;
  |     ^^^^^^^^^^^^^^^
  |
  = note: `#[warn(unused_imports)]` on by default

error[E0283]: type annotations needed
  --> src/main.rs:10:5
   |
10 |     insert_resource(Res.into());
   |     ^^^^^^^^^^^^^^^ ---------- type must be known at this point
   |     |
   |     cannot infer type of the type parameter `R` declared on the function `insert_resource`
   |
   = note: cannot satisfy `_: Resource`
   = help: the trait `Resource` is implemented for `Res`
note: required by a bound in `insert_resource`
  --> src/main.rs:4:23
   |
4  | fn insert_resource<R: Resource>(_resource: R) {}
   |                       ^^^^^^^^ required by this bound in `insert_resource`
help: consider specifying the generic argument
   |
10 |     insert_resource::<R>(Res.into());
   |                    +++++
help: consider removing this method call, as the receiver has type `Res` and `Res: Resource` trivially holds
   |
10 -     insert_resource(Res.into());
10 +     insert_resource(Res);
```

And how it looks now without the ICE.

```console
warning: unused import: `minirapier::Ray`
 --> src/main.rs:2:5
  |
2 | use minirapier::Ray;
  |     ^^^^^^^^^^^^^^^
  |
  = note: `#[warn(unused_imports)]` on by default

error[E0283]: type annotations needed
  --> src/main.rs:10:5
   |
10 |     insert_resource(Res.into());
   |     ^^^^^^^^^^^^^^^ ---------- type must be known at this point
   |     |
   |     cannot infer type of the type parameter `R` declared on the function `insert_resource`
   |
   = note: cannot satisfy `_: Resource`
note: there are multiple different versions of crate `minibevy` in the dependency graph
  --> /home/lqd/rust/tmp/minimization/issue-132920/rustc-ice-version-conflict/minibevy_b/src/lib.rs:1:1
   |
1  | pub trait Resource {}
   | ^^^^^^^^^^^^^^^^^^ this is the required trait
   |
  ::: src/main.rs:1:5
   |
1  | use minibevy::Resource;
   |     -------- one version of crate `minibevy` is used here, as a direct dependency of the current crate
2  | use minirapier::Ray;
   |     ---------- one version of crate `minibevy` is used here, as a dependency of crate `minirapier`
   |
  ::: /home/lqd/rust/tmp/minimization/issue-132920/rustc-ice-version-conflict/minibevy_a/src/lib.rs:1:1
   |
1  | pub trait Resource {}
   | ------------------ this is the found trait
   = help: you can use `cargo tree` to explore your dependency tree
note: required by a bound in `insert_resource`
  --> src/main.rs:4:23
   |
4  | fn insert_resource<R: Resource>(_resource: R) {}
   |                       ^^^^^^^^ required by this bound in `insert_resource`
help: consider specifying the generic argument
   |
10 |     insert_resource::<R>(Res.into());
   |                    +++++
help: consider removing this method call, as the receiver has type `Res` and `Res: Resource` trivially holds
   |
10 -     insert_resource(Res.into());
10 +     insert_resource(Res);
   |
```

The improvements from rust-lang#128849 are still present and the note about the trait coming from the 2 versions of bevy is more explanatory/helpful than before, albeit a bit verbosely.

Fixes rust-lang#132920.
@bors bors closed this as completed in f101562 Nov 27, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Nov 27, 2024
Rollup merge of rust-lang#133304 - lqd:issue-132920, r=estebank

Revert diagnostics hack to fix ICE 132920

This reverts 8a568d9 from rust-lang#128849 to fix the diagnostics ICE in rust-lang#132920.

The hack mentioned in that commit was supposed to be tailored to E277, but that codepath is used actually shared with other errors, e.g. at least the E283 from the linked issue.

We may have to eat the slightly worse diagnostics until a non-hacky way to make this error less verbose is implemented (or I guess a different hack specializing even more to E277's structure).

Sorry ``@estebank`` 🙏. I can close this if you'd prefer to fix it in a different way.

Since it seems unexpected that rust-lang#128849 would impact the repro, here's how the error used to look before that PR.

```console
warning: unused import: `minirapier::Ray`
 --> src/main.rs:2:5
  |
2 | use minirapier::Ray;
  |     ^^^^^^^^^^^^^^^
  |
  = note: `#[warn(unused_imports)]` on by default

error[E0283]: type annotations needed
  --> src/main.rs:10:5
   |
10 |     insert_resource(Res.into());
   |     ^^^^^^^^^^^^^^^ ---------- type must be known at this point
   |     |
   |     cannot infer type of the type parameter `R` declared on the function `insert_resource`
   |
   = note: cannot satisfy `_: Resource`
   = help: the trait `Resource` is implemented for `Res`
note: required by a bound in `insert_resource`
  --> src/main.rs:4:23
   |
4  | fn insert_resource<R: Resource>(_resource: R) {}
   |                       ^^^^^^^^ required by this bound in `insert_resource`
help: consider specifying the generic argument
   |
10 |     insert_resource::<R>(Res.into());
   |                    +++++
help: consider removing this method call, as the receiver has type `Res` and `Res: Resource` trivially holds
   |
10 -     insert_resource(Res.into());
10 +     insert_resource(Res);
```

And how it looks now without the ICE.

```console
warning: unused import: `minirapier::Ray`
 --> src/main.rs:2:5
  |
2 | use minirapier::Ray;
  |     ^^^^^^^^^^^^^^^
  |
  = note: `#[warn(unused_imports)]` on by default

error[E0283]: type annotations needed
  --> src/main.rs:10:5
   |
10 |     insert_resource(Res.into());
   |     ^^^^^^^^^^^^^^^ ---------- type must be known at this point
   |     |
   |     cannot infer type of the type parameter `R` declared on the function `insert_resource`
   |
   = note: cannot satisfy `_: Resource`
note: there are multiple different versions of crate `minibevy` in the dependency graph
  --> /home/lqd/rust/tmp/minimization/issue-132920/rustc-ice-version-conflict/minibevy_b/src/lib.rs:1:1
   |
1  | pub trait Resource {}
   | ^^^^^^^^^^^^^^^^^^ this is the required trait
   |
  ::: src/main.rs:1:5
   |
1  | use minibevy::Resource;
   |     -------- one version of crate `minibevy` is used here, as a direct dependency of the current crate
2  | use minirapier::Ray;
   |     ---------- one version of crate `minibevy` is used here, as a dependency of crate `minirapier`
   |
  ::: /home/lqd/rust/tmp/minimization/issue-132920/rustc-ice-version-conflict/minibevy_a/src/lib.rs:1:1
   |
1  | pub trait Resource {}
   | ------------------ this is the found trait
   = help: you can use `cargo tree` to explore your dependency tree
note: required by a bound in `insert_resource`
  --> src/main.rs:4:23
   |
4  | fn insert_resource<R: Resource>(_resource: R) {}
   |                       ^^^^^^^^ required by this bound in `insert_resource`
help: consider specifying the generic argument
   |
10 |     insert_resource::<R>(Res.into());
   |                    +++++
help: consider removing this method call, as the receiver has type `Res` and `Res: Resource` trivially holds
   |
10 -     insert_resource(Res.into());
10 +     insert_resource(Res);
   |
```

The improvements from rust-lang#128849 are still present and the note about the trait coming from the 2 versions of bevy is more explanatory/helpful than before, albeit a bit verbosely.

Fixes rust-lang#132920.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-trait-system Area: Trait system 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. 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

Successfully merging a pull request may close this issue.

6 participants