X-Recipient: archive-cygwin AT delorie DOT com X-Spam-Check-By: sourceware.org Date: Wed, 23 Mar 2011 19:15:07 +0100 From: Corinna Vinschen To: cygwin AT cygwin DOT com Subject: Re: Broken autoconf mmap test Message-ID: <20110323181507.GV31220@calimero.vinschen.de> Reply-To: cygwin AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com References: <4D890D95 DOT 6090302 AT redhat DOT com> <4D891A55 DOT 6050601 AT cornell DOT edu> <20110323091921 DOT GB10657 AT calimero DOT vinschen DOT de> <4D89D4AA DOT 6070903 AT cornell DOT edu> <20110323132622 DOT GM31220 AT calimero DOT vinschen DOT de> <4D89FEC7 DOT 3000107 AT cornell DOT edu> <20110323154421 DOT GN31220 AT calimero DOT vinschen DOT de> <4D8A308F DOT 508 AT cornell DOT edu> <4D8A3206 DOT 7070502 AT redhat DOT com> <4D8A3329 DOT 7050009 AT redhat DOT com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <4D8A3329.7050009@redhat.com> User-Agent: Mutt/1.5.21 (2010-09-15) Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com 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 man page: "The address range starting at pa and continuing for len bytes shall be legitimate for the possible (not necessarily current) address space of the process. [...] 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 bytes. 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 -- Corinna Vinschen Please, send mails regarding Cygwin to Cygwin Project Co-Leader cygwin AT cygwin DOT com Red Hat -- Problem reports: http://cygwin.com/problems.html FAQ: http://cygwin.com/faq/ Documentation: http://cygwin.com/docs.html Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple