RFR: 8371637: allocateNativeInternal sometimes return incorrectly aligned memory [v6]
Jorn Vernee
jvernee at openjdk.org
Thu Nov 20 15:05:22 UTC 2025
On Thu, 20 Nov 2025 14:57:34 GMT, Jorn Vernee <jvernee at openjdk.org> wrote:
>> Harald Eilertsen has updated the pull request incrementally with one additional commit since the last revision:
>>
>> Replace conditional with Math.max intrinsic
>>
>> Co-authored-by: ExE Boss <3889017+ExE-Boss at users.noreply.github.com>
>
> src/java.base/share/classes/jdk/internal/foreign/SegmentFactories.java line 215:
>
>> 213: result = Utils.alignUp(allocationBase, byteAlignment);
>> 214: } else {
>> 215: allocationSize = Math.max(alignedSize, byteAlignment);
>
> This looks correct but it really needs a comment.
Suggestion:
// always allocate at least 'byteAlignment' bytes, so that malloc is guaranteed to
// return a pointer aligned to that alignment, for cases where byteAlignment > alignedSize
allocationSize = Math.max(alignedSize, byteAlignment);
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/28235#discussion_r2546417290
More information about the core-libs-dev
mailing list