On Tue, Jul 09, 2019 at 10:24:53AM -0700, Graham Percival wrote: > RLIMIT_DATA > This is the maximum size of a data segment of the process, in bytes. If > this limit is exceeded, the malloc() function shall fail with errno set > to > [ENOMEM]. > http://pubs.opengroup.org/onlinepubs/9699919799/functions/getrlimit.html > > The relevant part is the second sentence. My interpretation of that sentence > is that if malloc() does *not* fail when it is asked to exceed RLIMIT_DATA, > then it is not following the POSIX standard.
Ah, but how do you ask malloc to exceed RLIMIT_DATA? Not by passing it a large number, or any number, since that doesn't change the size of any data segment. I think a program image whose .data exceeds RLIMIT_DATA won't load, so in that case any call to malloc will indeed fail with errno set to ENOMEM, inasmuch as anything follows from an invalid premise. Although now I wonder if ld.so enforces RLIMIT_DATA on the .data size of shared library images. (Note: if you're trying to do something practical, you might find RLIMIT_AS or RLIMIT_RSS more helpful.) -- David A. Holland dholl...@netbsd.org