From owner-freebsd-hackers@FreeBSD.ORG Sun Jul 5 07:32:28 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 75CB51065670 for ; Sun, 5 Jul 2009 07:32:28 +0000 (UTC) (envelope-from a_best01@uni-muenster.de) Received: from zivm-out3.uni-muenster.de (ZIVM-OUT3.UNI-MUENSTER.DE [128.176.192.18]) by mx1.freebsd.org (Postfix) with ESMTP id 0BC1C8FC14 for ; Sun, 5 Jul 2009 07:32:27 +0000 (UTC) (envelope-from a_best01@uni-muenster.de) X-IronPort-AV: E=Sophos;i="4.42,351,1243807200"; d="scan'208";a="7600368" Received: from zivmaildisp2.uni-muenster.de (HELO ZIVMAILUSER03.UNI-MUENSTER.DE) ([128.176.188.143]) by zivm-relay3.uni-muenster.de with ESMTP; 05 Jul 2009 09:32:26 +0200 Received: by ZIVMAILUSER03.UNI-MUENSTER.DE (Postfix, from userid 149459) id 394201B0751; Sun, 5 Jul 2009 09:32:26 +0200 (CEST) Date: Sun, 05 Jul 2009 09:32:25 +0200 (CEST) From: Alexander Best Sender: Organization: Westfaelische Wilhelms-Universitaet Muenster To: Nate Eldredge Message-ID: In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Cc: 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: Sun, 05 Jul 2009 07:32:28 -0000 so mmap differs from the POSIX recommendation right. the malloc.conf option seems more like a workaround/hack. imo it's confusing to have mmap und munmap deal differently with len=0. being able to succesfully alocate memory which cannot be removed doesn't seem logical to me. alex Nate Eldredge schrieb am 2009-07-05: > On Sun, 5 Jul 2009, Alexander Best wrote: > >i'm wondering why mmap and munmap behave differently when it comes > >to a length > >argument of zero. allocating memory with mmap for a zero length > >file returns a > >valid pointer to the mapped region. > >munmap however isn't able to remove a mapping with no length. > >wouldn't it be better to either forbid this in mmap or to allow it > >in munmap? > POSIX has an opinion: > http://www.opengroup.org/onlinepubs/9699919799/functions/mmap.html > "If len is zero, mmap() shall fail and no mapping shall be > established." > http://www.opengroup.org/onlinepubs/9699919799/functions/munmap.html > "The munmap() function shall fail if: > ... > [EINVAL] > The len argument is 0." > -- > Nate Eldredge > neldredge@math.ucsd.edu