RFR: 8371637: allocateNativeInternal sometimes return incorrectly aligned memory [v6]

Almaz duke at openjdk.org
Thu Nov 20 11:04:42 UTC 2025


On Wed, 19 Nov 2025 14:30:17 GMT, Maurizio Cimadamore <mcimadamore 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>
>
> I think the proposed simpler patch makes sense. Basically, it artificially expands the allocation size to match the alignment, which is probably not going to cause any side-effect as that is likely what was happening anyway...

@mcimadamore:

Question regarding `MAX_MALLOC_ALIGN = Unsafe.ADDRESS_SIZE == 4 ? 8 : 16;`

Is 16 here just a heuristic based on known malloc implementations or is it backed by something? I can't find anything regarding that in the libc standard. 

Not related to this particular PR: should `MAX_MALLOC_ALIGN` be `MIN_MALLOC_ALIGN` instead? Larger allocations might be page size aligned.

-------------

PR Comment: https://git.openjdk.org/jdk/pull/28235#issuecomment-3557358928


More information about the core-libs-dev mailing list