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: wrapping_mul() with copy bound #101962

Closed
matthiaskrgr opened this issue Sep 18, 2022 · 2 comments · Fixed by #128173
Closed

ICE: broken mir: wrapping_mul() with copy bound #101962

matthiaskrgr opened this issue Sep 18, 2022 · 2 comments · Fixed by #128173
Labels
A-intrinsics Area: Intrinsics C-bug Category: This is a bug. F-core_intrinsics Issue in the "core intrinsics" for internal usage only. glacier ICE tracked in rust-lang/glacier. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ requires-nightly This issue requires a nightly compiler in some way. 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

@matthiaskrgr
Copy link
Member

Code

#![feature(core_intrinsics)]

pub fn wrapping<T: Copy>(a: T, b: T) {
    let _z = core::intrinsics::wrapping_mul(a, b);
}

pub fn main() {
    wrapping(1,2);
}

Meta

rustc --version --verbose:

rustc 1.65.0-nightly (750bd1a7f 2022-09-14)
binary: rustc
commit-hash: 750bd1a7ff3e010611b97ee75d30b7cbf5f3a03c
commit-date: 2022-09-14
host: x86_64-unknown-linux-gnu
release: 1.65.0-nightly
LLVM version: 15.0.0

Error output

<output>
Backtrace

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

error: internal compiler error: broken MIR in Item(WithOptConstParam { did: DefId(0:3 ~ 8a8880dad02e5032aab3b7bbad2422ee44f48c65[266c]::wrapping), const_param_did: None }) (after pass PhaseChange-Runtime(Optimized)) at bb0[2]:
                                Cannot perform arithmetic on type T
 --> 8a8880dad02e5032aab3b7bbad2422ee44f48c65.rs:4:14
  |
4 |     let _z = core::intrinsics::wrapping_mul(a, b);
  |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |
  = note: delayed at compiler/rustc_const_eval/src/transform/validate.rs:129:36

thread 'rustc' panicked at 'Box<dyn Any>', compiler/rustc_errors/src/lib.rs:1492:13
stack backtrace:
   0:     0x7f8e3dea3c20 - std::backtrace_rs::backtrace::libunwind::trace::hf9cd4c385c25a2fe
                               at /rustc/750bd1a7ff3e010611b97ee75d30b7cbf5f3a03c/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   1:     0x7f8e3dea3c20 - std::backtrace_rs::backtrace::trace_unsynchronized::hf9a1be2df46de98c
                               at /rustc/750bd1a7ff3e010611b97ee75d30b7cbf5f3a03c/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7f8e3dea3c20 - std::sys_common::backtrace::_print_fmt::ha770a6c3890b3cde
                               at /rustc/750bd1a7ff3e010611b97ee75d30b7cbf5f3a03c/library/std/src/sys_common/backtrace.rs:66:5
   3:     0x7f8e3dea3c20 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h7099a61d18d47f5f
                               at /rustc/750bd1a7ff3e010611b97ee75d30b7cbf5f3a03c/library/std/src/sys_common/backtrace.rs:45:22
   4:     0x7f8e3defeaee - core::fmt::write::h34c269a5556240be
                               at /rustc/750bd1a7ff3e010611b97ee75d30b7cbf5f3a03c/library/core/src/fmt/mod.rs:1202:17
   5:     0x7f8e3de94835 - std::io::Write::write_fmt::h9b1d898decaac979
                               at /rustc/750bd1a7ff3e010611b97ee75d30b7cbf5f3a03c/library/std/src/io/mod.rs:1679:15
   6:     0x7f8e3dea68d3 - std::sys_common::backtrace::_print::hb8325cbd910e0a42
                               at /rustc/750bd1a7ff3e010611b97ee75d30b7cbf5f3a03c/library/std/src/sys_common/backtrace.rs:48:5
   7:     0x7f8e3dea68d3 - std::sys_common::backtrace::print::h52eaf8f4259fb854
                               at /rustc/750bd1a7ff3e010611b97ee75d30b7cbf5f3a03c/library/std/src/sys_common/backtrace.rs:35:9
   8:     0x7f8e3dea68d3 - std::panicking::default_hook::{{closure}}::h38a1bd1ceb333281
                               at /rustc/750bd1a7ff3e010611b97ee75d30b7cbf5f3a03c/library/std/src/panicking.rs:295:22
   9:     0x7f8e3dea65bf - std::panicking::default_hook::hbfa37b6c2aa83708
                               at /rustc/750bd1a7ff3e010611b97ee75d30b7cbf5f3a03c/library/std/src/panicking.rs:314:9
  10:     0x7f8e4070d001 - <rustc_driver[f7b5b01335fbd434]::DEFAULT_HOOK::{closure#0}::{closure#0} as core[f6f8d9be6066ab2c]::ops::function::FnOnce<(&core[f6f8d9be6066ab2c]::panic::panic_info::PanicInfo,)>>::call_once::{shim:vtable#0}
  11:     0x7f8e3dea710d - std::panicking::rust_panic_with_hook::h6bfc21eea1a19790
                               at /rustc/750bd1a7ff3e010611b97ee75d30b7cbf5f3a03c/library/std/src/panicking.rs:702:17
  12:     0x7f8e41867141 - std[81ab5d9a96a0142e]::panicking::begin_panic::<rustc_errors[e78c9e9af74db21c]::ExplicitBug>::{closure#0}
  13:     0x7f8e41866c66 - std[81ab5d9a96a0142e]::sys_common::backtrace::__rust_end_short_backtrace::<std[81ab5d9a96a0142e]::panicking::begin_panic<rustc_errors[e78c9e9af74db21c]::ExplicitBug>::{closure#0}, !>
  14:     0x7f8e418668f6 - std[81ab5d9a96a0142e]::panicking::begin_panic::<rustc_errors[e78c9e9af74db21c]::ExplicitBug>
  15:     0x7f8e41864446 - std[81ab5d9a96a0142e]::panic::panic_any::<rustc_errors[e78c9e9af74db21c]::ExplicitBug>
  16:     0x7f8e4025e228 - <rustc_errors[e78c9e9af74db21c]::HandlerInner as core[f6f8d9be6066ab2c]::ops::drop::Drop>::drop
  17:     0x7f8e3f540b28 - core[f6f8d9be6066ab2c]::ptr::drop_in_place::<rustc_session[c3e5419825648902]::parse::ParseSess>
  18:     0x7f8e3f4fe4e8 - <alloc[9d62437589f31483]::rc::Rc<rustc_session[c3e5419825648902]::session::Session> as core[f6f8d9be6066ab2c]::ops::drop::Drop>::drop
  19:     0x7f8e3f4fb4ad - core[f6f8d9be6066ab2c]::ptr::drop_in_place::<rustc_interface[5bcac5cfb78c3b1a]::interface::Compiler>
  20:     0x7f8e3f4f8d0c - rustc_interface[5bcac5cfb78c3b1a]::interface::create_compiler_and_run::<core[f6f8d9be6066ab2c]::result::Result<(), rustc_errors[e78c9e9af74db21c]::ErrorGuaranteed>, rustc_driver[f7b5b01335fbd434]::run_compiler::{closure#1}>
  21:     0x7f8e3f4f7211 - <scoped_tls[de48490ce358b7ec]::ScopedKey<rustc_span[352514dd70ceaa1d]::SessionGlobals>>::set::<rustc_interface[5bcac5cfb78c3b1a]::interface::run_compiler<core[f6f8d9be6066ab2c]::result::Result<(), rustc_errors[e78c9e9af74db21c]::ErrorGuaranteed>, rustc_driver[f7b5b01335fbd434]::run_compiler::{closure#1}>::{closure#0}, core[f6f8d9be6066ab2c]::result::Result<(), rustc_errors[e78c9e9af74db21c]::ErrorGuaranteed>>
  22:     0x7f8e3f4f6eff - std[81ab5d9a96a0142e]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[5bcac5cfb78c3b1a]::util::run_in_thread_pool_with_globals<rustc_interface[5bcac5cfb78c3b1a]::interface::run_compiler<core[f6f8d9be6066ab2c]::result::Result<(), rustc_errors[e78c9e9af74db21c]::ErrorGuaranteed>, rustc_driver[f7b5b01335fbd434]::run_compiler::{closure#1}>::{closure#0}, core[f6f8d9be6066ab2c]::result::Result<(), rustc_errors[e78c9e9af74db21c]::ErrorGuaranteed>>::{closure#0}, core[f6f8d9be6066ab2c]::result::Result<(), rustc_errors[e78c9e9af74db21c]::ErrorGuaranteed>>
  23:     0x7f8e40571000 - <<std[81ab5d9a96a0142e]::thread::Builder>::spawn_unchecked_<rustc_interface[5bcac5cfb78c3b1a]::util::run_in_thread_pool_with_globals<rustc_interface[5bcac5cfb78c3b1a]::interface::run_compiler<core[f6f8d9be6066ab2c]::result::Result<(), rustc_errors[e78c9e9af74db21c]::ErrorGuaranteed>, rustc_driver[f7b5b01335fbd434]::run_compiler::{closure#1}>::{closure#0}, core[f6f8d9be6066ab2c]::result::Result<(), rustc_errors[e78c9e9af74db21c]::ErrorGuaranteed>>::{closure#0}, core[f6f8d9be6066ab2c]::result::Result<(), rustc_errors[e78c9e9af74db21c]::ErrorGuaranteed>>::{closure#1} as core[f6f8d9be6066ab2c]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  24:     0x7f8e3deb0ee3 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h2695b43ebae659e4
                               at /rustc/750bd1a7ff3e010611b97ee75d30b7cbf5f3a03c/library/alloc/src/boxed.rs:1940:9
  25:     0x7f8e3deb0ee3 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hf3b49b955267341c
                               at /rustc/750bd1a7ff3e010611b97ee75d30b7cbf5f3a03c/library/alloc/src/boxed.rs:1940:9
  26:     0x7f8e3deb0ee3 - std::sys::unix::thread::Thread::new::thread_start::h2bad5ab8a769c6c8
                               at /rustc/750bd1a7ff3e010611b97ee75d30b7cbf5f3a03c/library/std/src/sys/unix/thread.rs:108:17
  27:     0x7f8e3dc0978d - <unknown>
  28:     0x7f8e3dc8a8e4 - clone
  29:                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.65.0-nightly (750bd1a7f 2022-09-14) running on x86_64-unknown-linux-gnu

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. S-has-mcve Status: A Minimal Complete and Verifiable Example has been found for this issue labels Sep 18, 2022
@matthiaskrgr matthiaskrgr changed the title ICE: wrapping_mul() with copy bound ICE: broken mir: wrapping_mul() with copy bound Sep 18, 2022
matthiaskrgr added a commit to matthiaskrgr/glacier that referenced this issue Sep 23, 2022
@rust-lang-glacier-bot rust-lang-glacier-bot added the glacier ICE tracked in rust-lang/glacier. label Oct 1, 2022
@compiler-errors
Copy link
Member

I think it's understood that using these intrinsics incorrectly will ICE, since we have no way of checking this intrinsic's usage properly via a trait bound...

@compiler-errors compiler-errors added the A-intrinsics Area: Intrinsics label Oct 22, 2022
Manishearth added a commit to Manishearth/rust that referenced this issue Nov 14, 2022
…imulacrum

Add a few known-bug tests

The labels of these tests should be changed from `S-bug-has-mcve` to `S-bug-has-test` once this is merged.

cc:
rust-lang#101518
rust-lang#99492
rust-lang#90950
rust-lang#89196
rust-lang#104034
rust-lang#101350
rust-lang#103705
rust-lang#103899

I couldn't reproduce the failures in rust-lang#101962 and rust-lang#100772 (so either these have started passing, or I didn't repro properly), so leaving those out for now.

rust-lang#102065 was a bit more complicated, since it uses `rustc_private` and I didn't want to mess with that.
@inquisitivecrystal inquisitivecrystal added the requires-nightly This issue requires a nightly compiler in some way. label Dec 12, 2022
@workingjubilee workingjubilee added the F-core_intrinsics Issue in the "core intrinsics" for internal usage only. label Mar 14, 2023
@Noratrieb
Copy link
Member

closing as "don't do this", this is an intrinsic which is not supported

@Noratrieb Noratrieb closed this as not planned Won't fix, can't repro, duplicate, stale Feb 15, 2024
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Jul 25, 2024
…, r=oli-obk

Remove crashes for misuses of intrinsics

All of these do not crash if the feature gate is removed. An ICE due *opting into* the intrinsics feature gate is not a bug that needs to be fixed, but instead a misuse of an internal-only API.

See rust-lang/compiler-team#620

The last two issues are already closed anyways, but:
Fixes rust-lang#97501
Fixes rust-lang#111699
Fixes rust-lang#101962
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-intrinsics Area: Intrinsics C-bug Category: This is a bug. F-core_intrinsics Issue in the "core intrinsics" for internal usage only. glacier ICE tracked in rust-lang/glacier. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ requires-nightly This issue requires a nightly compiler in some way. 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