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: broken mir with no-core and 1 => 1 match arm #102465

Closed
matthiaskrgr opened this issue Sep 29, 2022 · 6 comments
Closed

ICE: broken mir with no-core and 1 => 1 match arm #102465

matthiaskrgr opened this issue Sep 29, 2022 · 6 comments
Labels
C-bug Category: This is a bug. E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. F-no_core `#![feature(no_core)]` glacier ICE tracked in rust-lang/glacier. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ requires-internal-features This issue requires the use of internal features. requires-nightly This issue requires a nightly compiler in some way. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@matthiaskrgr
Copy link
Member

Code

#![feature(lang_items, no_core)]
#![no_std]
#![no_core]

#[lang = "sized"]
pub trait Sized {}

#[lang = "copy"]
trait Copy {}

fn bla(argc: isize)  {
    match argc {
        1 => 1, // removing this arm fixes the ICE
        _ => 1,
    };
}

Meta

rustc --version --verbose:

rustc 1.66.0-nightly (ce7f0f1aa 2022-09-28)
binary: rustc
commit-hash: ce7f0f1aa0f02c45cad0749e63f3086234b1f422
commit-date: 2022-09-28
host: x86_64-unknown-linux-gnu
release: 1.66.0-nightly
LLVM version: 15.0.0

Error output

rustc 92495.rs --crate-type lib

<output>
Backtrace

warning: function `bla` is never used
  --> 92495.rs:11:4
   |
11 | fn bla(argc: isize)  {
   |    ^^^
   |
   = note: `#[warn(dead_code)]` on by default

warning: 1 warning emitted

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

error: internal compiler error: broken MIR in DefId(0:3 ~ 92495[a75f]::bla) (NoSolution): could not prove Binder(TraitPredicate(<isize as Copy>, polarity:Positive), [])
  |
  = note: delayed at compiler/rustc_borrowck/src/type_check/canonical.rs:156:13

thread 'rustc' panicked at 'Box<dyn Any>', compiler/rustc_errors/src/lib.rs:1530:13
stack backtrace:
   0:     0x7f97106c3170 - std::backtrace_rs::backtrace::libunwind::trace::hac9b0f7f9661e748
                               at /rustc/ce7f0f1aa0f02c45cad0749e63f3086234b1f422/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   1:     0x7f97106c3170 - std::backtrace_rs::backtrace::trace_unsynchronized::hc44795987fc42d34
                               at /rustc/ce7f0f1aa0f02c45cad0749e63f3086234b1f422/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7f97106c3170 - std::sys_common::backtrace::_print_fmt::h11541e17c3fc86a7
                               at /rustc/ce7f0f1aa0f02c45cad0749e63f3086234b1f422/library/std/src/sys_common/backtrace.rs:66:5
   3:     0x7f97106c3170 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::hc17ff1666cc882db
                               at /rustc/ce7f0f1aa0f02c45cad0749e63f3086234b1f422/library/std/src/sys_common/backtrace.rs:45:22
   4:     0x7f971071de2e - core::fmt::write::h55fcab10ae826150
                               at /rustc/ce7f0f1aa0f02c45cad0749e63f3086234b1f422/library/core/src/fmt/mod.rs:1209:17
   5:     0x7f97106b3db5 - std::io::Write::write_fmt::hf963d6d18d14f181
                               at /rustc/ce7f0f1aa0f02c45cad0749e63f3086234b1f422/library/std/src/io/mod.rs:1679:15
   6:     0x7f97106c5ef3 - std::sys_common::backtrace::_print::h994ce2c0e5b405c8
                               at /rustc/ce7f0f1aa0f02c45cad0749e63f3086234b1f422/library/std/src/sys_common/backtrace.rs:48:5
   7:     0x7f97106c5ef3 - std::sys_common::backtrace::print::hcc56026dcd969e04
                               at /rustc/ce7f0f1aa0f02c45cad0749e63f3086234b1f422/library/std/src/sys_common/backtrace.rs:35:9
   8:     0x7f97106c5ef3 - std::panicking::default_hook::{{closure}}::h88f2c5d855241086
                               at /rustc/ce7f0f1aa0f02c45cad0749e63f3086234b1f422/library/std/src/panicking.rs:267:22
   9:     0x7f97106c5bdf - std::panicking::default_hook::h8c95d81babfc3452
                               at /rustc/ce7f0f1aa0f02c45cad0749e63f3086234b1f422/library/std/src/panicking.rs:286:9
  10:     0x7f9712efb801 - rustc_driver[b4131074c7377c18]::DEFAULT_HOOK::{closure#0}::{closure#0}
  11:     0x7f97106c672b - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::h67c5cbe4132c274b
                               at /rustc/ce7f0f1aa0f02c45cad0749e63f3086234b1f422/library/alloc/src/boxed.rs:1952:9
  12:     0x7f97106c672b - std::panicking::rust_panic_with_hook::h60207dae86acc93c
                               at /rustc/ce7f0f1aa0f02c45cad0749e63f3086234b1f422/library/std/src/panicking.rs:673:13
  13:     0x7f9714014701 - std[1bac5bf8d99344e6]::panicking::begin_panic::<rustc_errors[6dd3b64aee5d90d7]::ExplicitBug>::{closure#0}
  14:     0x7f9714013026 - std[1bac5bf8d99344e6]::sys_common::backtrace::__rust_end_short_backtrace::<std[1bac5bf8d99344e6]::panicking::begin_panic<rustc_errors[6dd3b64aee5d90d7]::ExplicitBug>::{closure#0}, !>
  15:     0x7f971400cfb6 - std[1bac5bf8d99344e6]::panicking::begin_panic::<rustc_errors[6dd3b64aee5d90d7]::ExplicitBug>
  16:     0x7f971400f7d6 - std[1bac5bf8d99344e6]::panic::panic_any::<rustc_errors[6dd3b64aee5d90d7]::ExplicitBug>
  17:     0x7f9712a681c8 - <rustc_errors[6dd3b64aee5d90d7]::HandlerInner as core[de81bf0691074480]::ops::drop::Drop>::drop
  18:     0x7f9711d1e468 - core[de81bf0691074480]::ptr::drop_in_place::<rustc_session[d3255eaf8224a584]::parse::ParseSess>
  19:     0x7f9711cdc3b8 - <alloc[c8bb264001a6b8ff]::rc::Rc<rustc_session[d3255eaf8224a584]::session::Session> as core[de81bf0691074480]::ops::drop::Drop>::drop
  20:     0x7f9711cd908d - core[de81bf0691074480]::ptr::drop_in_place::<rustc_interface[f0f2c906f605917e]::interface::Compiler>
  21:     0x7f9711cd6734 - rustc_interface[f0f2c906f605917e]::interface::create_compiler_and_run::<core[de81bf0691074480]::result::Result<(), rustc_errors[6dd3b64aee5d90d7]::ErrorGuaranteed>, rustc_driver[b4131074c7377c18]::run_compiler::{closure#1}>
  22:     0x7f9711cd4c41 - <scoped_tls[77ed516bf348563d]::ScopedKey<rustc_span[a9093c78adc8a30e]::SessionGlobals>>::set::<rustc_interface[f0f2c906f605917e]::interface::run_compiler<core[de81bf0691074480]::result::Result<(), rustc_errors[6dd3b64aee5d90d7]::ErrorGuaranteed>, rustc_driver[b4131074c7377c18]::run_compiler::{closure#1}>::{closure#0}, core[de81bf0691074480]::result::Result<(), rustc_errors[6dd3b64aee5d90d7]::ErrorGuaranteed>>
  23:     0x7f9711cd492f - std[1bac5bf8d99344e6]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[f0f2c906f605917e]::util::run_in_thread_pool_with_globals<rustc_interface[f0f2c906f605917e]::interface::run_compiler<core[de81bf0691074480]::result::Result<(), rustc_errors[6dd3b64aee5d90d7]::ErrorGuaranteed>, rustc_driver[b4131074c7377c18]::run_compiler::{closure#1}>::{closure#0}, core[de81bf0691074480]::result::Result<(), rustc_errors[6dd3b64aee5d90d7]::ErrorGuaranteed>>::{closure#0}, core[de81bf0691074480]::result::Result<(), rustc_errors[6dd3b64aee5d90d7]::ErrorGuaranteed>>
  24:     0x7f9712d5d600 - <<std[1bac5bf8d99344e6]::thread::Builder>::spawn_unchecked_<rustc_interface[f0f2c906f605917e]::util::run_in_thread_pool_with_globals<rustc_interface[f0f2c906f605917e]::interface::run_compiler<core[de81bf0691074480]::result::Result<(), rustc_errors[6dd3b64aee5d90d7]::ErrorGuaranteed>, rustc_driver[b4131074c7377c18]::run_compiler::{closure#1}>::{closure#0}, core[de81bf0691074480]::result::Result<(), rustc_errors[6dd3b64aee5d90d7]::ErrorGuaranteed>>::{closure#0}, core[de81bf0691074480]::result::Result<(), rustc_errors[6dd3b64aee5d90d7]::ErrorGuaranteed>>::{closure#1} as core[de81bf0691074480]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  25:     0x7f97106d0393 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hd5e3cab38cec9739
                               at /rustc/ce7f0f1aa0f02c45cad0749e63f3086234b1f422/library/alloc/src/boxed.rs:1938:9
  26:     0x7f97106d0393 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h970a034a5216df96
                               at /rustc/ce7f0f1aa0f02c45cad0749e63f3086234b1f422/library/alloc/src/boxed.rs:1938:9
  27:     0x7f97106d0393 - std::sys::unix::thread::Thread::new::thread_start::h19f111f22a37ea01
                               at /rustc/ce7f0f1aa0f02c45cad0749e63f3086234b1f422/library/std/src/sys/unix/thread.rs:108:17
  28:     0x7f971042878d - <unknown>
  29:     0x7f97104a98e4 - 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.66.0-nightly (ce7f0f1aa 2022-09-28) running on x86_64-unknown-linux-gnu

note: compiler flags: --crate-type lib

query stack during panic:
end of query stack

@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. requires-nightly This issue requires a nightly compiler in some way. labels Sep 29, 2022
@lcnr
Copy link
Contributor

lcnr commented Sep 29, 2022

I feel like we shouldn't really work on fixing this. Parts of the compiler short-cut trivially Copy builtin-types without going through the trait system. Failing with an ICE when missing these impls feels acceptable

@matthiaskrgr
Copy link
Member Author

matthiaskrgr commented Sep 29, 2022

ah, so we try to optimize away 1 => 1 which assume isize/usize is copy but it isn't here in no_core/no_std which causes the ICE?

@lcnr
Copy link
Contributor

lcnr commented Sep 29, 2022

not sure where exactly the ICE happens but pretty much: we compile while assuming that isize: Copy holds without checking it in the trait system

at some point we actually check that in the trait system, see that it doesn't hold, realize that we have a broken assumption and ICE

@compiler-errors
Copy link
Member

Yeah, I think we've gone back and forth on whether or not ICEs with an ill-defined #![no_core] program are worth the effort, code review, and resulting compiler code complexity of fixing. Perhaps it's worthwhile revisiting this as a policy rather than making a specific decision every time, especially since it's very likely that #![no_core] will never be stabilized?

@JohnTitor
Copy link
Member

Fixed on the latest nightly, marking as E-needs-test
@rustbot labels: +E-needs-test

@rustbot rustbot added the E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. label Oct 15, 2023
@Noratrieb
Copy link
Member

Noratrieb commented Jan 29, 2024

wontfix,we do not want a test: rust-lang/compiler-team#620

@Noratrieb Noratrieb closed this as not planned Won't fix, can't repro, duplicate, stale Jan 29, 2024
@fmease fmease added the requires-internal-features This issue requires the use of internal features. label Jan 29, 2024
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. E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. F-no_core `#![feature(no_core)]` glacier ICE tracked in rust-lang/glacier. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ requires-internal-features This issue requires the use of internal features. requires-nightly This issue requires a nightly compiler in some way. 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

8 participants