Closed as not planned
Description
I had this code fail (on both Mac and Windows):
#[global_allocator]
static GLOBAL: AccountingAllocator<mimalloc::MiMalloc> =
AccountingAllocator::new(mimalloc::MiMalloc);
#[repr(C, align(256))]
pub struct BigStruct { … }
fn collect() {
assert_eq!(align_of::<BigStruct>(), 256);
assert_eq!(size_of::<BigStruct>(), 256);
let vec: Vec<T> = std::iter::once(BigStruct{…}).collect();
dbg!(vec.as_ptr() as usize % std::mem::align_of::<T>()); // Sometimes prints 64
let slice = vec.as_slice(); // panics in debug builds because of the unaligned memory
}
Granted, 256 is a very large alignment, but I expect either mimalloc to handle it, or to log a warning, or panic, or similar.
But I don't want it to quietly return unaligned memory.
I cannot find any docs saying there is a limit to the supported alignment.
The standard allocator never fails on the same code.
Maybe related
Metadata
Metadata
Assignees
Labels
No labels