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: dereferencing Adt(..) #115789

Closed
matthiaskrgr opened this issue Sep 12, 2023 · 1 comment · Fixed by #115794
Closed

ICE: dereferencing Adt(..) #115789

matthiaskrgr opened this issue Sep 12, 2023 · 1 comment · Fixed by #115794
Labels
A-mir-opt Area: MIR optimizations 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.

Comments

@matthiaskrgr
Copy link
Member

Code

rustc -Zmir-opt-level=3

#[derive(Default)]
struct A {
    foo: Box<[bool]>,
}

pub fn main() {
    let a: A = Default::default();
}

Meta

rustc --version --verbose:

rustc 1.74.0-nightly (5f6ee65f5 2023-09-12)
binary: rustc
commit-hash: 5f6ee65f594f59f64c7957dcad90edc0b8830284
commit-date: 2023-09-12
host: x86_64-unknown-linux-gnu
release: 1.74.0-nightly
LLVM version: 17.0.0

Error output

warning: unused variable: `a`
 --> deriving-default-box.rs:7:9
  |
7 |     let a: A = Default::default();
  |         ^ help: if this is intentional, prefix it with an underscore: `_a`
  |
  = note: `#[warn(unused_variables)]` on by default

warning: field `foo` is never read
 --> deriving-default-box.rs:3:5
  |
2 | struct A {
  |        - field in this struct
3 |     foo: Box<[bool]>,
  |     ^^^
  |
  = note: `#[warn(dead_code)]` on by default
Backtrace

error: internal compiler error: /rustc/5f6ee65f594f59f64c7957dcad90edc0b8830284/compiler/rustc_const_eval/src/interpret/place.rs:459:13: dereferencing Adt(std::boxed::Box, [[bool], Adt(std::alloc::Global, [])])

thread 'rustc' panicked at /rustc/5f6ee65f594f59f64c7957dcad90edc0b8830284/compiler/rustc_errors/src/lib.rs:1651:9:
Box<dyn Any>
stack backtrace:
   0:     0x7f9293762efc - std::backtrace_rs::backtrace::libunwind::trace::h55359a43d1951496
                               at /rustc/5f6ee65f594f59f64c7957dcad90edc0b8830284/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
   1:     0x7f9293762efc - std::backtrace_rs::backtrace::trace_unsynchronized::hda60d3b694a048da
                               at /rustc/5f6ee65f594f59f64c7957dcad90edc0b8830284/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7f9293762efc - std::sys_common::backtrace::_print_fmt::hcaa923c54f0b748c
                               at /rustc/5f6ee65f594f59f64c7957dcad90edc0b8830284/library/std/src/sys_common/backtrace.rs:67:5
   3:     0x7f9293762efc - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::hca7b9c7634bb6a2d
                               at /rustc/5f6ee65f594f59f64c7957dcad90edc0b8830284/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x7f92937c915c - core::fmt::rt::Argument::fmt::h7e480ad4000d1ede
                               at /rustc/5f6ee65f594f59f64c7957dcad90edc0b8830284/library/core/src/fmt/rt.rs:138:9
   5:     0x7f92937c915c - core::fmt::write::h40ba427150be4d5d
                               at /rustc/5f6ee65f594f59f64c7957dcad90edc0b8830284/library/core/src/fmt/mod.rs:1094:21
   6:     0x7f929375593e - std::io::Write::write_fmt::h07c5cdbac563b1a2
                               at /rustc/5f6ee65f594f59f64c7957dcad90edc0b8830284/library/std/src/io/mod.rs:1714:15
   7:     0x7f9293762ce4 - std::sys_common::backtrace::_print::h8043b2171f37ee3c
                               at /rustc/5f6ee65f594f59f64c7957dcad90edc0b8830284/library/std/src/sys_common/backtrace.rs:47:5
   8:     0x7f9293762ce4 - std::sys_common::backtrace::print::hf8d132542a9b3f6f
                               at /rustc/5f6ee65f594f59f64c7957dcad90edc0b8830284/library/std/src/sys_common/backtrace.rs:34:9
   9:     0x7f9293765dda - std::panicking::panic_hook_with_disk_dump::{{closure}}::hdcac91a615e070a2
                               at /rustc/5f6ee65f594f59f64c7957dcad90edc0b8830284/library/std/src/panicking.rs:280:22
  10:     0x7f9293765ad5 - std::panicking::panic_hook_with_disk_dump::hbcae72cec2baf967
                               at /rustc/5f6ee65f594f59f64c7957dcad90edc0b8830284/library/std/src/panicking.rs:314:9
  11:     0x7f929693b599 - rustc_driver_impl[43bd6da197b49f55]::install_ice_hook::{closure#0}
  12:     0x7f9293766693 - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::hc4f47c97a460cd11
                               at /rustc/5f6ee65f594f59f64c7957dcad90edc0b8830284/library/alloc/src/boxed.rs:2021:9
  13:     0x7f9293766693 - std::panicking::rust_panic_with_hook::h109420236226f3ee
                               at /rustc/5f6ee65f594f59f64c7957dcad90edc0b8830284/library/std/src/panicking.rs:757:13
  14:     0x7f9296ea4734 - std[7db58085941d9bac]::panicking::begin_panic::<rustc_errors[c1b6cc29bebdb6ab]::ExplicitBug>::{closure#0}
  15:     0x7f9296ea2f96 - std[7db58085941d9bac]::sys_common::backtrace::__rust_end_short_backtrace::<std[7db58085941d9bac]::panicking::begin_panic<rustc_errors[c1b6cc29bebdb6ab]::ExplicitBug>::{closure#0}, !>
  16:     0x7f9296e441b6 - std[7db58085941d9bac]::panicking::begin_panic::<rustc_errors[c1b6cc29bebdb6ab]::ExplicitBug>
  17:     0x7f9296ebc884 - <rustc_errors[c1b6cc29bebdb6ab]::HandlerInner>::bug::<alloc[1d0d6505afdbca5c]::string::String>
  18:     0x7f9296ebc744 - <rustc_errors[c1b6cc29bebdb6ab]::Handler>::bug::<alloc[1d0d6505afdbca5c]::string::String>
  19:     0x7f9296f006cc - rustc_middle[29c00dc8642989c6]::util::bug::opt_span_bug_fmt::<rustc_span[30e21d5074f476ed]::span_encoding::Span>::{closure#0}
  20:     0x7f9296efd00a - rustc_middle[29c00dc8642989c6]::ty::context::tls::with_opt::<rustc_middle[29c00dc8642989c6]::util::bug::opt_span_bug_fmt<rustc_span[30e21d5074f476ed]::span_encoding::Span>::{closure#0}, !>::{closure#0}
  21:     0x7f9296efcfd8 - rustc_middle[29c00dc8642989c6]::ty::context::tls::with_context_opt::<rustc_middle[29c00dc8642989c6]::ty::context::tls::with_opt<rustc_middle[29c00dc8642989c6]::util::bug::opt_span_bug_fmt<rustc_span[30e21d5074f476ed]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
  22:     0x7f929536fdd0 - rustc_middle[29c00dc8642989c6]::util::bug::bug_fmt
  23:     0x7f92970f4dd8 - <rustc_const_eval[359a46a105bbed5a]::interpret::eval_context::InterpCx<rustc_mir_transform[95c4ccea1ed9f734]::dataflow_const_prop::DummyMachine>>::deref_pointer::<rustc_const_eval[359a46a105bbed5a]::interpret::operand::OpTy>
  24:     0x7f92970b0af5 - <rustc_mir_transform[95c4ccea1ed9f734]::dataflow_const_prop::ConstAnalysis>::assign_constant::{closure#0}
  25:     0x7f92970a1bc2 - <rustc_mir_dataflow[1ae8acabcb9c35eb]::value_analysis::Map>::for_each_projection_value::<rustc_const_eval[359a46a105bbed5a]::interpret::operand::OpTy, <rustc_mir_transform[95c4ccea1ed9f734]::dataflow_const_prop::ConstAnalysis>::assign_constant::{closure#0}, <rustc_mir_transform[95c4ccea1ed9f734]::dataflow_const_prop::ConstAnalysis>::assign_constant::{closure#1}>
  26:     0x7f92970e6990 - <rustc_mir_transform[95c4ccea1ed9f734]::dataflow_const_prop::ConstAnalysis>::assign_constant
  27:     0x7f92970e3c85 - <rustc_mir_transform[95c4ccea1ed9f734]::dataflow_const_prop::ConstAnalysis>::assign_operand
  28:     0x7f92970b675a - <rustc_mir_dataflow[1ae8acabcb9c35eb]::framework::engine::Engine<rustc_mir_dataflow[1ae8acabcb9c35eb]::value_analysis::ValueAnalysisWrapper<rustc_mir_transform[95c4ccea1ed9f734]::dataflow_const_prop::ConstAnalysis>>>::iterate_to_fixpoint
  29:     0x7f929704c9d5 - <tracing[f2b2d97559c71f19]::span::Span>::in_scope::<<rustc_mir_transform[95c4ccea1ed9f734]::dataflow_const_prop::DataflowConstProp as rustc_middle[29c00dc8642989c6]::mir::MirPass>::run_pass::{closure#0}, rustc_mir_dataflow[1ae8acabcb9c35eb]::framework::engine::Results<rustc_mir_dataflow[1ae8acabcb9c35eb]::value_analysis::ValueAnalysisWrapper<rustc_mir_transform[95c4ccea1ed9f734]::dataflow_const_prop::ConstAnalysis>, rustc_index[ee8d55f91f439666]::vec::IndexVec<rustc_middle[29c00dc8642989c6]::mir::BasicBlock, rustc_mir_dataflow[1ae8acabcb9c35eb]::value_analysis::State<rustc_mir_dataflow[1ae8acabcb9c35eb]::framework::lattice::FlatSet<rustc_middle[29c00dc8642989c6]::mir::interpret::value::Scalar>>>>>
  30:     0x7f92970e6620 - <rustc_mir_transform[95c4ccea1ed9f734]::dataflow_const_prop::DataflowConstProp as rustc_middle[29c00dc8642989c6]::mir::MirPass>::run_pass
  31:     0x7f9295875b0d - rustc_mir_transform[95c4ccea1ed9f734]::pass_manager::run_passes
  32:     0x7f9295875147 - rustc_mir_transform[95c4ccea1ed9f734]::optimized_mir
  33:     0x7f9294a97618 - rustc_query_impl[bf10786a05429046]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[bf10786a05429046]::query_impl::optimized_mir::dynamic_query::{closure#2}::{closure#0}, rustc_middle[29c00dc8642989c6]::query::erase::Erased<[u8; 8usize]>>
  34:     0x7f9294a975e1 - <rustc_query_impl[bf10786a05429046]::query_impl::optimized_mir::dynamic_query::{closure#2} as core[22cc6ecfdb6bcca5]::ops::function::FnOnce<(rustc_middle[29c00dc8642989c6]::ty::context::TyCtxt, rustc_span[30e21d5074f476ed]::def_id::DefId)>>::call_once
  35:     0x7f9294a4d160 - rustc_query_system[9effd60937474be5]::query::plumbing::try_execute_query::<rustc_query_impl[bf10786a05429046]::DynamicConfig<rustc_query_system[9effd60937474be5]::query::caches::DefaultCache<rustc_span[30e21d5074f476ed]::def_id::DefId, rustc_middle[29c00dc8642989c6]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[bf10786a05429046]::plumbing::QueryCtxt, false>
  36:     0x7f92962c7682 - rustc_query_impl[bf10786a05429046]::query_impl::optimized_mir::get_query_non_incr::__rust_end_short_backtrace
  37:     0x7f9294d0e190 - <rustc_middle[29c00dc8642989c6]::ty::context::TyCtxt>::instance_mir
  38:     0x7f9295967087 - <rustc_mir_transform[95c4ccea1ed9f734]::inline::Inliner>::try_inlining
  39:     0x7f9295966513 - <rustc_mir_transform[95c4ccea1ed9f734]::inline::Inliner>::process_blocks
  40:     0x7f9295965f04 - <rustc_mir_transform[95c4ccea1ed9f734]::inline::Inline as rustc_middle[29c00dc8642989c6]::mir::MirPass>::run_pass
  41:     0x7f9295875b0d - rustc_mir_transform[95c4ccea1ed9f734]::pass_manager::run_passes
  42:     0x7f9295875147 - rustc_mir_transform[95c4ccea1ed9f734]::optimized_mir
  43:     0x7f9294a97618 - rustc_query_impl[bf10786a05429046]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[bf10786a05429046]::query_impl::optimized_mir::dynamic_query::{closure#2}::{closure#0}, rustc_middle[29c00dc8642989c6]::query::erase::Erased<[u8; 8usize]>>
  44:     0x7f9294a975e1 - <rustc_query_impl[bf10786a05429046]::query_impl::optimized_mir::dynamic_query::{closure#2} as core[22cc6ecfdb6bcca5]::ops::function::FnOnce<(rustc_middle[29c00dc8642989c6]::ty::context::TyCtxt, rustc_span[30e21d5074f476ed]::def_id::DefId)>>::call_once
  45:     0x7f9294a4d160 - rustc_query_system[9effd60937474be5]::query::plumbing::try_execute_query::<rustc_query_impl[bf10786a05429046]::DynamicConfig<rustc_query_system[9effd60937474be5]::query::caches::DefaultCache<rustc_span[30e21d5074f476ed]::def_id::DefId, rustc_middle[29c00dc8642989c6]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[bf10786a05429046]::plumbing::QueryCtxt, false>
  46:     0x7f92962c7682 - rustc_query_impl[bf10786a05429046]::query_impl::optimized_mir::get_query_non_incr::__rust_end_short_backtrace
  47:     0x7f9294d0e190 - <rustc_middle[29c00dc8642989c6]::ty::context::TyCtxt>::instance_mir
  48:     0x7f92954aea02 - rustc_monomorphize[7ba1c9e625a37714]::collector::collect_used_items
  49:     0x7f92954abdde - rustc_monomorphize[7ba1c9e625a37714]::collector::collect_items_rec
  50:     0x7f9295d213e1 - <rustc_data_structures[b259781372983027]::sync::parallel::ParallelGuard>::run::<(), rustc_data_structures[b259781372983027]::sync::parallel::disabled::par_for_each_in<alloc[1d0d6505afdbca5c]::vec::Vec<rustc_middle[29c00dc8642989c6]::mir::mono::MonoItem>, rustc_monomorphize[7ba1c9e625a37714]::collector::collect_crate_mono_items::{closure#1}::{closure#0}>::{closure#0}::{closure#0}::{closure#0}>
  51:     0x7f9295d212fb - rustc_data_structures[b259781372983027]::sync::parallel::disabled::par_for_each_in::<alloc[1d0d6505afdbca5c]::vec::Vec<rustc_middle[29c00dc8642989c6]::mir::mono::MonoItem>, rustc_monomorphize[7ba1c9e625a37714]::collector::collect_crate_mono_items::{closure#1}::{closure#0}>
  52:     0x7f9295d21189 - <rustc_session[797cecdacaf7bd8a]::session::Session>::time::<(), rustc_monomorphize[7ba1c9e625a37714]::collector::collect_crate_mono_items::{closure#1}>
  53:     0x7f9295d20de8 - rustc_monomorphize[7ba1c9e625a37714]::collector::collect_crate_mono_items
  54:     0x7f9295d1f118 - rustc_monomorphize[7ba1c9e625a37714]::partitioning::collect_and_partition_mono_items
  55:     0x7f9295f142f9 - rustc_query_impl[bf10786a05429046]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[bf10786a05429046]::query_impl::collect_and_partition_mono_items::dynamic_query::{closure#2}::{closure#0}, rustc_middle[29c00dc8642989c6]::query::erase::Erased<[u8; 24usize]>>
  56:     0x7f9295f142cd - <rustc_query_impl[bf10786a05429046]::query_impl::collect_and_partition_mono_items::dynamic_query::{closure#2} as core[22cc6ecfdb6bcca5]::ops::function::FnOnce<(rustc_middle[29c00dc8642989c6]::ty::context::TyCtxt, ())>>::call_once
  57:     0x7f92960d6557 - rustc_query_system[9effd60937474be5]::query::plumbing::try_execute_query::<rustc_query_impl[bf10786a05429046]::DynamicConfig<rustc_query_system[9effd60937474be5]::query::caches::SingleCache<rustc_middle[29c00dc8642989c6]::query::erase::Erased<[u8; 24usize]>>, false, false, false>, rustc_query_impl[bf10786a05429046]::plumbing::QueryCtxt, false>
  58:     0x7f92962e31a2 - rustc_query_impl[bf10786a05429046]::query_impl::collect_and_partition_mono_items::get_query_non_incr::__rust_end_short_backtrace
  59:     0x7f9295f4557b - rustc_codegen_ssa[6f94cf36afb6d0d8]::base::codegen_crate::<rustc_codegen_llvm[d1d947d70c71a977]::LlvmCodegenBackend>
  60:     0x7f9295f4537f - <rustc_codegen_llvm[d1d947d70c71a977]::LlvmCodegenBackend as rustc_codegen_ssa[6f94cf36afb6d0d8]::traits::backend::CodegenBackend>::codegen_crate
  61:     0x7f9295e69812 - <rustc_session[797cecdacaf7bd8a]::session::Session>::time::<alloc[1d0d6505afdbca5c]::boxed::Box<dyn core[22cc6ecfdb6bcca5]::any::Any>, rustc_interface[dab9391c2a8d484a]::passes::start_codegen::{closure#0}>
  62:     0x7f9295e6936b - rustc_interface[dab9391c2a8d484a]::passes::start_codegen
  63:     0x7f9295e63cba - <rustc_middle[29c00dc8642989c6]::ty::context::GlobalCtxt>::enter::<<rustc_interface[dab9391c2a8d484a]::queries::Queries>::ongoing_codegen::{closure#0}, core[22cc6ecfdb6bcca5]::result::Result<alloc[1d0d6505afdbca5c]::boxed::Box<dyn core[22cc6ecfdb6bcca5]::any::Any>, rustc_span[30e21d5074f476ed]::ErrorGuaranteed>>
  64:     0x7f9295e630c2 - <rustc_interface[dab9391c2a8d484a]::interface::Compiler>::enter::<rustc_driver_impl[43bd6da197b49f55]::run_compiler::{closure#1}::{closure#2}, core[22cc6ecfdb6bcca5]::result::Result<core[22cc6ecfdb6bcca5]::option::Option<rustc_interface[dab9391c2a8d484a]::queries::Linker>, rustc_span[30e21d5074f476ed]::ErrorGuaranteed>>
  65:     0x7f9295e5c334 - std[7db58085941d9bac]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[dab9391c2a8d484a]::util::run_in_thread_with_globals<rustc_interface[dab9391c2a8d484a]::interface::run_compiler<core[22cc6ecfdb6bcca5]::result::Result<(), rustc_span[30e21d5074f476ed]::ErrorGuaranteed>, rustc_driver_impl[43bd6da197b49f55]::run_compiler::{closure#1}>::{closure#0}, core[22cc6ecfdb6bcca5]::result::Result<(), rustc_span[30e21d5074f476ed]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[22cc6ecfdb6bcca5]::result::Result<(), rustc_span[30e21d5074f476ed]::ErrorGuaranteed>>
  66:     0x7f9295e5ba8e - <<std[7db58085941d9bac]::thread::Builder>::spawn_unchecked_<rustc_interface[dab9391c2a8d484a]::util::run_in_thread_with_globals<rustc_interface[dab9391c2a8d484a]::interface::run_compiler<core[22cc6ecfdb6bcca5]::result::Result<(), rustc_span[30e21d5074f476ed]::ErrorGuaranteed>, rustc_driver_impl[43bd6da197b49f55]::run_compiler::{closure#1}>::{closure#0}, core[22cc6ecfdb6bcca5]::result::Result<(), rustc_span[30e21d5074f476ed]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[22cc6ecfdb6bcca5]::result::Result<(), rustc_span[30e21d5074f476ed]::ErrorGuaranteed>>::{closure#1} as core[22cc6ecfdb6bcca5]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  67:     0x7f9293771075 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h6e391959b1043522
                               at /rustc/5f6ee65f594f59f64c7957dcad90edc0b8830284/library/alloc/src/boxed.rs:2007:9
  68:     0x7f9293771075 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h80e392a53addb656
                               at /rustc/5f6ee65f594f59f64c7957dcad90edc0b8830284/library/alloc/src/boxed.rs:2007:9
  69:     0x7f9293771075 - std::sys::unix::thread::Thread::new::thread_start::h8c6721ffb353e658
                               at /rustc/5f6ee65f594f59f64c7957dcad90edc0b8830284/library/std/src/sys/unix/thread.rs:108:17
  70:     0x7f929348c9eb - <unknown>
  71:     0x7f9293510dfc - <unknown>
  72:                0x0 - <unknown>

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: please attach the file at `/tmp/2/icemaker_reduced/rustc-ice-2023-09-12T15:53:40.73879349Z-2966290.txt` to your bug report

note: compiler flags: -Z mir-opt-level=3

query stack during panic:
#0 [optimized_mir] optimizing MIR for `<impl at deriving-default-box.rs:1:10: 1:17>::default`
#1 [optimized_mir] optimizing MIR for `main`
#2 [collect_and_partition_mono_items] collect_and_partition_mono_items
end of query stack
error: aborting due to previous error; 2 warnings emitted

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

cc7a9d6 #115705 cc @cjgillot

@saethlin saethlin added A-mir-opt Area: MIR optimizations and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Sep 12, 2023
bors added a commit to rust-lang-ci/rust that referenced this issue Sep 20, 2023
Do not create a DerefLen place for `Box<[T]>`.

Fixes rust-lang#115789
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Sep 23, 2023
…twco

Do not create a DerefLen place for `Box<[T]>`.

Fixes rust-lang#115789
@bors bors closed this as completed in 551c718 Sep 24, 2023
github-actions bot pushed a commit to rust-lang/miri that referenced this issue Sep 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-mir-opt Area: MIR optimizations 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.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants