Skip to content

allocator bug #90219

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

Closed
gipsyh opened this issue Oct 24, 2021 · 2 comments
Closed

allocator bug #90219

gipsyh opened this issue Oct 24, 2021 · 2 comments
Labels
C-bug Category: This is a bug.

Comments

@gipsyh
Copy link

gipsyh commented Oct 24, 2021

#![feature(allocator_api)]

struct A {
    a:u32
}
unsafe impl std::alloc::Allocator for A {
    fn allocate(
        &self,
        layout: std::alloc::Layout,
    ) -> Result<std::ptr::NonNull<[u8]>, std::alloc::AllocError> {
        Err(std::alloc::AllocError)
    }

    unsafe fn deallocate(&self, ptr: std::ptr::NonNull<u8>, layout: std::alloc::Layout) {}
}

fn main() {
    let a = A {a:1};
    Box::new_in(1, a);
}
thread 'rustc' panicked at 'assertion failed: i < this.fields.count()', /rustc/547a6ffee0cf4da9929a9e3d49546dc87d607735/compiler/rustc_middle/src/ty/layout.rs:2290:21
stack backtrace:
   0: rust_begin_unwind
             at /rustc/547a6ffee0cf4da9929a9e3d49546dc87d607735/library/std/src/panicking.rs:495:5
   1: core::panicking::panic_fmt
             at /rustc/547a6ffee0cf4da9929a9e3d49546dc87d607735/library/core/src/panicking.rs:107:14
   2: core::panicking::panic
             at /rustc/547a6ffee0cf4da9929a9e3d49546dc87d607735/library/core/src/panicking.rs:50:5
   3: rustc_middle::ty::layout::<impl rustc_target::abi::TyAbiInterface<C> for &rustc_middle::ty::TyS>::ty_and_layout_field::field_ty_or_layout
   4: <rustc_target::abi::TyAndLayout<&rustc_middle::ty::TyS> as rustc_codegen_llvm::type_of::LayoutLlvmExt>::scalar_pair_element_llvm_type
   5: <rustc_target::abi::TyAndLayout<&rustc_middle::ty::TyS> as rustc_codegen_llvm::type_of::LayoutLlvmExt>::scalar_pair_element_llvm_type
   6: <rustc_target::abi::call::FnAbi<&rustc_middle::ty::TyS> as rustc_codegen_llvm::abi::FnAbiLlvmExt>::llvm_type
   7: rustc_codegen_llvm::mono_item::<impl rustc_codegen_ssa::traits::declare::PreDefineMethods for rustc_codegen_llvm::context::CodegenCx>::predefine_fn
   8: rustc_codegen_llvm::base::compile_codegen_unit::module_codegen
   9: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task
  10: rustc_codegen_llvm::base::compile_codegen_unit
  11: rustc_codegen_ssa::base::codegen_crate
  12: <rustc_codegen_llvm::LlvmCodegenBackend as rustc_codegen_ssa::traits::backend::CodegenBackend>::codegen_crate
  13: rustc_session::utils::<impl rustc_session::session::Session>::time
  14: rustc_interface::queries::Queries::ongoing_codegen
  15: rustc_interface::queries::<impl rustc_interface::interface::Compiler>::enter
  16: rustc_span::with_source_map
  17: scoped_tls::ScopedKey<T>::set
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

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.58.0-nightly (547a6ffee 2021-10-21) running on x86_64-unknown-linux-gnu

note: compiler flags: -C embed-bitcode=no -C debuginfo=2 -C incremental --crate-type bin

note: some of the compiler flags provided by cargo are hidden
@gipsyh gipsyh added the C-bug Category: This is a bug. label Oct 24, 2021
@memoryruins
Copy link
Contributor

Duplicate of #90201 and #78459

@matthiaskrgr
Copy link
Member

This is fixed on nightly.

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.
Projects
None yet
Development

No branches or pull requests

3 participants