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

thread 'rustc' panicked at 'to_const_int doesn't work on scalar pairs' #100878

Closed
paolobarbolini opened this issue Aug 22, 2022 · 4 comments · Fixed by #102181
Closed

thread 'rustc' panicked at 'to_const_int doesn't work on scalar pairs' #100878

paolobarbolini opened this issue Aug 22, 2022 · 4 comments · Fixed by #102181
Labels
A-const-eval Area: Constant evaluation (MIR interpretation) 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. 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

@paolobarbolini
Copy link
Contributor

paolobarbolini commented Aug 22, 2022

Code

pub fn get_u16_from_unaligned_manual(data: [u8; 1]) -> u8 {
    data[0] << 8
}

Meta

rustc --version --verbose:

rustc 1.65.0-nightly (c0941dfb5 2022-08-21)
binary: rustc
commit-hash: c0941dfb5a7d07ef2d70cc54d319669d9d6f6c01
commit-date: 2022-08-21
host: x86_64-unknown-linux-gnu
release: 1.65.0-nightly
LLVM version: 15.0.0

Error output

thread 'rustc' panicked at 'to_const_int doesn't work on scalar pairs: InterpErrorInfo(InterpErrorInfoInner { kind: using uninitialized data, but this operation requires initialized memory, backtrace: None })', /rustc/c0941dfb5a7d07ef2d70cc54d319669d9d6f6c01/compiler/rustc_const_eval/src/interpret/operand.rs:272:36
Backtrace

thread 'rustc' panicked at 'to_const_int doesn't work on scalar pairs: InterpErrorInfo(InterpErrorInfoInner { kind: using uninitialized data, but this operation requires initialized memory, backtrace: None })', /rustc/c0941dfb5a7d07ef2d70cc54d319669d9d6f6c01/compiler/rustc_const_eval/src/interpret/operand.rs:272:36
stack backtrace:
   0:     0x7f93067ea820 - std::backtrace_rs::backtrace::libunwind::trace::h4cfc0f9f3e5a75d1
                               at /rustc/c0941dfb5a7d07ef2d70cc54d319669d9d6f6c01/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   1:     0x7f93067ea820 - std::backtrace_rs::backtrace::trace_unsynchronized::h65db0c7f3c27bd40
                               at /rustc/c0941dfb5a7d07ef2d70cc54d319669d9d6f6c01/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7f93067ea820 - std::sys_common::backtrace::_print_fmt::h7089d9085447b800
                               at /rustc/c0941dfb5a7d07ef2d70cc54d319669d9d6f6c01/library/std/src/sys_common/backtrace.rs:66:5
   3:     0x7f93067ea820 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h476cb2d77b0da91f
                               at /rustc/c0941dfb5a7d07ef2d70cc54d319669d9d6f6c01/library/std/src/sys_common/backtrace.rs:45:22
   4:     0x7f93068456ae - core::fmt::write::h53819b6276006088
                               at /rustc/c0941dfb5a7d07ef2d70cc54d319669d9d6f6c01/library/core/src/fmt/mod.rs:1202:17
   5:     0x7f93067db4a5 - std::io::Write::write_fmt::h5b1829515868707a
                               at /rustc/c0941dfb5a7d07ef2d70cc54d319669d9d6f6c01/library/std/src/io/mod.rs:1672:15
   6:     0x7f93067ed4d3 - std::sys_common::backtrace::_print::h6cb157a41b3c080b
                               at /rustc/c0941dfb5a7d07ef2d70cc54d319669d9d6f6c01/library/std/src/sys_common/backtrace.rs:48:5
   7:     0x7f93067ed4d3 - std::sys_common::backtrace::print::h117b78b6f131ece6
                               at /rustc/c0941dfb5a7d07ef2d70cc54d319669d9d6f6c01/library/std/src/sys_common/backtrace.rs:35:9
   8:     0x7f93067ed4d3 - std::panicking::default_hook::{{closure}}::hf55bb9d90900cb92
                               at /rustc/c0941dfb5a7d07ef2d70cc54d319669d9d6f6c01/library/std/src/panicking.rs:295:22
   9:     0x7f93067ed1bf - std::panicking::default_hook::h095947f029f67011
                               at /rustc/c0941dfb5a7d07ef2d70cc54d319669d9d6f6c01/library/std/src/panicking.rs:314:9
  10:     0x7f930902ca54 - <rustc_driver[1396542de658d9ef]::DEFAULT_HOOK::{closure#0}::{closure#0} as core[bafc4c672d35f3dc]::ops::function::FnOnce<(&core[bafc4c672d35f3dc]::panic::panic_info::PanicInfo,)>>::call_once::{shim:vtable#0}
  11:     0x7f93067edd0d - std::panicking::rust_panic_with_hook::h3df526ea3ef21ddb
                               at /rustc/c0941dfb5a7d07ef2d70cc54d319669d9d6f6c01/library/std/src/panicking.rs:702:17
  12:     0x7f93067edb67 - std::panicking::begin_panic_handler::{{closure}}::h802dd6d61f5dd58f
                               at /rustc/c0941dfb5a7d07ef2d70cc54d319669d9d6f6c01/library/std/src/panicking.rs:588:13
  13:     0x7f93067ead2c - std::sys_common::backtrace::__rust_end_short_backtrace::h4bc0ea0de74aba3e
                               at /rustc/c0941dfb5a7d07ef2d70cc54d319669d9d6f6c01/library/std/src/sys_common/backtrace.rs:138:18
  14:     0x7f93067ed882 - rust_begin_unwind
                               at /rustc/c0941dfb5a7d07ef2d70cc54d319669d9d6f6c01/library/std/src/panicking.rs:584:5
  15:     0x7f93068421c3 - core::panicking::panic_fmt::h7c2821ba6a6b7ecd
                               at /rustc/c0941dfb5a7d07ef2d70cc54d319669d9d6f6c01/library/core/src/panicking.rs:142:14
  16:     0x7f9306842523 - core::result::unwrap_failed::hb47e1c05aa7baaf4
                               at /rustc/c0941dfb5a7d07ef2d70cc54d319669d9d6f6c01/library/core/src/result.rs:1814:5
  17:     0x7f9308581fa1 - <rustc_const_eval[786c7168b6e05b59]::interpret::operand::ImmTy>::to_const_int
  18:     0x7f93085813fa - <rustc_mir_transform[da432d88db9d5ab0]::const_prop_lint::ConstPropagator>::check_binary_op
  19:     0x7f930857e630 - <rustc_mir_transform[da432d88db9d5ab0]::const_prop_lint::ConstPropagator as rustc_middle[7247278619f001fe]::mir::visit::Visitor>::visit_body
  20:     0x7f93085723eb - <rustc_mir_transform[da432d88db9d5ab0]::const_prop_lint::ConstProp as rustc_mir_transform[da432d88db9d5ab0]::pass_manager::MirLint>::run_lint
  21:     0x7f93079defba - rustc_mir_transform[da432d88db9d5ab0]::pass_manager::run_passes
  22:     0x7f9308464f3d - rustc_mir_transform[da432d88db9d5ab0]::mir_drops_elaborated_and_const_checked
  23:     0x7f930841390b - rustc_query_system[2ce65edb6101d899]::query::plumbing::try_execute_query::<rustc_query_impl[f8b192862a939dac]::plumbing::QueryCtxt, rustc_query_system[2ce65edb6101d899]::query::caches::DefaultCache<rustc_middle[7247278619f001fe]::ty::WithOptConstParam<rustc_span[5318bedef2ca73b1]::def_id::LocalDefId>, &rustc_data_structures[1c5fb92d75ec3bdb]::steal::Steal<rustc_middle[7247278619f001fe]::mir::Body>>>
  24:     0x7f9308f2aa6a - <rustc_query_impl[f8b192862a939dac]::Queries as rustc_middle[7247278619f001fe]::ty::query::QueryEngine>::mir_drops_elaborated_and_const_checked
  25:     0x7f93079de137 - rustc_mir_transform[da432d88db9d5ab0]::optimized_mir
  26:     0x7f93082dd84e - rustc_query_system[2ce65edb6101d899]::query::plumbing::try_execute_query::<rustc_query_impl[f8b192862a939dac]::plumbing::QueryCtxt, rustc_query_system[2ce65edb6101d899]::query::caches::DefaultCache<rustc_span[5318bedef2ca73b1]::def_id::DefId, &rustc_middle[7247278619f001fe]::mir::Body>>
  27:     0x7f9308f2ad2c - <rustc_query_impl[f8b192862a939dac]::Queries as rustc_middle[7247278619f001fe]::ty::query::QueryEngine>::optimized_mir
  28:     0x7f9307c3f466 - <rustc_middle[7247278619f001fe]::ty::context::TyCtxt>::instance_mir
  29:     0x7f9307c33efc - rustc_monomorphize[38662e978b7edc7]::collector::collect_neighbours
  30:     0x7f9307c31a43 - rustc_monomorphize[38662e978b7edc7]::collector::collect_items_rec
  31:     0x7f9308a15743 - rustc_data_structures[1c5fb92d75ec3bdb]::sync::par_for_each_in::<alloc[cc53910b1e83d5d2]::vec::Vec<rustc_middle[7247278619f001fe]::mir::mono::MonoItem>, rustc_monomorphize[38662e978b7edc7]::collector::collect_crate_mono_items::{closure#1}::{closure#0}>
  32:     0x7f9308a155ac - <rustc_session[8008e2f707931a7]::session::Session>::time::<(), rustc_monomorphize[38662e978b7edc7]::collector::collect_crate_mono_items::{closure#1}>
  33:     0x7f9308a15219 - rustc_monomorphize[38662e978b7edc7]::collector::collect_crate_mono_items
  34:     0x7f9308a14084 - rustc_monomorphize[38662e978b7edc7]::partitioning::collect_and_partition_mono_items
  35:     0x7f9308d8af15 - rustc_query_system[2ce65edb6101d899]::query::plumbing::try_execute_query::<rustc_query_impl[f8b192862a939dac]::plumbing::QueryCtxt, rustc_query_system[2ce65edb6101d899]::query::caches::DefaultCache<(), (&std[e6e0e56adfd51cea]::collections::hash::set::HashSet<rustc_span[5318bedef2ca73b1]::def_id::DefId, core[bafc4c672d35f3dc]::hash::BuildHasherDefault<rustc_hash[6fc7e82ecd57dc4c]::FxHasher>>, &[rustc_middle[7247278619f001fe]::mir::mono::CodegenUnit])>>
  36:     0x7f9308d8ac15 - rustc_query_system[2ce65edb6101d899]::query::plumbing::get_query::<rustc_query_impl[f8b192862a939dac]::queries::collect_and_partition_mono_items, rustc_query_impl[f8b192862a939dac]::plumbing::QueryCtxt>
  37:     0x7f9308d8ab62 - <rustc_query_impl[f8b192862a939dac]::Queries as rustc_middle[7247278619f001fe]::ty::query::QueryEngine>::collect_and_partition_mono_items
  38:     0x7f9308dcd25b - rustc_codegen_ssa[553be98f56f802e0]::back::symbol_export::exported_symbols_provider_local
  39:     0x7f9308c6d5f1 - rustc_query_system[2ce65edb6101d899]::query::plumbing::try_execute_query::<rustc_query_impl[f8b192862a939dac]::plumbing::QueryCtxt, rustc_query_system[2ce65edb6101d899]::query::caches::DefaultCache<rustc_span[5318bedef2ca73b1]::def_id::CrateNum, &[(rustc_middle[7247278619f001fe]::middle::exported_symbols::ExportedSymbol, rustc_middle[7247278619f001fe]::middle::exported_symbols::SymbolExportInfo)]>>
  40:     0x7f9308c6d29a - rustc_query_system[2ce65edb6101d899]::query::plumbing::get_query::<rustc_query_impl[f8b192862a939dac]::queries::exported_symbols, rustc_query_impl[f8b192862a939dac]::plumbing::QueryCtxt>
  41:     0x7f93087f4de2 - <rustc_metadata[83b8adabf00e95da]::rmeta::encoder::EncodeContext>::encode_crate_root
  42:     0x7f930876d623 - rustc_metadata[83b8adabf00e95da]::rmeta::encoder::encode_metadata_impl
  43:     0x7f93087625fe - rustc_data_structures[1c5fb92d75ec3bdb]::sync::join::<rustc_metadata[83b8adabf00e95da]::rmeta::encoder::encode_metadata::{closure#0}, rustc_metadata[83b8adabf00e95da]::rmeta::encoder::encode_metadata::{closure#1}, (), ()>
  44:     0x7f93087624d9 - rustc_metadata[83b8adabf00e95da]::rmeta::encoder::encode_metadata
  45:     0x7f9308761686 - rustc_metadata[83b8adabf00e95da]::fs::encode_and_write_metadata
  46:     0x7f930874515c - <rustc_interface[d358214f54393a52]::passes::QueryContext>::enter::<<rustc_interface[d358214f54393a52]::queries::Queries>::ongoing_codegen::{closure#0}::{closure#0}, core[bafc4c672d35f3dc]::result::Result<alloc[cc53910b1e83d5d2]::boxed::Box<dyn core[bafc4c672d35f3dc]::any::Any>, rustc_errors[68a9913b99f4d6e1]::ErrorGuaranteed>>
  47:     0x7f930873c783 - <rustc_interface[d358214f54393a52]::queries::Queries>::ongoing_codegen
  48:     0x7f930873b821 - <rustc_interface[d358214f54393a52]::interface::Compiler>::enter::<rustc_driver[1396542de658d9ef]::run_compiler::{closure#1}::{closure#2}, core[bafc4c672d35f3dc]::result::Result<core[bafc4c672d35f3dc]::option::Option<rustc_interface[d358214f54393a52]::queries::Linker>, rustc_errors[68a9913b99f4d6e1]::ErrorGuaranteed>>
  49:     0x7f93087372ec - rustc_span[5318bedef2ca73b1]::with_source_map::<core[bafc4c672d35f3dc]::result::Result<(), rustc_errors[68a9913b99f4d6e1]::ErrorGuaranteed>, rustc_interface[d358214f54393a52]::interface::create_compiler_and_run<core[bafc4c672d35f3dc]::result::Result<(), rustc_errors[68a9913b99f4d6e1]::ErrorGuaranteed>, rustc_driver[1396542de658d9ef]::run_compiler::{closure#1}>::{closure#1}>
  50:     0x7f9308736cd2 - rustc_interface[d358214f54393a52]::interface::create_compiler_and_run::<core[bafc4c672d35f3dc]::result::Result<(), rustc_errors[68a9913b99f4d6e1]::ErrorGuaranteed>, rustc_driver[1396542de658d9ef]::run_compiler::{closure#1}>
  51:     0x7f9308735871 - <scoped_tls[cc0aafcf1c0b5a7f]::ScopedKey<rustc_span[5318bedef2ca73b1]::SessionGlobals>>::set::<rustc_interface[d358214f54393a52]::interface::run_compiler<core[bafc4c672d35f3dc]::result::Result<(), rustc_errors[68a9913b99f4d6e1]::ErrorGuaranteed>, rustc_driver[1396542de658d9ef]::run_compiler::{closure#1}>::{closure#0}, core[bafc4c672d35f3dc]::result::Result<(), rustc_errors[68a9913b99f4d6e1]::ErrorGuaranteed>>
  52:     0x7f930873555f - std[e6e0e56adfd51cea]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[d358214f54393a52]::util::run_in_thread_pool_with_globals<rustc_interface[d358214f54393a52]::interface::run_compiler<core[bafc4c672d35f3dc]::result::Result<(), rustc_errors[68a9913b99f4d6e1]::ErrorGuaranteed>, rustc_driver[1396542de658d9ef]::run_compiler::{closure#1}>::{closure#0}, core[bafc4c672d35f3dc]::result::Result<(), rustc_errors[68a9913b99f4d6e1]::ErrorGuaranteed>>::{closure#0}, core[bafc4c672d35f3dc]::result::Result<(), rustc_errors[68a9913b99f4d6e1]::ErrorGuaranteed>>
  53:     0x7f9308e4d2e9 - <<std[e6e0e56adfd51cea]::thread::Builder>::spawn_unchecked_<rustc_interface[d358214f54393a52]::util::run_in_thread_pool_with_globals<rustc_interface[d358214f54393a52]::interface::run_compiler<core[bafc4c672d35f3dc]::result::Result<(), rustc_errors[68a9913b99f4d6e1]::ErrorGuaranteed>, rustc_driver[1396542de658d9ef]::run_compiler::{closure#1}>::{closure#0}, core[bafc4c672d35f3dc]::result::Result<(), rustc_errors[68a9913b99f4d6e1]::ErrorGuaranteed>>::{closure#0}, core[bafc4c672d35f3dc]::result::Result<(), rustc_errors[68a9913b99f4d6e1]::ErrorGuaranteed>>::{closure#1} as core[bafc4c672d35f3dc]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  54:     0x7f93067f78b3 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h153a5b9c09be8d12
                               at /rustc/c0941dfb5a7d07ef2d70cc54d319669d9d6f6c01/library/alloc/src/boxed.rs:1935:9
  55:     0x7f93067f78b3 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h50171cd485c6ebe5
                               at /rustc/c0941dfb5a7d07ef2d70cc54d319669d9d6f6c01/library/alloc/src/boxed.rs:1935:9
  56:     0x7f93067f78b3 - std::sys::unix::thread::Thread::new::thread_start::h1d58b0ea990239e8
                               at /rustc/c0941dfb5a7d07ef2d70cc54d319669d9d6f6c01/library/std/src/sys/unix/thread.rs:108:17
  57:     0x7f93066cf609 - start_thread
  58:     0x7f93065f2163 - clone
  59:                0x0 - <unknown>

error: internal compiler error: unexpected panic

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 (c0941dfb5 2022-08-21) running on x86_64-unknown-linux-gnu

note: compiler flags: -C debuginfo=1 -C llvm-args=--x86-asm-syntax=intel --crate-type rlib

query stack during panic:
#0 [mir_drops_elaborated_and_const_checked] elaborating drops for `get_u16_from_unaligned_manual`
#1 [optimized_mir] optimizing MIR for `get_u16_from_unaligned_manual`
#2 [collect_and_partition_mono_items] collect_and_partition_mono_items
#3 [exported_symbols] exported_symbols
end of query stack


Bisection

searched nightlies: from nightly-2022-02-19 to nightly-2022-04-04
regressed nightly: nightly-2022-03-25
searched commit range: 9f4dc0b...63b8f01
regressed commit: 63b8f01

bisected with cargo-bisect-rustc v0.6.4

Host triple: x86_64-unknown-linux-gnu
Reproduce with:

cargo bisect-rustc --start 1.60.0 --end 1.61.0 --prompt -- build 

Originally reported at https://t.me/rustlang_it/142123

@paolobarbolini paolobarbolini 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 Aug 22, 2022
@chenyukang
Copy link
Member

@rustbot claim

@matthiaskrgr
Copy link
Member

This seems to be fixed in latest nightly?

error: this arithmetic operation will overflow
 --> fixed/100878.rs:3:5
  |
3 |     data[0] << 8
  |     ^^^^^^^^^^^^ attempt to shift left by `8_i32`, which would overflow
  |
  = note: `#[deny(arithmetic_overflow)]` on by default

error: aborting due to previous error

@matthiaskrgr matthiaskrgr added the E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. label Aug 28, 2022
@chenyukang
Copy link
Member

Yes, it's fixed in nightly.

@chenyukang chenyukang removed their assignment Sep 18, 2022
@inquisitivecrystal
Copy link
Contributor

inquisitivecrystal commented Sep 23, 2022

As a note, the ICE was fixed by #100043 (confirmed by cargo-bisect-rustc).

@inquisitivecrystal inquisitivecrystal added the A-const-eval Area: Constant evaluation (MIR interpretation) label Sep 23, 2022
inquisitivecrystal added a commit to inquisitivecrystal/rust that referenced this issue Sep 23, 2022
fee1-dead added a commit to fee1-dead-contrib/rust that referenced this issue Sep 26, 2022
…st, r=Mark-Simulacrum

Add regression test

This adds a regression test for issue rust-lang#100878.

Closes rust-lang#100878.
@bors bors closed this as completed in 0857dde Sep 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-const-eval Area: Constant evaluation (MIR interpretation) 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. 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
Development

Successfully merging a pull request may close this issue.

4 participants