[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#247300: libc6: malloc() never fails on 2.4 kernels, making processes crash



Daniel Jacobowitz wrote:
On Fri, May 07, 2004 at 12:58:28AM +0200, Vincent Lefevre wrote:
[...]
This is precisely what I thought to be the bug in glibc: the fact
(at least with the 2.4 kernel) that this flag is used by glibc.
On which documentation is glibc based (in particular, concerning
old_mmap)?


I don't know.  The comments suggest malloc made the choice
deliberately, though, so I don't think it's appropriate to reverse it.

For what it's worth, this is in the malloc(3) manual page on my
Debian/sarge system (from the package manpages-dev-1.66-1)

BUGS
       By default, Linux follows an  optimistic  memory  allocation  strategy.
       This  means  that  when malloc() returns non-NULL there is no guarantee
       that the memory really is available. This is a really bad bug.  In case
       it  turns  out  that the system is out of memory, one or more processes
       will be killed by the infamous OOM killer.  In case Linux  is  employed
       under  circumstances  where it would be less desirable to suddenly lose
       some randomly picked processes, and moreover the kernel version is suf-
       ficiently recent, one can switch off this overcommitting behavior using
       a command like
              # echo 2 > /proc/sys/vm/overcommit_memory
       See also  the  kernel  Documentation  directory,  files  vm/overcommit-
       accounting and sysctl/vm.txt.

If somebody would like to submit a patch to manpages-dev, I'm sure it would save grief for other developers to have it clearly spelled out that glibc's malloc() uses the MAP_NORESERVE flag when allocating memory. It would tell people what to look for when reading the kernel documentation referred to.

--Steve Augart

--
Steven Augart

Jikes RVM, a free, open source, Virtual Machine:
http://oss.software.ibm.com/jikesrvm



Reply to: