You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Allocating usize::MAX - 8 bytes fails but allocates new memory pages every time.
Steps to Reproduce
#[test]fncannot_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 _ in0..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/github.com-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.
The text was updated successfully, but these errors were encountered:
yvt
changed the title
Impossibly large allocations cause memory leak
Impossibly large allocations fails but still allocates new memory pages
Sep 12, 2021
Describe the Bug
Allocating
usize::MAX - 8
bytes fails but allocates new memory pages every time.Steps to Reproduce
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/github.com-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.
The text was updated successfully, but these errors were encountered: