-
Notifications
You must be signed in to change notification settings - Fork 13.4k
ICE with #![feature(allocator_api)]
#81270
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Comments
This comment has been minimized.
This comment has been minimized.
Slightly minimized: #![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; 1] }
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; 1] });
} Doesn't ICE anymore if you either remove the field |
Duplicate of #78459? |
No, not really a duplicate (but possibly related). This issue and the linked one have completely different backtraces. |
Just by the way, using inline storage in an allocator is actually unsafe unless the impl of the See the Allocator safety notes:
(Emphasis mine) (link) |
Issue: rust-lang/rust#81270
FWIW this is also triggered with uninhabited types. Though looks like only when drop glue is involved. Eg |
Another MCVE that leads to this ICE: #![feature(allocator_api)]
use std::alloc::Global;
use std::mem::MaybeUninit;
fn crash(_: &[MaybeUninit<()>]) {}
fn main() {
crash(&Box::new_uninit_slice_in(0, &Global));
} found in #85916 |
@rustbot claim |
Uh oh!
There was an error while loading. Please reload this page.
Hello,
I've tested the
allocator_api
feature and encountered an ICE:Code
If tried this code (playground):
Meta
I've used the "current" playground nighty compiler, but I can reproduce locally.
rustc --version --verbose
:and also on
Error output
Backtrace
The text was updated successfully, but these errors were encountered: