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

Allocator Bug #90201

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

Allocator Bug #90201

gipsyh opened this issue Oct 23, 2021 · 2 comments
Labels
A-allocators Area: Custom and system allocators C-bug Category: This is a bug.

Comments

@gipsyh
Copy link

gipsyh commented Oct 23, 2021

#![feature(allocator_api)]
struct B {}
struct A<'ctx> {
    b: &'ctx B,
}
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 b = B {};
    let a = A { b: &b };
    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
note: run with `RUST_BACKTRACE=1` environment variable to display a 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

query stack during panic:
end of query stack
warning: `ttt` (bin "ttt") generated 5 warnings
error: could not compile `ttt`; 5 warnings emitted
@gipsyh gipsyh added the C-bug Category: This is a bug. label Oct 23, 2021
@scottmcm scottmcm added the A-allocators Area: Custom and system allocators label Oct 24, 2021
@asquared31415
Copy link
Contributor

Duplicate of #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
A-allocators Area: Custom and system allocators C-bug Category: This is a bug.
Projects
None yet
Development

No branches or pull requests

4 participants