From owner-freebsd-stable@FreeBSD.ORG Tue Dec 12 00:46:25 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 2BCBC16A47B for ; Tue, 12 Dec 2006 00:46:25 +0000 (UTC) (envelope-from andrew@areilly.bpc-users.org) Received: from omta03sl.mx.bigpond.com (omta03sl.mx.bigpond.com [144.140.92.155]) by mx1.FreeBSD.org (Postfix) with ESMTP id 093A843CF4 for ; Tue, 12 Dec 2006 00:43:38 +0000 (GMT) (envelope-from andrew@areilly.bpc-users.org) Received: from oaamta03sl.mx.bigpond.com ([144.132.138.2]) by omta03sl.mx.bigpond.com with ESMTP id <20061212004445.LFTS4476.omta03sl.mx.bigpond.com@oaamta03sl.mx.bigpond.com> for ; Tue, 12 Dec 2006 00:44:45 +0000 Received: from areilly.bpa.nu ([144.132.138.2]) by oaamta03sl.mx.bigpond.com with ESMTP id <20061212004444.DDUL705.oaamta03sl.mx.bigpond.com@areilly.bpa.nu> for ; Tue, 12 Dec 2006 00:44:44 +0000 Received: (qmail 74761 invoked from network); 12 Dec 2006 00:44:39 -0000 Received: from duncan.reilly.home (10.0.0.6) by localhost with SMTP; 12 Dec 2006 00:44:39 -0000 AF: NF: 0 PS: 10 SRH: 1 SFN: DSR: MID: <20061212114153.588d9d54@duncan.reilly.home> CFG: PT: 0 S: andrew@areilly.bpc-users.org RQ: SSV: localhost NSV: SSH: R: ,, MAID: 1 X-Sylpheed-Privacy-System: X-Sylpheed-Sign: 0 SCF: #imap/andrew@localhost/INBOX/Sent RMID: #imap/andrew@localhost/INBOX/in_freebsd 0 20061211182544.GG69299@dan.emsphone.com X-Sylpheed-End-Special-Headers: 1 Date: Tue, 12 Dec 2006 11:43:14 +1100 From: Andrew Reilly (by way of 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 Resent-Date: Tue, 12 Dec 2006 11:44:39 +1100 Resent-From: Andrew Reilly Resent-Message-ID: <20061212114439.42d40d48@duncan.reilly.home> Resent-To: stable@freebsd.org 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 00:46:25 -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