From owner-freebsd-current@FreeBSD.ORG Fri Jan 4 14:22:28 2008 Return-Path: Delivered-To: freebsd-current@FreeBSD.ORG Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id C949B16A41B for ; Fri, 4 Jan 2008 14:22:28 +0000 (UTC) (envelope-from ache@nagual.pp.ru) Received: from nagual.pp.ru (nagual.pp.ru [194.87.13.69]) by mx1.freebsd.org (Postfix) with ESMTP id 41E8A13C457 for ; Fri, 4 Jan 2008 14:22:27 +0000 (UTC) (envelope-from ache@nagual.pp.ru) Received: from nagual.pp.ru (ache@localhost [127.0.0.1]) by nagual.pp.ru (8.14.2/8.14.2) with ESMTP id m04EMQBv018841 for ; Fri, 4 Jan 2008 17:22:27 +0300 (MSK) (envelope-from ache@nagual.pp.ru) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nagual.pp.ru; s=default; t=1199456547; bh=E+L7PVgXtpLBHXl6Qfuh+Edkk06i/ApaXUuaCg1 xlrs=; l=1291; h=Date:From:To:Subject:Message-ID:Mail-Followup-To: References:MIME-Version:Content-Type:Content-Disposition: In-Reply-To:User-Agent; b=TePzR9U5leHB48e4l8BkbXpPt/a9y0IEhACqCtRS nRkU/iMZ9J9prroUVK+MQqfaEOl857wepmgDiDmKRgDkf6t0Q5yNiEudmdxl+Y+GS4m PZdiLTQ1aHTn5n9qPVzm7PjKyhR2uC5MWlTl9F8UtNyUVQEF3A4VbUVfrOpfU0D8= Received: (from ache@localhost) by nagual.pp.ru (8.14.2/8.14.2/Submit) id m04EMQbO018840 for freebsd-current@FreeBSD.ORG; Fri, 4 Jan 2008 17:22:26 +0300 (MSK) (envelope-from ache) Date: Fri, 4 Jan 2008 17:22:26 +0300 From: Andrey Chernov To: freebsd-current@FreeBSD.ORG Message-ID: <20080104142226.GA18773@nagual.pp.ru> Mail-Followup-To: Andrey Chernov , freebsd-current@FreeBSD.ORG References: <20080104122149.GA17103@nagual.pp.ru> <5705.1199451431@critter.freebsd.dk> <20080104131247.GA17816@nagual.pp.ru> <20080104132545.GA51075@outcold.yadt.co.uk> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20080104132545.GA51075@outcold.yadt.co.uk> User-Agent: Mutt/1.5.17 (2007-11-01) Cc: Subject: Re: sbrk(2) broken X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 Jan 2008 14:22:28 -0000 On Fri, Jan 04, 2008 at 01:25:45PM +0000, David Taylor wrote: > On Fri, 04 Jan 2008, Andrey Chernov wrote: > > > On Fri, Jan 04, 2008 at 12:57:11PM +0000, Poul-Henning Kamp wrote: > > > There is address space allocated to the process (via sbrk/mmap) > > > > > > A subset of this, is address space allocated by the program (via malloc) > > > > > > ...and then there is memory actually in use, which is an entirely different > > > thing, of which we currently only have some kind of clue in the VM > > > system. > > > > Then, we need sysctl to fetch that "memory actually in use" from the > > kernel and compare that with getrlimit() which allows malloc() to return > > 0 when needed. > > That won't help much -- malloc could have allocated some address space that > hasn't (yet) been touched by the process. Just returning 0 when the > amount of memory "in use" hits a limit wouldn't stop the process from > then touching all the memory it has previously been allocated and > exceeding the limit. In that case the process is subject to be killed by system, if exceeds its limits. But... this is not malloc() problem at all, malloc() designed to detect overflow situation, not prevent it. The malloc() problem is not returning 0. -- http://ache.pp.ru/