Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 12 Dec 2006 11:43:14 +1100
From:      Andrew Reilly <andrew@areilly.bpc-users.org> (by way of Andrew Reilly <andrew-freebsd@areilly.bpc-users.org>)
To:        Dan Nelson <dnelson@allantgroup.com>
Cc:        Luigi Rizzo <rizzo@icir.org>, stable@freebsd.org
Subject:   Re: malloc(0) returns 0x800 on FreeBSD 6.2 ?
Message-ID:  <20061212114314.39542337@duncan.reilly.home>
Resent-Message-ID: <20061212114439.42d40d48@duncan.reilly.home>
In-Reply-To: <20061211182544.GG69299@dan.emsphone.com>
References:  <20061211094423.B44819@xorpc.icir.org> <20061211182544.GG69299@dan.emsphone.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On Mon, 11 Dec 2006 12:25:44 -0600
Dan Nelson <dnelson@allantgroup.com> 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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20061212114314.39542337>