Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm 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 Delivered-To: cgf-cygwin AT cygwin DOT com Message-ID: <754324CDE8E4EE4498D8E0357D913685D4D16B@saab-bt.act.cmis.CSIRO.AU> From: brett DOT matson AT csiro DOT au To: cygwin AT cygwin DOT com Cc: cgf-cygwin AT cygwin DOT com Subject: RE: 1.3.20: mmap with nonzero file offset results in seg fault (W in2k )" Date: Tue, 25 Feb 2003 16:51:33 +1100 MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----_=_NextPart_000_01C2DC91.F3C586DC" Note-from-DJ: This may be spam ------_=_NextPart_000_01C2DC91.F3C586DC Content-Type: text/plain; charset="iso-8859-1" Christopher, a few points about your comments: 1. I wasn't asking for help. This bug report wasn't for our benefit. We're content to use version 1.3.19. 2. Next time, read the man page: "The actual place where the object is mapped is returned by mmap, and is never 0." - mmap man page Despite your warm welcome to the group, I have attached a full test case. After further inspection it appears that the seg fault only occurs if the file offset is greater than 16 system pages. The seg fault only occurs in version 1.3.20. The TEST_FILE macro needs to be set to the name of a file that is larger than 16 system pages + 32 bytes. Brett -----Original Message----- From: Christopher Faylor [mailto:cgf-cygwin AT cygwin DOT com] Sent: Tuesday, February 25, 2003 1:28 PM To: cygwin AT cygwin DOT com Subject: Re: 1.3.20: mmap with nonzero file offset results in seg fault (Win2k )" On Tue, Feb 25, 2003 at 12:49:45PM +1100, brett DOT matson AT csiro DOT au wrote: > >Accessing the mapped region of memory after an mmap call >with a non-zero offset results in a seg fault. A zero >offset will not result in a seg fault. > >Cygwin1.dll version 1.3.19 doesn't experience this problem. >Cygcheck output is attached. > >Example: > >if (rslt = mmap(0, size, prot, MAP_SHARED, fd, offset)) > == MAP_FAILED) { >} else { > printf("%d", rslt[0]); // seg fault >} >AND >if (rslt = mmap(0, size, prot, MAP_SHARED, fd, 0)) > == MAP_FAILED) { >} else { > printf("%d", rslt[0]); // no seg fault (zero offset) >} The above is bogus code since rslt will be equal to either 1 or 0 depending on whether mmap failed or not. Please provide a real working test case which can be cut, pasted, compiled, linked, and run, if you want help. The theory is that, if you want help, you reduce the barrier of providing the help as much as possible. Providing buggy examples isn't going to do that. cgf -- Please use the resources at cygwin.com rather than sending personal email. Special for spam email harvesters: send email to aaaspam AT sourceware DOT org and be permanently blocked from mailing lists at sources.redhat.com ------_=_NextPart_000_01C2DC91.F3C586DC Content-Type: text/plain; name="mmaptest.c.txt" Content-Disposition: attachment; filename="mmaptest.c.txt" #include #include #include #include #include #define MAP_SIZE 32 #define TEST_FILE "textfile.txt" // TEST_FILE must be larger than a (16 * pagesize) + 32 bytes int main(int argc, char **argv) { int fd, offset; void * startAddr; fd = open(TEST_FILE, O_RDONLY); /* map with non-zero offset */ offset = 0; startAddr = mmap(0, MAP_SIZE, PROT_READ, MAP_SHARED, fd, offset); printf("Mapped file with zero offset at %d\n", (int)startAddr); printf("%c\n", *((char *)startAddr)); munmap(startAddr, MAP_SIZE); /* map with non-zero offset */ offset = 16 * getpagesize(); startAddr = mmap(0, MAP_SIZE, PROT_READ, MAP_SHARED, fd, offset); printf("Mapped file with nonzero offset at %d\n", (int)startAddr); printf("%c\n", *((char *)startAddr)); munmap(startAddr, MAP_SIZE); close(fd); return 0; } ------_=_NextPart_000_01C2DC91.F3C586DC Content-Type: text/plain; charset=us-ascii -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Bug reporting: http://cygwin.com/bugs.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/ ------_=_NextPart_000_01C2DC91.F3C586DC--