mirror of
https://github.com/openjdk/jdk.git
synced 2026-02-10 02:18:46 +00:00
8288850: SegmentAllocator:allocate() can return null some cases
Reviewed-by: psandoz
This commit is contained in:
parent
3164c98f4c
commit
2baf526fce
@ -78,7 +78,9 @@ public final class ArenaAllocator implements SegmentAllocator {
|
||||
return slice;
|
||||
} else {
|
||||
long maxPossibleAllocationSize = bytesSize + bytesAlignment - 1;
|
||||
if (maxPossibleAllocationSize > blockSize) {
|
||||
if (maxPossibleAllocationSize < 0) {
|
||||
throw new OutOfMemoryError();
|
||||
} else if (maxPossibleAllocationSize > blockSize) {
|
||||
// too big
|
||||
return newSegment(bytesSize, bytesAlignment);
|
||||
} else {
|
||||
|
||||
@ -160,6 +160,12 @@ public class TestSegmentAllocators {
|
||||
allocator.allocate(1, 3);
|
||||
}
|
||||
|
||||
@Test(expectedExceptions = OutOfMemoryError.class)
|
||||
public void testBadArenaNullReturn() {
|
||||
SegmentAllocator segmentAllocator = SegmentAllocator.newNativeArena(MemorySession.openImplicit());
|
||||
segmentAllocator.allocate(Long.MAX_VALUE, 2);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testArrayAllocateDelegation() {
|
||||
AtomicInteger calls = new AtomicInteger();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user