This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: RFC: __attribute_alloc_size__ on allocation functions (BZ#23741)
- From: DJ Delorie <dj at redhat dot com>
- To: Adhemerval Zanella <adhemerval dot zanella at linaro dot org>
- Cc: libc-alpha at sourceware dot org
- Date: Sat, 17 Nov 2018 11:27:03 -0500
- Subject: Re: RFC: __attribute_alloc_size__ on allocation functions (BZ#23741)
Adhemerval Zanella <adhemerval.zanella@linaro.org> writes:
> So I think before adding such annotation we need to discuss whether we
> want to allow such kind of allocation on malloc and mmap functions. To
> comparison:
It's relatively easy to add such a limit to malloc et al; there's
already a "request too big" macro that just needs to be adjusted (it
currently avoids unsigned overflows).
Perhaps a good compromise would be to retain current behavior for 32-bit
targets (where allocations bigger than 2Gb are realistic) but limit them
to PTRDIFF_MAX on 64 bit targets, (where a 5 exabyte allocation is not
reasonable).