Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 05 Jul 2009 09:32:25 +0200 (CEST)
From:      Alexander Best <alexbestms@math.uni-muenster.de>
To:        Nate Eldredge <neldredge@math.ucsd.edu>
Cc:        freebsd-hackers@freebsd.org
Subject:   Re: mmap/munmap with zero length
Message-ID:  <permail-200907050732251e86ffa8000022a8-a_best01@message-id.uni-muenster.de>
In-Reply-To: <Pine.GSO.4.64.0907041735580.4747@zeno.ucsd.edu>

next in thread | previous in thread | raw e-mail | index | archive | help
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



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