-
Notifications
You must be signed in to change notification settings - Fork 46
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
Does not honor alignment reliably #87
Comments
I'm unable to reproduce test failure on my Arch Linux using both stable and nightly rust. |
Hm. That's really strange. I've made some upgrades recently (glibc & others) at my Devuan laptop. |
Its scary, cause if there is an issue for real, its super bad :( |
My colleague helped me with that. Now it crashes with:
|
use mimalloc::MiMalloc;
#[global_allocator]
static GLOBAL: MiMalloc = MiMalloc;
#[repr(align(64))]
struct Overaligned(u8);
fn main() {
for i in 1.. {
let x = Box::new(Overaligned(0));
let ptr: *const Overaligned = &*x;
assert!(((ptr as usize) % std::mem::align_of::<Overaligned>()) == 0, "unaligned box on try {i}");
}
} On my machine, this program reliably panics on (In debug mode it panics on the
I think the issue is in fn main() {
for i in 1.. {
let ptr = unsafe { libmimalloc_sys::mi_malloc(64) };
assert!(((ptr as usize) % 64) == 0, "unaligned on try {i}");
}
} |
Yes, this line should probably be removed Line 56 in 934a2fb
|
That said people probably shouldn't be using the secure mode. It's a bad default. (not that this means the bug shouldn't be fixed) |
@thomcc The initial reasoning behind the secure mode by default was that secure mode is still as performant or more than other allocators while providing enhanced security. It seems it always introduces more problems though so I will remove it as a default feature. Regarding this line:
Maybe it should only be removed with secure mode? |
I'm not sure if it's actually something stable we can rely on. @daanx might be able to say if it is, but it's not clear to me. |
I've been trying to find more info about this. Looks like Furthermore, following the calls eventually leads to to As a result, I think |
@nathaniel-daniel Thank you for your research into this. Yes, go ahead. |
Hi
Following example reliably fails on mimalloc-0.1.32.
Crash is always at 4096 alignment.
The text was updated successfully, but these errors were encountered: