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 when returning a Box with a reference as its Allocator #81246

Closed
beepster4096 opened this issue Jan 21, 2021 · 4 comments
Closed

ICE when returning a Box with a reference as its Allocator #81246

beepster4096 opened this issue Jan 21, 2021 · 4 comments
Labels
A-allocators Area: Custom and system allocators C-bug Category: This is a bug. 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

@beepster4096
Copy link
Contributor

Code

#![feature(allocator_api)]

fn ice() -> Box<(), &'static std::alloc::Global> {todo!()}

fn main(){
    ice();
}

Meta

rustc --version --verbose:

rustc 1.51.0-nightly (a4cbb44ae 2021-01-20)
binary: rustc
commit-hash: a4cbb44ae2c80545db957763b502dc7f6ea22085
commit-date: 2021-01-20
host: x86_64-pc-windows-msvc
release: 1.51.0-nightly
LLVM version: 11.0.1

Error output

thread 'rustc' panicked at 'assertion failed: i < this.fields.count()', /rustc/a4cbb44ae2c80545db957763b502dc7f6ea22085\compiler\rustc_middle\src\ty\layout.rs:2149: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.51.0-nightly (a4cbb44ae 2021-01-20) running on x86_64-pc-windows-msvc

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:
error: could not compile `icetest`
Backtrace

thread 'rustc' panicked at 'assertion failed: i < this.fields.count()', /rustc/a4cbb44ae2c80545db957763b502dc7f6ea22085\compiler\rustc_middle\src\ty\layout.rs:2149:21
stack backtrace:
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.51.0-nightly (a4cbb44ae 2021-01-20) running on x86_64-pc-windows-msvc

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
error: could not compile `icetest`

To learn more, run the command again with --verbose.

@beepster4096 beepster4096 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 Jan 21, 2021
@beepster4096
Copy link
Contributor Author

@rustbot label: +requires-nightly +A-allocators

@rustbot rustbot added A-allocators Area: Custom and system allocators requires-nightly This issue requires a nightly compiler in some way. labels Jan 21, 2021
@jfrimmel
Copy link
Contributor

Another code snippet, that hits this assertion is (playground):

#![feature(allocator_api)]
use std::alloc::{Layout, Allocator, Global, AllocError};
use std::ptr::NonNull;
use std::marker::PhantomData;

struct S<A>{ a: PhantomData<A>, b: (u8,) }
unsafe impl<A> Allocator for S<A> {
    fn allocate(&self, _: Layout) -> Result<NonNull<[u8]>, AllocError> {
        todo!();
    }
    unsafe fn deallocate(&self, _: NonNull<u8>, _: Layout) {
        todo!();
    }
}

fn main() {
    let x: Box<u8, S<u8>> = Box::new_in(0, S {
        a: PhantomData,
        b: (0,),
    });
}

This is a slightly changed variant of #81270, but the array was changed to a 1-element-tuple.

fanninpm added a commit to fanninpm/glacier that referenced this issue Jan 30, 2021
@rust-lang-glacier-bot rust-lang-glacier-bot added the glacier ICE tracked in rust-lang/glacier. label Jan 30, 2021
@exrook
Copy link
Contributor

exrook commented Feb 5, 2021

I believe this is the same issue as #78459

@beepster4096
Copy link
Contributor Author

Yeah, looks like it

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. 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

No branches or pull requests

5 participants