From owner-freebsd-hackers@FreeBSD.ORG Mon Jul 6 18:26:19 2009 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 4CBBB106567A for ; Mon, 6 Jul 2009 18:26:19 +0000 (UTC) (envelope-from freebsd-listen@fabiankeil.de) Received: from smtprelay09.ispgateway.de (smtprelay09.ispgateway.de [80.67.31.43]) by mx1.freebsd.org (Postfix) with ESMTP id D361D8FC1F for ; Mon, 6 Jul 2009 18:26:18 +0000 (UTC) (envelope-from freebsd-listen@fabiankeil.de) Received: from [62.143.132.243] (helo=localhost) by smtprelay09.ispgateway.de with esmtpsa (TLSv1:AES128-SHA:128) (Exim 4.68) (envelope-from ) id 1MNsuV-0003qu-5f for freebsd-hackers@freebsd.org; Mon, 06 Jul 2009 20:27:28 +0200 Date: Mon, 6 Jul 2009 20:26:08 +0200 From: Fabian Keil To: freebsd-hackers@freebsd.org Message-ID: <20090706202608.45c98821@fabiankeil.de> In-Reply-To: <4A50E3F2.8080008@FreeBSD.org> References: <20090705182856.799b6b07@fabiankeil.de> <4A50E3F2.8080008@FreeBSD.org> X-Mailer: Claws Mail 3.7.2 (GTK+ 2.16.2; i386-portbld-freebsd8.0) X-PGP-KEY-URL: http://www.fabiankeil.de/gpg-keys/freebsd-listen-2008-08-18.asc Mime-Version: 1.0 Content-Type: multipart/signed; micalg=PGP-SHA1; boundary="Sig_/fYmYfL1q3FDwUL+INd9DA4n"; protocol="application/pgp-signature" X-Df-Sender: 775067 Subject: Re: Zero-length allocation with posix_memalign() X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 06 Jul 2009 18:26:19 -0000 --Sig_/fYmYfL1q3FDwUL+INd9DA4n Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Jason Evans wrote: > Fabian Keil wrote: > > R=E9mi Denis-Courmont, one of the vlc developers, pointed out > > that passing a zero size to posix_memalign() should actually > > work, though: > >=20 > > | In principle, while useless, there is no reason why allocating an emp= ty=20 > > | picture should not be possible. posix_memalign() does support zero-le= ngth=20 > > | allocation anyway: > > | http://www.opengroup.org/onlinepubs/9699919799/functions/posix_memali= gn.html > > | | If the size of the space requested is 0, the behavior is > > | | implementation-defined; the value returned in memptr shall be eithe= r a > > | | null pointer or a unique pointer. >=20 > Standards: So many to choose from. This behavior for posix_memalign was= =20 > only defined as of the 2008 standard (see the Issue 7 notes for=20 > posix_memalign): >=20 > https://www.opengroup.org/austin/interps/uploads/40/14543/AI-152.txt >=20 > Such requirements are unfortunate, because they induce a performance=20 > penalty for every call, just so that programs can avoid proper handling=20 > of edge cases in the rare situations for which such edge cases are a=20 > real possibility. >=20 > I will add the pessimization to posix_memalign once the 8.0 freeze is=20 > over. It will be quite some time before this behavior becomes=20 > ubiquitous, so in the meanwhile it's probably a good idea to modify vlc=20 > to avoid such allocation requests. Great, thanks. I agree and will forward the vlc patch to the maintainer of the FreeBSD port if getting it committed upstream fails. Fabian --Sig_/fYmYfL1q3FDwUL+INd9DA4n Content-Type: application/pgp-signature; name=signature.asc Content-Disposition: attachment; filename=signature.asc -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.12 (FreeBSD) iEYEARECAAYFAkpSQcYACgkQBYqIVf93VJ15jACdFF1748pnTxPqe/Yxl2qW53lk Cm8AoLn6d1kM13FsdDw+UiR7FTmLqSiq =fEG8 -----END PGP SIGNATURE----- --Sig_/fYmYfL1q3FDwUL+INd9DA4n--