From owner-freebsd-current@FreeBSD.ORG Sat Jan 5 13:50:46 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 7F0F516A4C0; Sat, 5 Jan 2008 13:50:46 +0000 (UTC) (envelope-from des@des.no) Received: from tim.des.no (tim.des.no [194.63.250.121]) by mx1.freebsd.org (Postfix) with ESMTP id 51D0513C458; Sat, 5 Jan 2008 13:50:46 +0000 (UTC) (envelope-from des@des.no) Received: from tim.des.no (localhost [127.0.0.1]) by spam.des.no (Postfix) with ESMTP id 620072099; Sat, 5 Jan 2008 14:50:37 +0100 (CET) X-Spam-Tests: AWL X-Spam-Learn: disabled X-Spam-Score: -0.2/3.0 X-Spam-Checker-Version: SpamAssassin 3.2.3 (2007-08-08) on tim.des.no Received: from ds4.des.no (des.no [80.203.243.180]) by smtp.des.no (Postfix) with ESMTP id 41682207E; Sat, 5 Jan 2008 14:50:37 +0100 (CET) Received: by ds4.des.no (Postfix, from userid 1001) id 1D235844C3; Sat, 5 Jan 2008 14:50:37 +0100 (CET) From: =?utf-8?Q?Dag-Erling_Sm=C3=B8rgrav?= To: Robert Watson References: <86myrlahee.fsf@ds4.des.no> <5647.1199451237@critter.freebsd.dk> <86abnlag4t.fsf@ds4.des.no> <20080104132310.X77222@fledge.watson.org> Date: Sat, 05 Jan 2008 14:50:37 +0100 In-Reply-To: <20080104132310.X77222@fledge.watson.org> (Robert Watson's message of "Fri\, 4 Jan 2008 13\:24\:28 +0000 \(GMT\)") Message-ID: <86odc08jpu.fsf@ds4.des.no> User-Agent: Gnus/5.110006 (No Gnus v0.6) Emacs/22.1 (berkeley-unix) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Cc: Poul-Henning Kamp , freebsd-current@freebsd.org, Jason Evans , Igor Mozolevsky 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: Sat, 05 Jan 2008 13:50:46 -0000 Robert Watson writes: > Another aspect of the problem is that applications have come to depend > in malloc(3) returning NULL when memory is getting tight [...] I don't do that any more. Unless the program I'm writing is intended to run for a long time and can gracefully handle an out-of-memory situation (such as denying client requests until the situation improves), I write malloc() wrappers which zero the allocated region before returning to the caller, to force a SIGSEGV and spare the caller from having to check the return value. I sometimes also allocate a little bit extra and stick a magic signature and an allocation length in there so my free() wrapper can check for bugs and zero the allocated memory before freeing it. I wouldn't need any of this if my code only ran on FreeBSD, but most of my $DAYTIME_JOB code these days runs on Linux first and FreeBSD second. DES --=20 Dag-Erling Sm=C3=B8rgrav - des@des.no