This is the mail archive of the
mailing list for the Cygwin project.
Re: Broken autoconf mmap test
On Mar 23 11:51, Eric Blake wrote:
> On 03/23/2011 11:46 AM, Eric Blake wrote:
> > On 03/23/2011 11:40 AM, Ken Brown wrote:
> >>> Usually it shouldn't. While you can write into a mmaped area beyond
> >>> EOF up to the end of the last page, it doesn't make a lot of sense.
> >>> The data will never show up in the mapped file.
> Hmm, rereading POSIX:
> If the size of the mapped file changes after the call to mmap( ) as a
> result of some other operation
> on the mapped file, the effect of references to portions of the mapped
> region that correspond to
> added or removed portions of the file is unspecified.
That has nothing to do with what the autoconf test tests. Consider a
filesize of 1 bytes and a pagesize of 4K. Since mmap always returns
full pages, the file is mapped into a single 4K page.
The autoconf test only test if you can access the entire page in memory,
and if this page is filled with 0-bytes.
It does not test what happens if you change the file after calling mmap.
> > Unless the right thing to do in autoconf is to separate the test into
> > two levels; one of whether most mmap works but you can't extend files
> > (cygwin always passes) and one whether writing beyond EOF works as
> > required by POSIX (cygwin currently fails on W64, but hopefully fewer
> > packages rely on this stricter behavior). Or figure out a way to make
> > cygwin work around the W64 limitations.
> I'm still debating if cygwin is compliant and the autoconf test is
> exploiting undefined behavior... this is tricky stuff to get right.
Cygwin tries to be as compliant as possible, and it tries to implement
expectations which are typical for some Unix systems even if they are
not covered by the standards.
And yes, the autoconf test tests defined behaviour, see the SUSv4 mmap
"The address range starting at pa and continuing for len bytes shall be
legitimate for the possible (not necessarily current) address space of
The system performs mapping operations over whole pages. Thus, while
the parameter len need not meet a size or alignment constraint, the
system shall include, in any mapping operation, any partial page
specified by the address range starting at pa and continuing for len
The system shall always zero-fill any partial page at the end of an
object. Further, the system shall never write out any modified
portions of the last page of an object which are beyond its end."
Corinna Vinschen Please, send mails regarding Cygwin to
Cygwin Project Co-Leader cygwin AT cygwin DOT com
Problem reports: http://cygwin.com/problems.html
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple