From owner-freebsd-hackers@FreeBSD.ORG Mon Jul 20 06:27:26 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 79401106564A for ; Mon, 20 Jul 2009 06:27:26 +0000 (UTC) (envelope-from mel.flynn+fbsd.hackers@mailing.thruhere.net) Received: from mailhub.rachie.is-a-geek.net (rachie.is-a-geek.net [66.230.99.27]) by mx1.freebsd.org (Postfix) with ESMTP id 1D6348FC0A for ; Mon, 20 Jul 2009 06:27:25 +0000 (UTC) (envelope-from mel.flynn+fbsd.hackers@mailing.thruhere.net) Received: from mx1.sbmail.office-on-the.net (mx1.sbmail.office-on-the.net [192.168.2.107]) by mailhub.rachie.is-a-geek.net (Postfix) with ESMTP id 6370B7E818 for ; Sun, 19 Jul 2009 22:27:25 -0800 (AKDT) Received: by mx1.sbmail.office-on-the.net (Postfix, from userid 125) id CEEB1C2C800; Sun, 19 Jul 2009 22:33:53 -0800 (AKDT) Received: from dspam.sbmail.office-on-the.net (mx1.sbmail.office-on-the.net [192.168.2.107]) by mx1.sbmail.office-on-the.net (Postfix) with SMTP id 45F38C2C802 for ; Sun, 19 Jul 2009 22:13:51 -0800 (AKDT) Received: from webmail.testbox.ath.cx (mx1.sbmail.office-on-the.net [192.168.2.107]) by mx1.sbmail.office-on-the.net (Postfix) with ESMTP id F237DC2C800; Sun, 19 Jul 2009 22:13:48 -0800 (AKDT) MIME-Version: 1.0 Date: Sun, 19 Jul 2009 22:13:48 -0800 From: Mel Flynn To: John Baldwin In-Reply-To: <200907131639.10346.jhb@freebsd.org> References: <200907131428.08923.jhb@freebsd.org> <200907132133.52217.tijl@ulyssis.org> <200907131639.10346.jhb@freebsd.org> Message-ID: X-Sender: mel.flynn+fbsd.hackers@mailing.thruhere.net User-Agent: RoundCube Webmail/0.2 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-DSPAM-Result: Innocent X-DSPAM-Processed: Sun Jul 19 22:13:50 2009 X-DSPAM-Confidence: 1.0000 X-DSPAM-Improbability: 1 in 98689407 chance of being spam X-DSPAM-Probability: 0.0023 X-DSPAM-Signature: 54,4a640b1e44756072160320 X-DSPAM-Factors: 27, "uap+>len, 0.40000, Received*Sun+19, 0.40000, ccache+CALL, 0.40000, ccache+CALL, 0.40000, On+Monday, 0.40000, On+Monday, 0.40000, right, 0.40000, smoochies+rachie, 0.40000, smoochies+rachie, 0.40000, so+excuse, 0.40000, 2009+16, 0.40000, 229, 0.40000, 229, 0.40000, tree+recently, 0.40000, John+Baldwin, 0.40000, John+Baldwin, 0.40000, Cc*hackers+freebsd.org>, 0.40000, into+numeric, 0.40000, Cc*Best, 0.40000, an, 0.40000, Cc*Coosemans+, 0.40000, Received*webmail.testbox.ath.cx, 0.40000, from, 0.40000, from, 0.40000, 16+39, 0.40000 Cc: Nate Eldredge , Tijl Coosemans , Alexander Best , Alan Cox , freebsd-hackers@freebsd.org Subject: Re: mmap/munmap with zero length 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, 20 Jul 2009 06:27:26 -0000 On Mon, 13 Jul 2009 16:39:09 -0400, John Baldwin wrote: > On Monday 13 July 2009 3:33:51 pm Tijl Coosemans wrote: >> On Monday 13 July 2009 20:28:08 John Baldwin wrote: >> > On Sunday 05 July 2009 3:32:25 am Alexander Best wrote: >> >> so mmap differs from the POSIX recommendation right. the malloc.con= f >> >> option seems more like a workaround/hack. imo it's confusing to hav= e >> >> mmap und munmap deal differently with len=3D0. being able to >> >> succesfully alocate memory which cannot be removed doesn't seem >> >> logical to me. >> >=20 >> > This should fix it: >> >=20 >> > --- //depot/user/jhb/acpipci/vm/vm_mmap.c >> > +++ /home/jhb/work/p4/acpipci/vm/vm_mmap.c >> > @@ -229,7 +229,7 @@ >> >=20 >> > fp =3D NULL; >> > /* make sure mapping fits into numeric range etc */ >> > - if ((ssize_t) uap->len < 0 || >> > + if ((ssize_t) uap->len <=3D 0 || >> > ((flags & MAP_ANON) && uap->fd !=3D -1)) >> > return (EINVAL); >>=20 >> Why not "uap->len =3D=3D 0"? Sizes of 2GiB and more (32bit) shouldn't = cause >> an error. >=20 > I don't actually disagree and know of locally modified versions of FreeBSD=20 > that remove this check for precisely that reason. If this has hit the tree recently, I think it broke ccache. Since I've also done make delete-old-libs and was about to rebuild all my ports on my laptop, I'll investigate, as I'm not looking forward to doing this twice for all dependants of libtool :(. Failed to mmap /var/db/ccache/mel/tmp.cpp_stderr.smoochies.rachie.is-a-geek.net.27934 kdump: 27934 ccache CALL open(0x28201280,O_RDONLY,0x1) 27934 ccache NAMI=20 "/var/db/ccache/mel/tmp.cpp_stderr.smoochies.rachie.is-a-geek.net.27934" 27934 ccache RET open 4 27934 ccache CALL fstat(0x4,0xbfbfe7fc) 27934 ccache STRU struct stat {dev=3D105, ino=3D895320, mode=3D-rw-r-= -r-- , nlink=3D1, uid=3D1003, gid=3D0, rdev=3D0, atime=3D1248069251, stime=3D124= 8069251, ctime=3D1248069251, birthtime=3D1248069251, size=3D0, blksize=3D4096, blo= cks=3D0, flags=3D0x0 } 27934 ccache RET fstat 0 27934 ccache CALL mmap(0,0,PROT_READ,MAP_PRIVATE,0x4,0,0) 27934 ccache RET mmap -1 errno 22 Invalid argument Sent from webmail, so excuse any formatting issues. --=20 Mel