This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH 2/2] malloc: make malloc fail with requests larger than PTRDIFF_MAX
On 21/12/2018 16:41, Joseph Myers wrote:
> I think this needs a NEWS entry (in the "Deprecated and removed features,
> and other changes affecting compatibility" section), as it may affect
> people currently doing > 2GB allocations in 32-bit programs.
>
What about:
* Memory allocation functions malloc, calloc, realloc, reallocarray, valloc,
pvalloc, memaling, and posix_memalignfail now fail with requests larger
than PTRDIFF_MAX. This is to avoid potential undefined behavior with
pointer subtraction within the allocated object, where results might
in ptrdiff_t type overflow.
As a side note, gcc 9 now seems to add -Wattributes in -Wall which results
in a "error: ‘alloc_size’ attribute ignored on a function returning ‘int’"
on posix_memalign with __attribute_alloc_size__ ((3)).
Does gcc provide an attribute to indicate first argument is the expected
result, so it can match the attribute with argument type instead of
function returned one? Otherwise I think we will need to suppress it
from posix_memalign.