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

dyn* ICE primitive read not possible for type: [i32; 4] #102173

Closed
Tracked by #102425
DutchGhost opened this issue Sep 23, 2022 · 1 comment · Fixed by #104338
Closed
Tracked by #102425

dyn* ICE primitive read not possible for type: [i32; 4] #102173

DutchGhost opened this issue Sep 23, 2022 · 1 comment · Fixed by #104338
Assignees
Labels
C-bug Category: This is a bug. F-dyn_star `#![feature(dyn_star)]` 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. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@DutchGhost
Copy link
Contributor

Code

#![feature(dyn_star)]
#![allow(incomplete_features)]

use core::fmt::Debug;

fn main() {
    let i = [1, 2, 3, 4] as dyn* Debug;
    
    dbg!(i);
}

Meta

rustc --version --verbose:

rustc 1.66.0-nightly (e7119a030 2022-09-22)

Error output

[<output>](error: internal compiler error: /rustc/e7119a0300b87a3d670408ee8e847c6821b3ae80/compiler/rustc_const_eval/src/interpret/operand.rs:390:13: primitive read not possible for type: [i32; 4])
Backtrace

error: internal compiler error: /rustc/e7119a0300b87a3d670408ee8e847c6821b3ae80/compiler/rustc_const_eval/src/interpret/operand.rs:390:13: primitive read not possible for type: [i32; 4]
 --> src/main.rs:7:13
  |
7 |     let i = [1, 2, 3, 4] as dyn* Debug;
  |             ^^^^^^^^^^^^^^^^^^^^^^^^^^

thread 'rustc' panicked at 'Box<dyn Any>', /rustc/e7119a0300b87a3d670408ee8e847c6821b3ae80/compiler/rustc_errors/src/lib.rs:1434:9
stack backtrace:
   0:     0x7f024ef53ff0 - std::backtrace_rs::backtrace::libunwind::trace::hf4e04b2e4313927b
                               at /rustc/e7119a0300b87a3d670408ee8e847c6821b3ae80/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   1:     0x7f024ef53ff0 - std::backtrace_rs::backtrace::trace_unsynchronized::h2771cf061d4680d1
                               at /rustc/e7119a0300b87a3d670408ee8e847c6821b3ae80/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7f024ef53ff0 - std::sys_common::backtrace::_print_fmt::h2e413508900ead1c
                               at /rustc/e7119a0300b87a3d670408ee8e847c6821b3ae80/library/std/src/sys_common/backtrace.rs:66:5
   3:     0x7f024ef53ff0 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::hb886319318f6b897
                               at /rustc/e7119a0300b87a3d670408ee8e847c6821b3ae80/library/std/src/sys_common/backtrace.rs:45:22
   4:     0x7f024efaee1e - core::fmt::write::hd7350cb51945e18c
                               at /rustc/e7119a0300b87a3d670408ee8e847c6821b3ae80/library/core/src/fmt/mod.rs:1202:17
   5:     0x7f024ef44af5 - std::io::Write::write_fmt::ha7bc763f922fc662
                               at /rustc/e7119a0300b87a3d670408ee8e847c6821b3ae80/library/std/src/io/mod.rs:1679:15
   6:     0x7f024ef56d73 - std::sys_common::backtrace::_print::h7ad0003e1b032609
                               at /rustc/e7119a0300b87a3d670408ee8e847c6821b3ae80/library/std/src/sys_common/backtrace.rs:48:5
   7:     0x7f024ef56d73 - std::sys_common::backtrace::print::h6f247b59322d4826
                               at /rustc/e7119a0300b87a3d670408ee8e847c6821b3ae80/library/std/src/sys_common/backtrace.rs:35:9
   8:     0x7f024ef56d73 - std::panicking::default_hook::{{closure}}::h71a394bfa368bc38
                               at /rustc/e7119a0300b87a3d670408ee8e847c6821b3ae80/library/std/src/panicking.rs:267:22
   9:     0x7f024ef56a5f - std::panicking::default_hook::h353829743ca9a29f
                               at /rustc/e7119a0300b87a3d670408ee8e847c6821b3ae80/library/std/src/panicking.rs:286:9
  10:     0x7f025176cef1 - <rustc_driver[7857f239df018eab]::DEFAULT_HOOK::{closure#0}::{closure#0} as core[cde1ce9e21f08391]::ops::function::FnOnce<(&core[cde1ce9e21f08391]::panic::panic_info::PanicInfo,)>>::call_once::{shim:vtable#0}
  11:     0x7f024ef575ab - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::h5c7ac9f6a4be07e2
                               at /rustc/e7119a0300b87a3d670408ee8e847c6821b3ae80/library/alloc/src/boxed.rs:1954:9
  12:     0x7f024ef575ab - std::panicking::rust_panic_with_hook::h6ad4960c15699d95
                               at /rustc/e7119a0300b87a3d670408ee8e847c6821b3ae80/library/std/src/panicking.rs:673:13
  13:     0x7f02519f5b21 - std[35bb8192b5670ad2]::panicking::begin_panic::<rustc_errors[354c2d440e1385ac]::ExplicitBug>::{closure#0}
  14:     0x7f02519f41c6 - std[35bb8192b5670ad2]::sys_common::backtrace::__rust_end_short_backtrace::<std[35bb8192b5670ad2]::panicking::begin_panic<rustc_errors[354c2d440e1385ac]::ExplicitBug>::{closure#0}, !>
  15:     0x7f0251976536 - std[35bb8192b5670ad2]::panicking::begin_panic::<rustc_errors[354c2d440e1385ac]::ExplicitBug>
  16:     0x7f0251a1f4a6 - std[35bb8192b5670ad2]::panic::panic_any::<rustc_errors[354c2d440e1385ac]::ExplicitBug>
  17:     0x7f0251a1eedf - <rustc_errors[354c2d440e1385ac]::HandlerInner>::span_bug::<rustc_span[4a0a9e8ceb64f0f4]::span_encoding::Span, &alloc[70f1755a93720895]::string::String>
  18:     0x7f0251a1ec60 - <rustc_errors[354c2d440e1385ac]::Handler>::span_bug::<rustc_span[4a0a9e8ceb64f0f4]::span_encoding::Span, &alloc[70f1755a93720895]::string::String>
  19:     0x7f0251a4c3e8 - rustc_middle[33a3dc3ec8228005]::ty::context::tls::with_context_opt::<rustc_middle[33a3dc3ec8228005]::ty::context::tls::with_opt<rustc_middle[33a3dc3ec8228005]::util::bug::opt_span_bug_fmt<rustc_span[4a0a9e8ceb64f0f4]::span_encoding::Span>::{closure#0}, ()>::{closure#0}, ()>
  20:     0x7f0251a4b906 - rustc_middle[33a3dc3ec8228005]::util::bug::opt_span_bug_fmt::<rustc_span[4a0a9e8ceb64f0f4]::span_encoding::Span>
  21:     0x7f0251a4b8c4 - rustc_middle[33a3dc3ec8228005]::util::bug::span_bug_fmt::<rustc_span[4a0a9e8ceb64f0f4]::span_encoding::Span>
  22:     0x7f0250e15e82 - <rustc_const_eval[4d5bd7e7607305c4]::interpret::eval_context::InterpCx<rustc_mir_transform[38a49b1d59d53461]::const_prop::ConstPropMachine>>::eval_rvalue_into_place
  23:     0x7f0250bb10c2 - <rustc_mir_transform[38a49b1d59d53461]::const_prop_lint::ConstPropagator as rustc_middle[33a3dc3ec8228005]::mir::visit::Visitor>::visit_body
  24:     0x7f0250ba8c03 - <rustc_mir_transform[38a49b1d59d53461]::const_prop_lint::ConstProp as rustc_mir_transform[38a49b1d59d53461]::pass_manager::MirLint>::run_lint
  25:     0x7f02503013e5 - rustc_mir_transform[38a49b1d59d53461]::pass_manager::run_passes_no_validate
  26:     0x7f02502fe684 - rustc_mir_transform[38a49b1d59d53461]::run_analysis_to_runtime_passes
  27:     0x7f02502fd692 - rustc_mir_transform[38a49b1d59d53461]::mir_drops_elaborated_and_const_checked
  28:     0x7f0250d526a3 - rustc_query_system[d3b2657d85679091]::query::plumbing::try_execute_query::<rustc_query_impl[542bbd4b66bfb449]::plumbing::QueryCtxt, rustc_query_system[d3b2657d85679091]::query::caches::DefaultCache<rustc_middle[33a3dc3ec8228005]::ty::WithOptConstParam<rustc_span[4a0a9e8ceb64f0f4]::def_id::LocalDefId>, &rustc_data_structures[bf19c7e493ef6519]::steal::Steal<rustc_middle[33a3dc3ec8228005]::mir::Body>>>
  29:     0x7f02516ad28e - <rustc_query_impl[542bbd4b66bfb449]::Queries as rustc_middle[33a3dc3ec8228005]::ty::query::QueryEngine>::mir_drops_elaborated_and_const_checked
  30:     0x7f025035b3cb - rustc_mir_transform[38a49b1d59d53461]::optimized_mir
  31:     0x7f0250b744eb - rustc_query_system[d3b2657d85679091]::query::plumbing::try_execute_query::<rustc_query_impl[542bbd4b66bfb449]::plumbing::QueryCtxt, rustc_query_system[d3b2657d85679091]::query::caches::DefaultCache<rustc_span[4a0a9e8ceb64f0f4]::def_id::DefId, &rustc_middle[33a3dc3ec8228005]::mir::Body>>
  32:     0x7f02516ad67f - <rustc_query_impl[542bbd4b66bfb449]::Queries as rustc_middle[33a3dc3ec8228005]::ty::query::QueryEngine>::optimized_mir
  33:     0x7f02503a5735 - <rustc_middle[33a3dc3ec8228005]::ty::context::TyCtxt>::instance_mir
  34:     0x7f025039ab3c - rustc_monomorphize[807358ae657c971c]::collector::collect_neighbours
  35:     0x7f02503986d2 - rustc_monomorphize[807358ae657c971c]::collector::collect_items_rec
  36:     0x7f0250ee534d - <rustc_session[fa757ff4c2b8954a]::session::Session>::time::<(), rustc_monomorphize[807358ae657c971c]::collector::collect_crate_mono_items::{closure#1}>
  37:     0x7f0250ee4ed9 - rustc_monomorphize[807358ae657c971c]::collector::collect_crate_mono_items
  38:     0x7f0250ee3dc6 - rustc_monomorphize[807358ae657c971c]::partitioning::collect_and_partition_mono_items
  39:     0x7f025151c4a9 - rustc_query_system[d3b2657d85679091]::query::plumbing::try_execute_query::<rustc_query_impl[542bbd4b66bfb449]::plumbing::QueryCtxt, rustc_query_system[d3b2657d85679091]::query::caches::DefaultCache<(), (&std[35bb8192b5670ad2]::collections::hash::set::HashSet<rustc_span[4a0a9e8ceb64f0f4]::def_id::DefId, core[cde1ce9e21f08391]::hash::BuildHasherDefault<rustc_hash[56467a0a1e3e166e]::FxHasher>>, &[rustc_middle[33a3dc3ec8228005]::mir::mono::CodegenUnit])>>
  40:     0x7f025151c19b - rustc_query_system[d3b2657d85679091]::query::plumbing::get_query::<rustc_query_impl[542bbd4b66bfb449]::queries::collect_and_partition_mono_items, rustc_query_impl[542bbd4b66bfb449]::plumbing::QueryCtxt>
  41:     0x7f025151c0de - <rustc_query_impl[542bbd4b66bfb449]::Queries as rustc_middle[33a3dc3ec8228005]::ty::query::QueryEngine>::collect_and_partition_mono_items
  42:     0x7f0251263712 - rustc_codegen_ssa[2a18cf2abb0e25f]::base::codegen_crate::<rustc_codegen_llvm[1c20db9e7afb2165]::LlvmCodegenBackend>
  43:     0x7f02512634e2 - <rustc_codegen_llvm[1c20db9e7afb2165]::LlvmCodegenBackend as rustc_codegen_ssa[2a18cf2abb0e25f]::traits::backend::CodegenBackend>::codegen_crate
  44:     0x7f025053f7dc - <rustc_session[fa757ff4c2b8954a]::session::Session>::time::<alloc[70f1755a93720895]::boxed::Box<dyn core[cde1ce9e21f08391]::any::Any>, rustc_interface[f2560d97934cc6f6]::passes::start_codegen::{closure#0}>
  45:     0x7f025053f1ae - <rustc_interface[f2560d97934cc6f6]::passes::QueryContext>::enter::<<rustc_interface[f2560d97934cc6f6]::queries::Queries>::ongoing_codegen::{closure#0}::{closure#0}, core[cde1ce9e21f08391]::result::Result<alloc[70f1755a93720895]::boxed::Box<dyn core[cde1ce9e21f08391]::any::Any>, rustc_errors[354c2d440e1385ac]::ErrorGuaranteed>>
  46:     0x7f02504ff6d3 - <rustc_interface[f2560d97934cc6f6]::queries::Queries>::ongoing_codegen
  47:     0x7f02504fda4a - rustc_interface[f2560d97934cc6f6]::interface::create_compiler_and_run::<core[cde1ce9e21f08391]::result::Result<(), rustc_errors[354c2d440e1385ac]::ErrorGuaranteed>, rustc_driver[7857f239df018eab]::run_compiler::{closure#1}>
  48:     0x7f02504fc342 - <scoped_tls[8ee1aa185b4607e2]::ScopedKey<rustc_span[4a0a9e8ceb64f0f4]::SessionGlobals>>::set::<rustc_interface[f2560d97934cc6f6]::interface::run_compiler<core[cde1ce9e21f08391]::result::Result<(), rustc_errors[354c2d440e1385ac]::ErrorGuaranteed>, rustc_driver[7857f239df018eab]::run_compiler::{closure#1}>::{closure#0}, core[cde1ce9e21f08391]::result::Result<(), rustc_errors[354c2d440e1385ac]::ErrorGuaranteed>>
  49:     0x7f02504fc02f - std[35bb8192b5670ad2]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[f2560d97934cc6f6]::util::run_in_thread_pool_with_globals<rustc_interface[f2560d97934cc6f6]::interface::run_compiler<core[cde1ce9e21f08391]::result::Result<(), rustc_errors[354c2d440e1385ac]::ErrorGuaranteed>, rustc_driver[7857f239df018eab]::run_compiler::{closure#1}>::{closure#0}, core[cde1ce9e21f08391]::result::Result<(), rustc_errors[354c2d440e1385ac]::ErrorGuaranteed>>::{closure#0}, core[cde1ce9e21f08391]::result::Result<(), rustc_errors[354c2d440e1385ac]::ErrorGuaranteed>>
  50:     0x7f02515d1980 - <<std[35bb8192b5670ad2]::thread::Builder>::spawn_unchecked_<rustc_interface[f2560d97934cc6f6]::util::run_in_thread_pool_with_globals<rustc_interface[f2560d97934cc6f6]::interface::run_compiler<core[cde1ce9e21f08391]::result::Result<(), rustc_errors[354c2d440e1385ac]::ErrorGuaranteed>, rustc_driver[7857f239df018eab]::run_compiler::{closure#1}>::{closure#0}, core[cde1ce9e21f08391]::result::Result<(), rustc_errors[354c2d440e1385ac]::ErrorGuaranteed>>::{closure#0}, core[cde1ce9e21f08391]::result::Result<(), rustc_errors[354c2d440e1385ac]::ErrorGuaranteed>>::{closure#1} as core[cde1ce9e21f08391]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  51:     0x7f024ef61393 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hbe492c93bea3125c
                               at /rustc/e7119a0300b87a3d670408ee8e847c6821b3ae80/library/alloc/src/boxed.rs:1940:9
  52:     0x7f024ef61393 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h1c6cb812ee67c431
                               at /rustc/e7119a0300b87a3d670408ee8e847c6821b3ae80/library/alloc/src/boxed.rs:1940:9
  53:     0x7f024ef61393 - std::sys::unix::thread::Thread::new::thread_start::hcd53b5f11cecf106
                               at /rustc/e7119a0300b87a3d670408ee8e847c6821b3ae80/library/std/src/sys/unix/thread.rs:108:17
  54:     0x7f024ee34609 - start_thread
  55:     0x7f024ed57133 - clone
  56:                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 (e7119a030 2022-09-22) running on x86_64-unknown-linux-gnu

note: compiler flags: --crate-type bin -C embed-bitcode=no -C codegen-units=1 -C debuginfo=2

note: some of the compiler flags provided by cargo are hidden

query stack during panic:
#0 [mir_drops_elaborated_and_const_checked] elaborating drops for `main`
#1 [optimized_mir] optimizing MIR for `main`
#2 [collect_and_partition_mono_items] collect_and_partition_mono_items
end of query stack
error: could not compile `playground`

@DutchGhost DutchGhost 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 Sep 23, 2022
@DutchGhost DutchGhost changed the title dyn* ICE dyn* ICE primitive read not possible for type: [i32; 4] Sep 23, 2022
@crlf0710 crlf0710 added the F-dyn_star `#![feature(dyn_star)]` label Sep 23, 2022
@inquisitivecrystal inquisitivecrystal added the requires-nightly This issue requires a nightly compiler in some way. label Sep 24, 2022
@eholk
Copy link
Contributor

eholk commented Sep 28, 2022

Thanks for the report!

This test case should not compile because only things that are pointer sized can be converted to dyn*. But, we definitely need a proper error message rather than an ICE.

@rust-lang-glacier-bot rust-lang-glacier-bot added the glacier ICE tracked in rust-lang/glacier. label Oct 1, 2022
@TaKO8Ki TaKO8Ki self-assigned this Oct 2, 2022
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Nov 16, 2022
…holk

Enforce that `dyn*` coercions are actually pointer-sized

Implement a perma-unstable, rudimentary `PointerSized` trait to enforce `dyn*` casts are `usize`-sized for now, at least to prevent ICEs and weird codegen issues from cropping up after monomorphization since currently we enforce *nothing*.

This probably can/should be removed in favor of a more sophisticated trait for handling `dyn*` conversions when we decide on one, but I just want to get something up for discussion and experimentation for now.

r? `@eholk` cc `@tmandry` (though feel free to claim/reassign)

Fixes rust-lang#102141
Fixes rust-lang#102173
Manishearth added a commit to Manishearth/rust that referenced this issue Nov 18, 2022
…holk

Enforce that `dyn*` coercions are actually pointer-sized

Implement a perma-unstable, rudimentary `PointerSized` trait to enforce `dyn*` casts are `usize`-sized for now, at least to prevent ICEs and weird codegen issues from cropping up after monomorphization since currently we enforce *nothing*.

This probably can/should be removed in favor of a more sophisticated trait for handling `dyn*` conversions when we decide on one, but I just want to get something up for discussion and experimentation for now.

r? `@eholk` cc `@tmandry` (though feel free to claim/reassign)

Fixes rust-lang#102141
Fixes rust-lang#102173
Manishearth added a commit to Manishearth/rust that referenced this issue Nov 18, 2022
…holk

Enforce that `dyn*` coercions are actually pointer-sized

Implement a perma-unstable, rudimentary `PointerSized` trait to enforce `dyn*` casts are `usize`-sized for now, at least to prevent ICEs and weird codegen issues from cropping up after monomorphization since currently we enforce *nothing*.

This probably can/should be removed in favor of a more sophisticated trait for handling `dyn*` conversions when we decide on one, but I just want to get something up for discussion and experimentation for now.

r? ``@eholk`` cc ``@tmandry`` (though feel free to claim/reassign)

Fixes rust-lang#102141
Fixes rust-lang#102173
@bors bors closed this as completed in 24ee599 Nov 19, 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. F-dyn_star `#![feature(dyn_star)]` 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. 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