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: unimpl selecting .. during codegen with -Zmir-opt-level=3 #95640

Closed
matthiaskrgr opened this issue Apr 4, 2022 · 4 comments · Fixed by #98005
Closed

ICE: unimpl selecting .. during codegen with -Zmir-opt-level=3 #95640

matthiaskrgr opened this issue Apr 4, 2022 · 4 comments · Fixed by #98005
Assignees
Labels
C-bug Category: This is a bug. glacier ICE tracked in rust-lang/glacier. 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

@matthiaskrgr
Copy link
Member

matthiaskrgr commented Apr 4, 2022

Code

./src/test/ui/impl-trait/projection.rs or ./src/test/ui/impl-trait/issues/issue-93788.rs

struct D;

trait Tr {
    type It;
    fn foo(self) -> Option<Self::It>;
}

impl<'a> Tr for &'a D {
    type It = ();
    fn foo(self) -> Option<()> { None }
}

fn run<F>(f: F)
    where for<'a> &'a D: Tr,
          F: Fn(<&D as Tr>::It),
{
    let d = &D;
    while let Some(i) = d.foo() {
        f(i);
    }
}

fn main() {
    run(|_| {});
}

Meta

rustc --version --verbose:

rustc 1.61.0-nightly (ec667fbcf 2022-04-04)
binary: rustc
commit-hash: ec667fbcfcd29e2b5080f6be04e229356b27e600
commit-date: 2022-04-04
host: x86_64-unknown-linux-gnu
release: 1.61.0-nightly
LLVM version: 14.0.0

Error output

error: internal compiler error: no errors encountered even though `delay_span_bug` issued

error: internal compiler error: Encountered error `Unimplemented` selecting `Binder(<F as std::ops::Fn<((),)>>, [])` during codegen
  |
  = note: delayed at compiler/rustc_trait_selection/src/traits/codegen.rs:65:43

thread 'rustc' panicked at 'Box<dyn Any>', compiler/rustc_errors/src/lib.rs:1309:13
stack backtrace:
   0:     0x7fb62369e1bd - std::backtrace_rs::backtrace::libunwind::trace::heec4f07b572dff4a
                               at /rustc/ec667fbcfcd29e2b5080f6be04e229356b27e600/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
   1:     0x7fb62369e1bd - std::backtrace_rs::backtrace::trace_unsynchronized::h27f126e1ba2fc9fe
                               at /rustc/ec667fbcfcd29e2b5080f6be04e229356b27e600/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7fb62369e1bd - std::sys_common::backtrace::_print_fmt::h1ad2cfa418d019be
                               at /rustc/ec667fbcfcd29e2b5080f6be04e229356b27e600/library/std/src/sys_common/backtrace.rs:66:5
   3:     0x7fb62369e1bd - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h71bda82396ca2ccb
                               at /rustc/ec667fbcfcd29e2b5080f6be04e229356b27e600/library/std/src/sys_common/backtrace.rs:45:22
   4:     0x7fb6236f800c - core::fmt::write::haf21212323ab55a6
                               at /rustc/ec667fbcfcd29e2b5080f6be04e229356b27e600/library/core/src/fmt/mod.rs:1194:17
   5:     0x7fb62368f711 - std::io::Write::write_fmt::h709567098e8bb7a3
                               at /rustc/ec667fbcfcd29e2b5080f6be04e229356b27e600/library/std/src/io/mod.rs:1655:15
   6:     0x7fb6236a12a5 - std::sys_common::backtrace::_print::h7bdb328e8fb5bc9c
                               at /rustc/ec667fbcfcd29e2b5080f6be04e229356b27e600/library/std/src/sys_common/backtrace.rs:48:5
   7:     0x7fb6236a12a5 - std::sys_common::backtrace::print::ha66a358ec62b9f56
                               at /rustc/ec667fbcfcd29e2b5080f6be04e229356b27e600/library/std/src/sys_common/backtrace.rs:35:9
   8:     0x7fb6236a12a5 - std::panicking::default_hook::{{closure}}::h42888aa46b817168
                               at /rustc/ec667fbcfcd29e2b5080f6be04e229356b27e600/library/std/src/panicking.rs:295:22
   9:     0x7fb6236a0f59 - std::panicking::default_hook::h2f63747e8b20dcce
                               at /rustc/ec667fbcfcd29e2b5080f6be04e229356b27e600/library/std/src/panicking.rs:314:9
  10:     0x7fb623eadb31 - rustc_driver[da51e8717594c06]::DEFAULT_HOOK::{closure#0}::{closure#0}
  11:     0x7fb6236a19f0 - std::panicking::rust_panic_with_hook::hffc556aebc44ec87
                               at /rustc/ec667fbcfcd29e2b5080f6be04e229356b27e600/library/std/src/panicking.rs:702:17
  12:     0x7fb624f85221 - std[f6c29e8191ad9162]::panicking::begin_panic::<rustc_errors[28fdae027b88b0d3]::ExplicitBug>::{closure#0}
  13:     0x7fb624f85096 - std[f6c29e8191ad9162]::sys_common::backtrace::__rust_end_short_backtrace::<std[f6c29e8191ad9162]::panicking::begin_panic<rustc_errors[28fdae027b88b0d3]::ExplicitBug>::{closure#0}, !>
  14:     0x7fb624f86646 - std[f6c29e8191ad9162]::panicking::begin_panic::<rustc_errors[28fdae027b88b0d3]::ExplicitBug>
  15:     0x7fb624f93126 - std[f6c29e8191ad9162]::panic::panic_any::<rustc_errors[28fdae027b88b0d3]::ExplicitBug>
  16:     0x7fb62667b63a - <rustc_errors[28fdae027b88b0d3]::HandlerInner as core[a94a316f25bee083]::ops::drop::Drop>::drop
  17:     0x7fb625d99d58 - core[a94a316f25bee083]::ptr::drop_in_place::<rustc_session[e1d6914d0f769cb2]::parse::ParseSess>
  18:     0x7fb625d9ca03 - <alloc[ca428d0dd1bb949c]::rc::Rc<rustc_session[e1d6914d0f769cb2]::session::Session> as core[a94a316f25bee083]::ops::drop::Drop>::drop
  19:     0x7fb625d831bd - core[a94a316f25bee083]::ptr::drop_in_place::<rustc_interface[ab2911a8b2c2c556]::interface::Compiler>
  20:     0x7fb625d82835 - rustc_span[d93c874db11a808b]::with_source_map::<core[a94a316f25bee083]::result::Result<(), rustc_errors[28fdae027b88b0d3]::ErrorGuaranteed>, rustc_interface[ab2911a8b2c2c556]::interface::create_compiler_and_run<core[a94a316f25bee083]::result::Result<(), rustc_errors[28fdae027b88b0d3]::ErrorGuaranteed>, rustc_driver[da51e8717594c06]::run_compiler::{closure#1}>::{closure#1}>
  21:     0x7fb625d9dca4 - rustc_interface[ab2911a8b2c2c556]::interface::create_compiler_and_run::<core[a94a316f25bee083]::result::Result<(), rustc_errors[28fdae027b88b0d3]::ErrorGuaranteed>, rustc_driver[da51e8717594c06]::run_compiler::{closure#1}>
  22:     0x7fb625d80de2 - <scoped_tls[49782f0079b233c3]::ScopedKey<rustc_span[d93c874db11a808b]::SessionGlobals>>::set::<rustc_interface[ab2911a8b2c2c556]::interface::run_compiler<core[a94a316f25bee083]::result::Result<(), rustc_errors[28fdae027b88b0d3]::ErrorGuaranteed>, rustc_driver[da51e8717594c06]::run_compiler::{closure#1}>::{closure#0}, core[a94a316f25bee083]::result::Result<(), rustc_errors[28fdae027b88b0d3]::ErrorGuaranteed>>
  23:     0x7fb625d9699f - std[f6c29e8191ad9162]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[ab2911a8b2c2c556]::util::run_in_thread_pool_with_globals<rustc_interface[ab2911a8b2c2c556]::interface::run_compiler<core[a94a316f25bee083]::result::Result<(), rustc_errors[28fdae027b88b0d3]::ErrorGuaranteed>, rustc_driver[da51e8717594c06]::run_compiler::{closure#1}>::{closure#0}, core[a94a316f25bee083]::result::Result<(), rustc_errors[28fdae027b88b0d3]::ErrorGuaranteed>>::{closure#0}, core[a94a316f25bee083]::result::Result<(), rustc_errors[28fdae027b88b0d3]::ErrorGuaranteed>>
  24:     0x7fb625d82119 - <<std[f6c29e8191ad9162]::thread::Builder>::spawn_unchecked_<rustc_interface[ab2911a8b2c2c556]::util::run_in_thread_pool_with_globals<rustc_interface[ab2911a8b2c2c556]::interface::run_compiler<core[a94a316f25bee083]::result::Result<(), rustc_errors[28fdae027b88b0d3]::ErrorGuaranteed>, rustc_driver[da51e8717594c06]::run_compiler::{closure#1}>::{closure#0}, core[a94a316f25bee083]::result::Result<(), rustc_errors[28fdae027b88b0d3]::ErrorGuaranteed>>::{closure#0}, core[a94a316f25bee083]::result::Result<(), rustc_errors[28fdae027b88b0d3]::ErrorGuaranteed>>::{closure#1} as core[a94a316f25bee083]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  25:     0x7fb6236abbe3 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hb733ebfa7dfa7117
                               at /rustc/ec667fbcfcd29e2b5080f6be04e229356b27e600/library/alloc/src/boxed.rs:1861:9
  26:     0x7fb6236abbe3 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h5bd940b278e4b294
                               at /rustc/ec667fbcfcd29e2b5080f6be04e229356b27e600/library/alloc/src/boxed.rs:1861:9
  27:     0x7fb6236abbe3 - std::sys::unix::thread::Thread::new::thread_start::h3e807ea239c319c1
                               at /rustc/ec667fbcfcd29e2b5080f6be04e229356b27e600/library/std/src/sys/unix/thread.rs:108:17
  28:     0x7fb6234835c2 - start_thread
  29:     0x7fb623508584 - __clone
  30:                0x0 - <unknown>

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.61.0-nightly (ec667fbcf 2022-04-04) running on x86_64-unknown-linux-gnu

note: compiler flags: -Z mir-opt-level=3

query stack during panic:
end of query stack
Backtrace


cc @compiler-errors I believe this might be caused by #95031

@matthiaskrgr matthiaskrgr added 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. C-bug Category: This is a bug. labels Apr 4, 2022
@compiler-errors compiler-errors self-assigned this Apr 4, 2022
@compiler-errors
Copy link
Member

I'll look into it regardless

@ghost

This comment was marked as resolved.

@matthiaskrgr
Copy link
Member Author

@allexgray the nightly that contains suspicious commit has not been released yet, there is no point in trying to reproduce this with nightly (or even stable).
You'll need something that contains ec667fbcfcd29e2b5080f6be04e229356b27e600

@compiler-errors
Copy link
Member

This is the same issue that I identified in #94238, but the bug identified and fixed in #95031 actually caused it to not be triggered until now.

The issue here is a "trivial bound" (for<'a> &'a D: Tr,) causing us to not select <&D as Tr>::It => () but <&D as Tr>::It => <&D as Tr>::It in the MIR inliner. The caching bug actually caused the latter branch to happen everywhere, so when that bug was fixed, we started to normalize <&D as Tr>::It to () in some places, causing this ICE. I bet I could trigger an ICE with a slight modification to this code using the inliner even with #95031 reverted.

This is probably only triggered by the inliner, but the MIR inliner isn't enabled without -Zmir-opt-level being explicitly provided, right?

@rust-lang-glacier-bot rust-lang-glacier-bot added the glacier ICE tracked in rust-lang/glacier. label Apr 9, 2022
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Jun 18, 2022
…r=Mark-Simulacrum

Add some tests for impossible bounds

Adds test for rust-lang#93008
Adds test for rust-lang#94680
Closes rust-lang#94999
Closes rust-lang#95640
JohnTitor added a commit to JohnTitor/rust that referenced this issue Jun 22, 2022
…r=Mark-Simulacrum

Add some tests for impossible bounds

Adds test for rust-lang#93008
Adds test for rust-lang#94680
Closes rust-lang#94999
Closes rust-lang#95640
@bors bors closed this as completed in 400751d Jun 22, 2022
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. glacier ICE tracked in rust-lang/glacier. 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
3 participants