This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: RFC: __attribute_alloc_size__ on allocation functions (BZ#23741)


On Fri, Nov 09, 2018 at 03:23:55PM -0800, Paul Eggert wrote:
> On 11/9/18 7:11 AM, Adhemerval Zanella wrote:
> >It seems that some*very*  specific programs do allocate objects larger PTRDIFF_MAX,
> 
> On the other hand, GNU coreutils, GNU Emacs and several other
> programs do just the opposite: they uses wrappers around malloc that
> fail without calling malloc if the requested size exceeds
> PTRDIFF_MAX. This is to avoid the compiler gotchas mentioned in this
> thread.
> 
> For almost all applications malloc and friends should never allocate
> such objects as they cause more problems than they cure. The very
> few applications that need and can safely use objects larger than
> PTRDIFF_MAX can use mmap. And for mmap, I wouldn't mind if glibc
> mmap added a flag MMAP_EXCEED_PTRDIFF, so that mmap could reject
> requests for sizes greater than PTRDIFF_MAX unless this new flag is
> used.

It would be nice if such a flag were practical, but Linux went and
wasted all the bits on dubious hugetlb stuff, making those left a
precious resource.

Rich


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]