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???

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          }


$ uname -a
CYGWIN_NT-5.1 test2vk 1.5.19(0.150/4/2) 2006-01-20 13:28 i686 Cygwin

[EMAIL PROTECTED] ~
$ which fsx
/cygdrive/c/bin/fsx

[EMAIL PROTECTED] ~
$ fsx testfile
skipping zero size read
skipping zero size read
truncating to largest ever: 0xa64
domapwrite: msync: Cannot allocate memory
LOG DUMP (6 total operations):
1(1 mod 256): SKIPPED (no operation)
2(2 mod 256): SKIPPED (no operation)
3(3 mod 256): TRUNCATE UP       from 0x0 to 0xa64
4(4 mod 256): WRITE     0x11833 thru 0x144de    (0x2cac bytes) HOLE
5(5 mod 256): MAPWRITE 0x1dfcb thru 0x1fd98     (0x1dce bytes)
6(6 mod 256): MAPWRITE 0xc8b1 thru 0x1056e      (0x3cbe bytes)
Correct content saved for comparison
(maybe hexdump "testfile" vs "testfile.fsxgood")

[EMAIL PROTECTED] ~
$

The amount of memory in the test machine seems to have no relevance, because it 
fails on all machines running cygwin 1.5.19 (One had 256MB of RAM, one had 
512MB of RAM, one had 1.2GB of RAM).  All failed quickly as above.

As requested, the output of the cygcheck -s -v -r command is attached.

Information about a similar problem reported:
*  Subject: mmap msync does not sync!!! 
*  From: "Brian Michael Genisio" <genisiob at pilot dot msu dot edu> 
*  Date: Wed, 20 Jun 2001 09:16:32 -0400 (EDT)

Sincerely,
D. Jecha



Donna K. Jecha
Test Engineer
Trusted Data Corporation
1881 Landings Drive
Landmark Business Complex, Building F
Mountain View, CA 94043-0848
http://www.trusteddata.com
Work:  (650) 691 2145

 



--
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/

Reply via email to