1.5.19 src/winsup/cygwin/mmap.cc msync() still calling getpagesize rather than getsystempagesize

Corinna Vinschen corinna-cygwin@cygwin.com
Wed Aug 16 20:45:00 GMT 2006


On Aug 16 11:43, Donna Jecha wrote:
> In the function msync in the file src/winsup/cygwin/mmap.cc, the declaration for pagesize goes out of its way to invoke either getsystempagesize -or- getpagesize():
> 
> 
> 1366    size_t pagesize = wincap.has_mmap_alignment_bug () ?
> 1367                      getsystempagesize () : getpagesize ();
> 
> 
> Later in this same function, however, only getpagesize() is called:
> 
> 
> 1393 for (DWORD i = getpagesize (); i < len; i += getpagesize ())
> 
> 
> Shouldn't the getpagesize invocation at line 1383 also be conditional as to which gets called as is done on line 1367???

Maybe, I have to have another look into that.  But that can't be the
reason for the ENOMEM problem since getpagesize is definitely correct
for NT systems as you're using.  getsystempagesize is only the right
choice for systems with the mmap alignment bug, which are 95/98/Me.
I'm not overly concerned by that since 9x support is phased out anyway.

> fsx is a file system exerciser program.  It has proven to be a good test case for finding corruption problems.  The fsx program works on cygwin 1.5.18, but not on cygwin 1.5.19.  On cygwin 1.5.19, msync always returns a status of -1 and sets errno to ENOMEM.  Here's the code snippet:
> 
> 673          pg_offset = offset & page_mask;
>  674          map_size  = pg_offset + size;
>  675
>  676          if ((p = (char *)mmap(0, map_size, PROT_READ | PROT_WRITE,
>  677                                MAP_FILE | MAP_SHARED, fd,
>  678                                (off_t)(offset - pg_offset))) == (char *)-1) {
>  679                  prterr("domapwrite: mmap");
>  680                  report_failure(202);
>  681          }
>  682          memcpy(p + pg_offset, good_buf + offset, size);  // status of memcpy is not checked ... yet
>  683          if (msync(p, map_size, 0) != 0) {
>  684                  prterr("domapwrite: msync");
>  685                  report_failure(203);
>  686          }
>  687
>  688          check_eofpage("Write", offset, p, size);
>  689
>  690          if (munmap(p, map_size) != 0) {
>  691                  prterr("domapwrite: munmap");
>  692                  report_failure(204);
>  693          }

Would you mind to create a self-contained, *minimal* testcase from that?
The snippet alone seems correct but I'm missing a few parameters like,
for instance the values of offset and page_mask, etc.  If you could
create a tiny testcase which builds out of the box and reproduces the
problem, that would be enourmeously helpful.


Thanks in advance,
Corinna

-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Project Co-Leader          cygwin AT cygwin DOT com
Red Hat

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/



More information about the Cygwin mailing list