Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ private static long allocateNativeInternal(long byteSize, long byteAlignment, Me
}
// Always allocate at least some memory so that zero-length segments have distinct
// non-zero addresses.
alignedSize = Math.max(1, alignedSize);
alignedSize = Math.max(Long.BYTES, alignedSize);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few lines above this code there's a comment which says:

// Align the allocation size up to a multiple of 8 so we can init the memory with longs
long alignedSize = init ? Utils.alignUp(byteSize, Long.BYTES) : byteSize;

Should we have a similar comment as well as a check for init here? After all, we are increasing this size here because of init initializing the allocated memory. So perhaps something like:

// Always allocate at least some memory so that zero-length segments have distinct
// non-zero addresses. If we are initializing the allocated memory, then use a minimum
// size of 8 because we init the memory with longs.
alignedSize = Math.max((init ? Long.BYTES : 1), alignedSize);

If you do use this newer proposed change, then please have it verified against the original reproducer.


long allocationSize;
long allocationBase;
Expand Down