From owner-freebsd-stable@FreeBSD.ORG Tue Dec 12 01:47:58 2006 Return-Path: X-Original-To: stable@freebsd.org Delivered-To: freebsd-stable@FreeBSD.ORG Received: from mx1.FreeBSD.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 75A1516A492 for ; Tue, 12 Dec 2006 01:47:58 +0000 (UTC) (envelope-from andrew@areilly.bpc-users.org) Received: from qsrv03sl.mx.bigpond.com (qsrv03sl.mx.bigpond.com [144.140.92.183]) by mx1.FreeBSD.org (Postfix) with ESMTP id D3B5643E4A for ; Tue, 12 Dec 2006 01:44:58 +0000 (GMT) (envelope-from andrew@areilly.bpc-users.org) Received: from oaamta02sl.mx.bigpond.com ([144.132.138.2]) by omta02sl.mx.bigpond.com with ESMTP id <20061212004333.TOEP17746.omta02sl.mx.bigpond.com@oaamta02sl.mx.bigpond.com> for ; Tue, 12 Dec 2006 00:43:33 +0000 Received: from areilly.bpa.nu ([144.132.138.2]) by oaamta02sl.mx.bigpond.com with ESMTP id <20061212004333.FGMN2695.oaamta02sl.mx.bigpond.com@areilly.bpa.nu> for ; Tue, 12 Dec 2006 00:43:33 +0000 Received: (qmail 74682 invoked from network); 12 Dec 2006 00:43:14 -0000 Received: from localhost (HELO duncan.reilly.home) (127.0.0.1) by localhost with SMTP; 12 Dec 2006 00:43:14 -0000 Date: Tue, 12 Dec 2006 11:43:14 +1100 From: Andrew Reilly To: Dan Nelson Message-ID: <20061212114314.39542337@duncan.reilly.home> In-Reply-To: <20061211182544.GG69299@dan.emsphone.com> References: <20061211094423.B44819@xorpc.icir.org> <20061211182544.GG69299@dan.emsphone.com> X-Mailer: Sylpheed-Claws 2.5.2 (GTK+ 2.10.6; amd64-portbld-freebsd6.2) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Cc: Luigi Rizzo , stable@freebsd.org Subject: Re: malloc(0) returns 0x800 on FreeBSD 6.2 ? X-BeenThere: freebsd-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Production branch of FreeBSD source code List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 12 Dec 2006 01:47:58 -0000 On Mon, 11 Dec 2006 12:25:44 -0600 Dan Nelson wrote: > The FreeBSD 6.x behaviour is slightly against POSIX rules that state > all successful malloc calls must return unique pointers, so the 7.x > malloc silently rounds zero-size mallocs to 1. Ideally malloc would > return unique pointers to blocks of memory set to MPROT_NONE via > mprotect() (you could fit 8192 of these pointers in an 8k page), to Could you, really? I'm not a language lawyer, and this is a language-lawyer question, but I would have expected that the maximal alignment rule would prevent you from allocating more than 512 or 1024 "unique, valid" pointers in a page. Perhaps there is no alignment requirement on a zero-byte object? Just curious. I don't care about the actual implementation, and I thought that handing out a special MPROT_NONE page was a good idea... > prevent applications from using that byte of memory. Cheers, -- Andrew