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: assertion failed: value <= 0xFFFF_FF00 #121126

Closed
matthiaskrgr opened this issue Feb 15, 2024 · 6 comments · Fixed by #125821
Closed

ICE: assertion failed: value <= 0xFFFF_FF00 #121126

matthiaskrgr opened this issue Feb 15, 2024 · 6 comments · Fixed by #125821
Labels
C-bug Category: This is a bug. E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ P-medium Medium priority regression-from-stable-to-beta Performance or correctness regression from stable to beta. S-bug-has-test Status: This bug is tracked inside the repo by a `known-bug` test. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Milestone

Comments

@matthiaskrgr
Copy link
Member

auto-reduced (treereduce-rust):

fn main() {
    let _n = 1i64 >> [64][4_294_967_295];
}

original:

// build-fail
// compile-flags: -C debug-assertions

#![deny(arithmetic_overflow)]

fn main() {
    let _n = 1i64 >> [64][4_294_967_295];
    //~^ ERROR: this arithmetic operation will overflow
}

Version information

rustc 1.78.0-nightly (ee9c7c940 2024-02-14)
binary: rustc
commit-hash: ee9c7c940c07d8b67c9a6b2ec930db70dcd23a46
commit-date: 2024-02-14
host: x86_64-unknown-linux-gnu
release: 1.78.0-nightly
LLVM version: 18.1.0

Command:
/home/matthias/.rustup/toolchains/master/bin/rustc

Program output

error: this operation will panic at runtime
 --> /tmp/icemaker_global_tempdir.rNcBg9EDTBPd/rustc_testrunner_tmpdir_reporting.ckrlm3bA7Huu/mvce.rs:2:22
  |
2 |     let _n = 1i64 >> [64][4_294_967_295];
  |                      ^^^^^^^^^^^^^^^^^^^ index out of bounds: the length is 1 but the index is 4294967295
  |
  = note: `#[deny(unconditional_panic)]` on by default

thread 'rustc' panicked at /rustc/ee9c7c940c07d8b67c9a6b2ec930db70dcd23a46/compiler/rustc_target/src/abi/mod.rs:22:1:
assertion failed: value <= 0xFFFF_FF00
stack backtrace:
   0:     0x7f953378ce46 - std::backtrace_rs::backtrace::libunwind::trace::h5168cb64cb843b87
                               at /rustc/ee9c7c940c07d8b67c9a6b2ec930db70dcd23a46/library/std/src/../../backtrace/src/backtrace/libunwind.rs:104:5
   1:     0x7f953378ce46 - std::backtrace_rs::backtrace::trace_unsynchronized::hbbff473666b784c6
                               at /rustc/ee9c7c940c07d8b67c9a6b2ec930db70dcd23a46/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7f953378ce46 - std::sys_common::backtrace::_print_fmt::h6c61b632e6cc7949
                               at /rustc/ee9c7c940c07d8b67c9a6b2ec930db70dcd23a46/library/std/src/sys_common/backtrace.rs:68:5
   3:     0x7f953378ce46 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h974a6b559c2b8d41
                               at /rustc/ee9c7c940c07d8b67c9a6b2ec930db70dcd23a46/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x7f95337dd46c - core::fmt::rt::Argument::fmt::hf6a5273aff56768c
                               at /rustc/ee9c7c940c07d8b67c9a6b2ec930db70dcd23a46/library/core/src/fmt/rt.rs:142:9
   5:     0x7f95337dd46c - core::fmt::write::h1caffe3a78971207
                               at /rustc/ee9c7c940c07d8b67c9a6b2ec930db70dcd23a46/library/core/src/fmt/mod.rs:1120:17
   6:     0x7f95337807ef - std::io::Write::write_fmt::h2caf2bb3485e27a5
                               at /rustc/ee9c7c940c07d8b67c9a6b2ec930db70dcd23a46/library/std/src/io/mod.rs:1854:15
   7:     0x7f953378cbf4 - std::sys_common::backtrace::_print::h0414d95b24b9ea44
                               at /rustc/ee9c7c940c07d8b67c9a6b2ec930db70dcd23a46/library/std/src/sys_common/backtrace.rs:47:5
   8:     0x7f953378cbf4 - std::sys_common::backtrace::print::hfdf60e3b3d06625d
                               at /rustc/ee9c7c940c07d8b67c9a6b2ec930db70dcd23a46/library/std/src/sys_common/backtrace.rs:34:9
   9:     0x7f953378f93b - std::panicking::default_hook::{{closure}}::h3c1109072cde0ade
  10:     0x7f953378f689 - std::panicking::default_hook::hfe3c076d4f24ecbe
                               at /rustc/ee9c7c940c07d8b67c9a6b2ec930db70dcd23a46/library/std/src/panicking.rs:292:9
  11:     0x7f95365f563c - std[2308076c1424b998]::panicking::update_hook::<alloc[33ce0ef41c101337]::boxed::Box<rustc_driver_impl[d317596fd5f90102]::install_ice_hook::{closure#0}>>::{closure#0}
  12:     0x7f95337900a0 - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::h8a55f98e23703736
                               at /rustc/ee9c7c940c07d8b67c9a6b2ec930db70dcd23a46/library/alloc/src/boxed.rs:2030:9
  13:     0x7f95337900a0 - std::panicking::rust_panic_with_hook::hc147efcd5d482f2c
                               at /rustc/ee9c7c940c07d8b67c9a6b2ec930db70dcd23a46/library/std/src/panicking.rs:785:13
  14:     0x7f953378fda9 - std::panicking::begin_panic_handler::{{closure}}::h6174f0cd2a065d90
                               at /rustc/ee9c7c940c07d8b67c9a6b2ec930db70dcd23a46/library/std/src/panicking.rs:651:13
  15:     0x7f953378d326 - std::sys_common::backtrace::__rust_end_short_backtrace::h770b1c8f4d2029d4
                               at /rustc/ee9c7c940c07d8b67c9a6b2ec930db70dcd23a46/library/std/src/sys_common/backtrace.rs:171:18
  16:     0x7f953378fb14 - rust_begin_unwind
                               at /rustc/ee9c7c940c07d8b67c9a6b2ec930db70dcd23a46/library/std/src/panicking.rs:647:5
  17:     0x7f95337d9975 - core::panicking::panic_fmt::h66e8ea0facb42563
                               at /rustc/ee9c7c940c07d8b67c9a6b2ec930db70dcd23a46/library/core/src/panicking.rs:72:14
  18:     0x7f95337d9a33 - core::panicking::panic::h272a74656aca8902
                               at /rustc/ee9c7c940c07d8b67c9a6b2ec930db70dcd23a46/library/core/src/panicking.rs:144:5
  19:     0x7f9538bcde42 - <rustc_mir_transform[c0673d0b3c528a53]::const_prop_lint::ConstPropagator>::get_const.cold.0
  20:     0x7f9535136654 - <rustc_mir_transform[c0673d0b3c528a53]::const_prop_lint::ConstPropagator as rustc_middle[efc8e2d5742a68dd]::mir::visit::Visitor>::visit_assign
  21:     0x7f9537e28c5b - <rustc_mir_transform[c0673d0b3c528a53]::const_prop_lint::ConstPropagator as rustc_middle[efc8e2d5742a68dd]::mir::visit::Visitor>::visit_body
  22:     0x7f95351325d6 - <rustc_mir_transform[c0673d0b3c528a53]::const_prop_lint::ConstPropLint as rustc_mir_transform[c0673d0b3c528a53]::pass_manager::MirLint>::run_lint
  23:     0x7f953781420f - rustc_mir_transform[c0673d0b3c528a53]::pass_manager::run_passes_inner
  24:     0x7f9537fb3684 - rustc_mir_transform[c0673d0b3c528a53]::mir_drops_elaborated_and_const_checked
  25:     0x7f9537fb2fa9 - rustc_query_impl[ecef4a4fa1cc3689]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[ecef4a4fa1cc3689]::query_impl::mir_drops_elaborated_and_const_checked::dynamic_query::{closure#2}::{closure#0}, rustc_middle[efc8e2d5742a68dd]::query::erase::Erased<[u8; 8usize]>>
  26:     0x7f953798cdb0 - rustc_query_system[8b26caae5283da17]::query::plumbing::try_execute_query::<rustc_query_impl[ecef4a4fa1cc3689]::DynamicConfig<rustc_query_system[8b26caae5283da17]::query::caches::VecCache<rustc_span[e043cedf16fd8748]::def_id::LocalDefId, rustc_middle[efc8e2d5742a68dd]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[ecef4a4fa1cc3689]::plumbing::QueryCtxt, false>
  27:     0x7f953798c69c - rustc_query_impl[ecef4a4fa1cc3689]::query_impl::mir_drops_elaborated_and_const_checked::get_query_non_incr::__rust_end_short_backtrace
  28:     0x7f95381fbb3f - rustc_interface[e88069c12facd435]::passes::analysis
  29:     0x7f95381fb229 - rustc_query_impl[ecef4a4fa1cc3689]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[ecef4a4fa1cc3689]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[efc8e2d5742a68dd]::query::erase::Erased<[u8; 1usize]>>
  30:     0x7f953863afe5 - rustc_query_system[8b26caae5283da17]::query::plumbing::try_execute_query::<rustc_query_impl[ecef4a4fa1cc3689]::DynamicConfig<rustc_query_system[8b26caae5283da17]::query::caches::SingleCache<rustc_middle[efc8e2d5742a68dd]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[ecef4a4fa1cc3689]::plumbing::QueryCtxt, false>
  31:     0x7f953863ad49 - rustc_query_impl[ecef4a4fa1cc3689]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
  32:     0x7f9538644695 - rustc_interface[e88069c12facd435]::interface::run_compiler::<core[db7e23408f407db6]::result::Result<(), rustc_span[e043cedf16fd8748]::ErrorGuaranteed>, rustc_driver_impl[d317596fd5f90102]::run_compiler::{closure#0}>::{closure#0}
  33:     0x7f95387c5ad8 - std[2308076c1424b998]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[e88069c12facd435]::util::run_in_thread_with_globals<rustc_interface[e88069c12facd435]::util::run_in_thread_pool_with_globals<rustc_interface[e88069c12facd435]::interface::run_compiler<core[db7e23408f407db6]::result::Result<(), rustc_span[e043cedf16fd8748]::ErrorGuaranteed>, rustc_driver_impl[d317596fd5f90102]::run_compiler::{closure#0}>::{closure#0}, core[db7e23408f407db6]::result::Result<(), rustc_span[e043cedf16fd8748]::ErrorGuaranteed>>::{closure#0}, core[db7e23408f407db6]::result::Result<(), rustc_span[e043cedf16fd8748]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[db7e23408f407db6]::result::Result<(), rustc_span[e043cedf16fd8748]::ErrorGuaranteed>>
  34:     0x7f95387c5904 - <<std[2308076c1424b998]::thread::Builder>::spawn_unchecked_<rustc_interface[e88069c12facd435]::util::run_in_thread_with_globals<rustc_interface[e88069c12facd435]::util::run_in_thread_pool_with_globals<rustc_interface[e88069c12facd435]::interface::run_compiler<core[db7e23408f407db6]::result::Result<(), rustc_span[e043cedf16fd8748]::ErrorGuaranteed>, rustc_driver_impl[d317596fd5f90102]::run_compiler::{closure#0}>::{closure#0}, core[db7e23408f407db6]::result::Result<(), rustc_span[e043cedf16fd8748]::ErrorGuaranteed>>::{closure#0}, core[db7e23408f407db6]::result::Result<(), rustc_span[e043cedf16fd8748]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[db7e23408f407db6]::result::Result<(), rustc_span[e043cedf16fd8748]::ErrorGuaranteed>>::{closure#1} as core[db7e23408f407db6]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  35:     0x7f95337991e5 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hbe12538a3d7e111d
                               at /rustc/ee9c7c940c07d8b67c9a6b2ec930db70dcd23a46/library/alloc/src/boxed.rs:2016:9
  36:     0x7f95337991e5 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h306728bac30291a0
                               at /rustc/ee9c7c940c07d8b67c9a6b2ec930db70dcd23a46/library/alloc/src/boxed.rs:2016:9
  37:     0x7f95337991e5 - std::sys::pal::unix::thread::Thread::new::thread_start::hec142a176366d167
                               at /rustc/ee9c7c940c07d8b67c9a6b2ec930db70dcd23a46/library/std/src/sys/pal/unix/thread.rs:108:17
  38:     0x7f95335809eb - <unknown>
  39:     0x7f95336047cc - <unknown>
  40:                0x0 - <unknown>

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: rustc 1.78.0-nightly (ee9c7c940 2024-02-14) running on x86_64-unknown-linux-gnu

query stack during panic:
#0 [mir_drops_elaborated_and_const_checked] elaborating drops for `main`
#1 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to 1 previous error


@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 Feb 15, 2024
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Feb 15, 2024
@matthiaskrgr
Copy link
Member Author

#119627 cc @oli-obk

@oli-obk
Copy link
Contributor

oli-obk commented Feb 15, 2024

I cannot reproduce this with a local stage 1 build 😕 nightly and beta show this tho...

@oli-obk
Copy link
Contributor

oli-obk commented Feb 15, 2024

maybe this is a rustc miscompile? #121124 (comment)

cc @saethlin

@saethlin saethlin added A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. I-unsound Issue: A soundness hole (worst kind of bug), see: https://en.wikipedia.org/wiki/Soundness and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Feb 15, 2024
@rustbot rustbot added the I-prioritize Issue: Indicates that prioritization has been requested for this issue. label Feb 15, 2024
@saethlin saethlin added the regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. label Feb 15, 2024
@saethlin
Copy link
Member

I can reproduce this on aarch64-apple-darwin, and on beta.

@saethlin saethlin added regression-from-stable-to-beta Performance or correctness regression from stable to beta. and removed regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. labels Feb 15, 2024
@tmiasko
Copy link
Contributor

tmiasko commented Feb 15, 2024

The calls to FieldIdx::from_u32 seem bogus because index is potentially out of range (the valid range is restricted further in comparison to u32):

fields.get(FieldIdx::from_u32(idx.try_into().ok()?)).unwrap_or(&Value::Uninit)
}
(
PlaceElem::ConstantIndex { offset, min_length: _, from_end: false },
Value::Aggregate { fields, .. },
) => fields
.get(FieldIdx::from_u32(offset.try_into().ok()?))

@tmiasko tmiasko removed A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. I-unsound Issue: A soundness hole (worst kind of bug), see: https://en.wikipedia.org/wiki/Soundness labels Feb 15, 2024
@apiraino
Copy link
Contributor

WG-prioritization assigning priority (Zulip discussion).

@rustbot label -I-prioritize +P-medium

@rustbot rustbot added P-medium Medium priority and removed I-prioritize Issue: Indicates that prioritization has been requested for this issue. labels Feb 15, 2024
@Mark-Simulacrum Mark-Simulacrum added this to the 1.77.0 milestone Mar 15, 2024
c4rrao added a commit to c4rrao/my_rust that referenced this issue Apr 4, 2024
When indexing an array with an index (u32) that exceeds the maximum value allowed by FieldIdx (default: 0xFFFF_FF00), although the compiler would detect the error, it would also cause a panic, which is a bug.
I fixed it by adding a verification before calling the FieldIdx::from_u32(idx) method.
This check ensures that if the idx value is greater than the maximum allowed value, it returns Option::None, similar to how other functions handle errors during the call to the project method of type Value.
@matthiaskrgr matthiaskrgr added the S-bug-has-test Status: This bug is tracked inside the repo by a `known-bug` test. label Apr 15, 2024
@cjgillot cjgillot added the E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. label May 11, 2024
@bors bors closed this as completed in acaf0ae Jun 1, 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-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ P-medium Medium priority regression-from-stable-to-beta Performance or correctness regression from stable to beta. S-bug-has-test Status: This bug is tracked inside the repo by a `known-bug` test. 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.

8 participants