From owner-freebsd-stable@FreeBSD.ORG Wed Jul 23 23:58:39 2003 Return-Path: Delivered-To: freebsd-stable@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 7704837B404 for ; Wed, 23 Jul 2003 23:58:39 -0700 (PDT) Received: from mta02bw.bigpond.com (mta02bw.bigpond.com [144.135.24.138]) by mx1.FreeBSD.org (Postfix) with ESMTP id 1A1C643F85 for ; Wed, 23 Jul 2003 23:58:30 -0700 (PDT) (envelope-from areilly@bigpond.net.au) Received: from areilly.bpc-users.org ([144.135.24.72]) by mta02bw.email.bigpond.com (iPlanet Messaging Server 5.2 HotFix 1.14 (built Mar 18 2003)) with SMTP id <0HII008KQOC4D2@mta02bw.email.bigpond.com> for freebsd-stable@freebsd.org; Thu, 24 Jul 2003 16:50:28 +1000 (EST) Received: from cpe-144-132-191-61.nsw.bigpond.net.au ([144.132.191.61]) by bwmam02bpa.bigpond.com(MAM REL_3_3_2c 17/10252856); Thu, 24 Jul 2003 16:50:27 +0000 Received: (qmail 17832 invoked from network); Thu, 24 Jul 2003 06:50:28 +0000 Received: from unknown (HELO bigpond.net.au) (203.202.138.82) by localhost with SMTP; Thu, 24 Jul 2003 06:50:28 +0000 Date: Thu, 24 Jul 2003 16:49:34 +1000 From: Andrew Reilly In-reply-to: <5.2.0.9.0.20030723234250.052821e8@192.168.0.12> To: Mike Tancsa Message-id: <3F1F817E.7040504@bigpond.net.au> MIME-version: 1.0 Content-type: text/plain; charset=ISO-8859-1; format=flowed Content-transfer-encoding: 7BIT X-Accept-Language: en-us, en User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.5b) Gecko/20030716 Thunderbird/0.1a References: <20030723173427.GA72876@vmunix.com> <20030723173427.GA72876@vmunix.com> <5.2.0.9.0.20030723234250.052821e8@192.168.0.12> cc: Gabor cc: freebsd-stable@freebsd.org cc: Kris Kennaway Subject: Re: malloc does not return null when out of memory X-BeenThere: freebsd-stable@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Production branch of FreeBSD source code List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 24 Jul 2003 06:58:39 -0000 Mike Tancsa wrote: > At 08:15 PM 7/23/2003 -0700, Kris Kennaway wrote: > >> On Wed, Jul 23, 2003 at 01:34:27PM -0400, Gabor wrote: >> >> > Here is the tail end of the output. It dies when trying to poke at >> > the memory using memset. If I just malloc without the memset, it >> > never even dies. >> >> Ah, the annual "memory overcommit" thread. I thought we were overdue >> for one. > > > > But why does the man page for malloc (3) say, > > If malloc() fails, a NULL pointer is returned. Because that's what happens. See the subthread with the ulimit examples. In the cases being cited, the malloc itself is not failing, because it is able to return a pointer to a chunk of *VM*. The problem occurrs later, when the program attempts to read or write to that memory, and it doesn't occur because malloc was wrong, but because no other process has exited or unmapped something in the mean-time, to free up a page to back that address space. -- Andrew