MAX_MALLOC_ALIGN and libc spec

Maurizio Cimadamore maurizio.cimadamore at oracle.com
Fri Nov 14 10:51:22 UTC 2025


Hi,
I think this very topic is being discussed here?

https://github.com/openjdk/jdk/pull/28235

Cheers
Maurizio

On 14/11/2025 10:42, Almaz Mingaleev wrote:
> Hello,
>
> SegmentFactories defines MAX_MALLOC_ALIGN variable and sets it to 16 
> on LP64 architectures. However, section 7.24.4.1 of the libc spec only 
> says
>
> > The pointer returned if the allocation succeeds is suitably aligned 
> so that it can be
> > assigned to a pointer to any type of object with a fundamental alignment
> > requirement and size less than or equal to the size requested
>
> (https://open-std.org/JTC1/SC22/WG14/www/docs/n3467.pdf#page=397)
>
> The largest type defined by the spec seems to be “long double” and 
> there is only “Recommended practice” for it:
>
> > The long double type should match the ISO/IEC 60559 binary128 
> format, else
> > an ISO/IEC 60559 binary64-extended format.
>
> Do I understand correctly that the currently used value of 16 is 
> relying on existing implementations and that the current 
> implementation might misbehave if a malloc call for a size of 8 bytes 
> returns an 8 bytes aligned address, which is allowed by the spec?
>
> Also, shouldn’t the name be MIN_MALLOC_ALIGN?
>
> Thanks,
> Almaz


More information about the panama-dev mailing list