-
Notifications
You must be signed in to change notification settings - Fork 47
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Describe the Bug
Allocating usize::MAX - 8
bytes fails but allocates new memory pages every time.
Steps to Reproduce
#[test]
fn cannot_alloc_max_usize_m8() {
let a = &wee_alloc::WeeAlloc::INIT;
let layout = Layout::from_size_align(std::usize::MAX - 8, 1)
.expect("should be able to create a `Layout` with size = std::usize::MAX - 8");
for _ in 0..10000000 {
let result = unsafe { a.alloc(layout) };
assert!(result.is_err());
}
}
Expected Behavior
The test should complete without causing OOM.
Actual Behavior
With debug assertions: thread 'cannot_alloc_max_usize_m8' panicked at 'attempt to add with overflow', .../.cargo/registry/src/gitproxy.zycloud.tk-1ecc6299db9ec823/memory_units-0.4.0/src/lib.rs:166:1
Without debug assertions: The test allocates tens of gigabytes of memory and eventually gets killed by the kernel.
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working