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: argument to drop_in_place is not a raw ptr: &dyn Trait2<Type1> #111883

Closed
matthiaskrgr opened this issue May 23, 2023 · 3 comments
Closed

ICE: argument to drop_in_place is not a raw ptr: &dyn Trait2<Type1> #111883

matthiaskrgr opened this issue May 23, 2023 · 3 comments
Labels
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

#![crate_type = "lib"]
#![feature(arbitrary_self_types, no_core, lang_items)]
#![no_core]

#[lang = "sized"]
trait Sized {}
#[lang = "copy"]
trait Copy {}
#[lang = "receiver"]
trait Receiver {}
#[lang = "dispatch_from_dyn"]
trait DispatchFromDyn<T> {}
impl<'a, T: ?Sized + Unsize<U>, U: ?Sized> DispatchFromDyn<&'a U> for &'a T {}
#[lang = "unsize"]
trait Unsize<T: ?Sized> {}
#[lang = "coerce_unsized"]
pub trait CoerceUnsized<T: ?Sized> {}
impl<'a, 'b: 'a, T: ?Sized + Unsize<U>, U: ?Sized> CoerceUnsized<&'a U> for &'b T {}

#[lang = "drop_in_place"]
fn drop_in_place_fn<T>(a: &dyn Trait2<T>) {}

pub trait Trait1 {
    fn foo(&self);
}

pub struct Type1;

impl Trait1 for Type1 {
    fn foo(&self) {}
}

pub trait Trait2<T> {}

pub fn bar1() {
    let a = Type1;
    let b = &a as &dyn Trait1;
    b.foo();
}

Meta

rustc --version --verbose:

rustc 1.71.0-nightly (f3d597b31 2023-05-23)
binary: rustc
commit-hash: f3d597b31c0f101a02c230798afa31a36bdacbc6
commit-date: 2023-05-23
host: x86_64-unknown-linux-gnu
release: 1.71.0-nightly
LLVM version: 16.0.4

Error output

<output>
Backtrace

warning: unused variable: `a`
  --> treereduce.out:21:24
   |
21 | fn drop_in_place_fn<T>(a: &dyn Trait2<T>) {}
   |                        ^ help: if this is intentional, prefix it with an underscore: `_a`
   |
   = note: `#[warn(unused_variables)]` on by default

warning: private trait `Sized` in public interface (error E0445)
  --> treereduce.out:33:1
   |
33 | pub trait Trait2<T> {}
   | ^^^^^^^^^^^^^^^^^^^
   |
   = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
   = note: for more information, see issue #34537 <https://github.com/rust-lang/rust/issues/34537>
   = note: `#[warn(private_in_public)]` on by default

error: internal compiler error: compiler/rustc_ty_utils/src/abi.rs:386:18: argument to drop_in_place is not a raw ptr: &dyn Trait2<Type1>

thread 'rustc' panicked at 'Box<dyn Any>', /rustc/f3d597b31c0f101a02c230798afa31a36bdacbc6/compiler/rustc_errors/src/lib.rs:1650:9
stack backtrace:
   0:     0x7fac5e569531 - std::backtrace_rs::backtrace::libunwind::trace::h6baaeedd4fccd054
                               at /rustc/f3d597b31c0f101a02c230798afa31a36bdacbc6/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
   1:     0x7fac5e569531 - std::backtrace_rs::backtrace::trace_unsynchronized::h8e9568254f3fa164
                               at /rustc/f3d597b31c0f101a02c230798afa31a36bdacbc6/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7fac5e569531 - std::sys_common::backtrace::_print_fmt::hef8d1d746c9f67ae
                               at /rustc/f3d597b31c0f101a02c230798afa31a36bdacbc6/library/std/src/sys_common/backtrace.rs:65:5
   3:     0x7fac5e569531 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::hc747bb379fb72440
                               at /rustc/f3d597b31c0f101a02c230798afa31a36bdacbc6/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x7fac5e5c9b8f - core::fmt::rt::Argument::fmt::h3956dc7d56f74ca3
                               at /rustc/f3d597b31c0f101a02c230798afa31a36bdacbc6/library/core/src/fmt/rt.rs:138:9
   5:     0x7fac5e5c9b8f - core::fmt::write::hfa3d2c4a997c6a93
                               at /rustc/f3d597b31c0f101a02c230798afa31a36bdacbc6/library/core/src/fmt/mod.rs:1094:21
   6:     0x7fac5e55c831 - std::io::Write::write_fmt::heaf05fdef908d88e
                               at /rustc/f3d597b31c0f101a02c230798afa31a36bdacbc6/library/std/src/io/mod.rs:1712:15
   7:     0x7fac5e569345 - std::sys_common::backtrace::_print::h7e0d6fff8f40243c
                               at /rustc/f3d597b31c0f101a02c230798afa31a36bdacbc6/library/std/src/sys_common/backtrace.rs:47:5
   8:     0x7fac5e569345 - std::sys_common::backtrace::print::hbde3ac9b6cb1d75f
                               at /rustc/f3d597b31c0f101a02c230798afa31a36bdacbc6/library/std/src/sys_common/backtrace.rs:34:9
   9:     0x7fac5e56bff7 - std::panicking::default_hook::{{closure}}::hd41b67a1f293cacb
  10:     0x7fac5e56bde4 - std::panicking::default_hook::h2876d7042a0118d9
                               at /rustc/f3d597b31c0f101a02c230798afa31a36bdacbc6/library/std/src/panicking.rs:288:9
  11:     0x7fac616f5f5b - rustc_driver_impl[582d5cb644cbfc29]::install_ice_hook::{closure#0}
  12:     0x7fac5e56c717 - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::h99db99dd6b6e0d19
                               at /rustc/f3d597b31c0f101a02c230798afa31a36bdacbc6/library/alloc/src/boxed.rs:1999:9
  13:     0x7fac5e56c717 - std::panicking::rust_panic_with_hook::h1658669de3396d92
                               at /rustc/f3d597b31c0f101a02c230798afa31a36bdacbc6/library/std/src/panicking.rs:695:13
  14:     0x7fac61bffcb1 - std[f2da8316d6db2576]::panicking::begin_panic::<rustc_errors[64134838643052e9]::ExplicitBug>::{closure#0}
  15:     0x7fac61bfa106 - std[f2da8316d6db2576]::sys_common::backtrace::__rust_end_short_backtrace::<std[f2da8316d6db2576]::panicking::begin_panic<rustc_errors[64134838643052e9]::ExplicitBug>::{closure#0}, !>
  16:     0x7fac61bf98a6 - std[f2da8316d6db2576]::panicking::begin_panic::<rustc_errors[64134838643052e9]::ExplicitBug>
  17:     0x7fac61bf3414 - <rustc_errors[64134838643052e9]::HandlerInner>::bug::<alloc[c0674fa548f2638a]::string::String>
  18:     0x7fac61bf31b6 - <rustc_errors[64134838643052e9]::Handler>::bug::<alloc[c0674fa548f2638a]::string::String>
  19:     0x7fac61c76f0c - rustc_middle[4e8357760ade6042]::util::bug::opt_span_bug_fmt::<rustc_span[f846a9a6973d9efc]::span_encoding::Span>::{closure#0}
  20:     0x7fac61c743fa - rustc_middle[4e8357760ade6042]::ty::context::tls::with_opt::<rustc_middle[4e8357760ade6042]::util::bug::opt_span_bug_fmt<rustc_span[f846a9a6973d9efc]::span_encoding::Span>::{closure#0}, !>::{closure#0}
  21:     0x7fac61c743ca - rustc_middle[4e8357760ade6042]::ty::context::tls::with_context_opt::<rustc_middle[4e8357760ade6042]::ty::context::tls::with_opt<rustc_middle[4e8357760ade6042]::util::bug::opt_span_bug_fmt<rustc_span[f846a9a6973d9efc]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
  22:     0x7fac5fedb86d - rustc_middle[4e8357760ade6042]::util::bug::bug_fmt
  23:     0x7fac5f8430b5 - <core[8abe981e17941196]::iter::adapters::GenericShunt<core[8abe981e17941196]::iter::adapters::map::Map<core[8abe981e17941196]::iter::adapters::enumerate::Enumerate<core[8abe981e17941196]::iter::adapters::chain::Chain<core[8abe981e17941196]::iter::adapters::chain::Chain<core[8abe981e17941196]::iter::adapters::copied::Copied<core[8abe981e17941196]::slice::iter::Iter<rustc_middle[4e8357760ade6042]::ty::Ty>>, core[8abe981e17941196]::iter::adapters::copied::Copied<core[8abe981e17941196]::slice::iter::Iter<rustc_middle[4e8357760ade6042]::ty::Ty>>>, core[8abe981e17941196]::option::IntoIter<rustc_middle[4e8357760ade6042]::ty::Ty>>>, rustc_ty_utils[ef6fa4138e700ebe]::abi::fn_abi_new_uncached::{closure#1}>, core[8abe981e17941196]::result::Result<core[8abe981e17941196]::convert::Infallible, rustc_middle[4e8357760ade6042]::ty::layout::FnAbiError>> as core[8abe981e17941196]::iter::traits::iterator::Iterator>::next
  24:     0x7fac6065db8d - rustc_ty_utils[ef6fa4138e700ebe]::abi::fn_abi_new_uncached
  25:     0x7fac60658da6 - rustc_ty_utils[ef6fa4138e700ebe]::abi::fn_abi_of_instance
  26:     0x7fac5f7a0978 - rustc_query_impl[9e447be1993c3916]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[9e447be1993c3916]::query_impl::fn_abi_of_instance::dynamic_query::{closure#2}::{closure#0}, rustc_middle[4e8357760ade6042]::query::erase::Erased<[u8; 24usize]>>
  27:     0x7fac606d5ea2 - rustc_query_system[bbfbc2f9f51dee36]::query::plumbing::try_execute_query::<rustc_query_impl[9e447be1993c3916]::DynamicConfig<rustc_query_system[bbfbc2f9f51dee36]::query::caches::DefaultCache<rustc_middle[4e8357760ade6042]::ty::ParamEnvAnd<(rustc_middle[4e8357760ade6042]::ty::instance::Instance, &rustc_middle[4e8357760ade6042]::ty::list::List<rustc_middle[4e8357760ade6042]::ty::Ty>)>, rustc_middle[4e8357760ade6042]::query::erase::Erased<[u8; 24usize]>>, false, false, false>, rustc_query_impl[9e447be1993c3916]::plumbing::QueryCtxt, false>
  28:     0x7fac606d5acd - rustc_query_impl[9e447be1993c3916]::query_impl::fn_abi_of_instance::get_query_non_incr::__rust_end_short_backtrace
  29:     0x7fac5fdaf2fa - rustc_codegen_llvm[c467aa6e245be363]::callee::get_fn
  30:     0x7fac601072f8 - <rustc_codegen_llvm[c467aa6e245be363]::context::CodegenCx as rustc_codegen_ssa[434f07609135cfcd]::traits::consts::ConstMethods>::scalar_to_backend
  31:     0x7fac6010b195 - rustc_codegen_llvm[c467aa6e245be363]::consts::const_alloc_to_llvm
  32:     0x7fac6011daea - rustc_codegen_ssa[434f07609135cfcd]::meth::get_vtable::<rustc_codegen_llvm[c467aa6e245be363]::context::CodegenCx>
  33:     0x7fac60118900 - rustc_codegen_ssa[434f07609135cfcd]::base::unsized_info::<rustc_codegen_llvm[c467aa6e245be363]::builder::Builder>
  34:     0x7fac6010d85a - rustc_codegen_ssa[434f07609135cfcd]::base::unsize_ptr::<rustc_codegen_llvm[c467aa6e245be363]::builder::Builder>
  35:     0x7fac600eb705 - <rustc_codegen_ssa[434f07609135cfcd]::mir::FunctionCx<rustc_codegen_llvm[c467aa6e245be363]::builder::Builder>>::codegen_rvalue_operand
  36:     0x7fac600bd25c - rustc_codegen_ssa[434f07609135cfcd]::mir::codegen_mir::<rustc_codegen_llvm[c467aa6e245be363]::builder::Builder>
  37:     0x7fac60d2ba47 - rustc_codegen_llvm[c467aa6e245be363]::base::compile_codegen_unit::module_codegen
  38:     0x7fac60d2a639 - <rustc_codegen_llvm[c467aa6e245be363]::LlvmCodegenBackend as rustc_codegen_ssa[434f07609135cfcd]::traits::backend::ExtraBackendMethods>::compile_codegen_unit
  39:     0x7fac60d26c72 - rustc_codegen_ssa[434f07609135cfcd]::base::codegen_crate::<rustc_codegen_llvm[c467aa6e245be363]::LlvmCodegenBackend>
  40:     0x7fac60d26552 - <rustc_codegen_llvm[c467aa6e245be363]::LlvmCodegenBackend as rustc_codegen_ssa[434f07609135cfcd]::traits::backend::CodegenBackend>::codegen_crate
  41:     0x7fac609a2612 - <rustc_session[8a2390cb7e4bb88d]::session::Session>::time::<alloc[c0674fa548f2638a]::boxed::Box<dyn core[8abe981e17941196]::any::Any>, rustc_interface[4027ea3aaa7c84cf]::passes::start_codegen::{closure#0}>
  42:     0x7fac609a215b - rustc_interface[4027ea3aaa7c84cf]::passes::start_codegen
  43:     0x7fac6099fab7 - <rustc_middle[4e8357760ade6042]::ty::context::GlobalCtxt>::enter::<<rustc_interface[4027ea3aaa7c84cf]::queries::Queries>::ongoing_codegen::{closure#0}::{closure#0}, core[8abe981e17941196]::result::Result<alloc[c0674fa548f2638a]::boxed::Box<dyn core[8abe981e17941196]::any::Any>, rustc_span[f846a9a6973d9efc]::ErrorGuaranteed>>
  44:     0x7fac6099e24d - <rustc_interface[4027ea3aaa7c84cf]::queries::Queries>::ongoing_codegen
  45:     0x7fac6099d834 - <rustc_interface[4027ea3aaa7c84cf]::interface::Compiler>::enter::<rustc_driver_impl[582d5cb644cbfc29]::run_compiler::{closure#1}::{closure#2}, core[8abe981e17941196]::result::Result<core[8abe981e17941196]::option::Option<rustc_interface[4027ea3aaa7c84cf]::queries::Linker>, rustc_span[f846a9a6973d9efc]::ErrorGuaranteed>>
  46:     0x7fac6099b59c - <scoped_tls[4ceba47216e47159]::ScopedKey<rustc_span[f846a9a6973d9efc]::SessionGlobals>>::set::<rustc_interface[4027ea3aaa7c84cf]::interface::run_compiler<core[8abe981e17941196]::result::Result<(), rustc_span[f846a9a6973d9efc]::ErrorGuaranteed>, rustc_driver_impl[582d5cb644cbfc29]::run_compiler::{closure#1}>::{closure#0}, core[8abe981e17941196]::result::Result<(), rustc_span[f846a9a6973d9efc]::ErrorGuaranteed>>
  47:     0x7fac6099aa36 - std[f2da8316d6db2576]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[4027ea3aaa7c84cf]::util::run_in_thread_pool_with_globals<rustc_interface[4027ea3aaa7c84cf]::interface::run_compiler<core[8abe981e17941196]::result::Result<(), rustc_span[f846a9a6973d9efc]::ErrorGuaranteed>, rustc_driver_impl[582d5cb644cbfc29]::run_compiler::{closure#1}>::{closure#0}, core[8abe981e17941196]::result::Result<(), rustc_span[f846a9a6973d9efc]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[8abe981e17941196]::result::Result<(), rustc_span[f846a9a6973d9efc]::ErrorGuaranteed>>
  48:     0x7fac60fb1585 - <<std[f2da8316d6db2576]::thread::Builder>::spawn_unchecked_<rustc_interface[4027ea3aaa7c84cf]::util::run_in_thread_pool_with_globals<rustc_interface[4027ea3aaa7c84cf]::interface::run_compiler<core[8abe981e17941196]::result::Result<(), rustc_span[f846a9a6973d9efc]::ErrorGuaranteed>, rustc_driver_impl[582d5cb644cbfc29]::run_compiler::{closure#1}>::{closure#0}, core[8abe981e17941196]::result::Result<(), rustc_span[f846a9a6973d9efc]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[8abe981e17941196]::result::Result<(), rustc_span[f846a9a6973d9efc]::ErrorGuaranteed>>::{closure#1} as core[8abe981e17941196]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  49:     0x7fac5e576b85 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hddd06452c293754a
                               at /rustc/f3d597b31c0f101a02c230798afa31a36bdacbc6/library/alloc/src/boxed.rs:1985:9
  50:     0x7fac5e576b85 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hda65146f537261ce
                               at /rustc/f3d597b31c0f101a02c230798afa31a36bdacbc6/library/alloc/src/boxed.rs:1985:9
  51:     0x7fac5e576b85 - std::sys::unix::thread::Thread::new::thread_start::h0ad9b921d3c1653e
                               at /rustc/f3d597b31c0f101a02c230798afa31a36bdacbc6/library/std/src/sys/unix/thread.rs:108:17
  52:     0x7fac5e2d4bb5 - <unknown>
  53:     0x7fac5e356d90 - <unknown>
  54:                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: rustc 1.71.0-nightly (f3d597b31 2023-05-23) running on x86_64-unknown-linux-gnu

query stack during panic:
#0 [fn_abi_of_instance] computing call ABI of `drop_in_place_fn::<Type1> - shim(None)`
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 May 23, 2023
@matthiaskrgr
Copy link
Member Author

This compiles fine with rustc 1.71.0-nightly (8b4b20836 2023-05-22) but ICEs with rustc 1.71.0-nightly (f3d597b31 2023-05-23)

@matthiaskrgr
Copy link
Member Author

ICEs since #111807

@Noratrieb
Copy link
Member

this is a malformed lang item, we do not core to support these.
please avoid submitting ICE bugs for malformed lang items and other no_core shenanigans, thanks!

@Noratrieb Noratrieb closed this as not planned Won't fix, can't repro, duplicate, stale May 23, 2023
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. 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

No branches or pull requests

2 participants