This is the mail archive of the
cygwin@cygwin.com
mailing list for the Cygwin project.
Re: 1.1.3: mmap() returns unusable memory segments: segm fault
- To: Corinna Vinschen <cygwin at cygwin dot com>
- Subject: Re: 1.1.3: mmap() returns unusable memory segments: segm fault
- From: Lothar Linhard <lothar at concept dot de>
- Date: Tue, 6 Nov 2001 13:20:30 +0100 (W. Europe Standard Time)
Hi Corinna,
thanks, I've installed 1.3.4-2 and can verify that the problem
is fixed. I'm still enthusiastic about your response time.
However, here is another problem I have detected:
UNIX allows to do one unmap on memory space mapped by
several continous mmaps. Cygwin's munmap doesnt. I can
walk around this limitation, so this is (as far as I'm concerned)
a low priority request.
Here is my test case:
#include <stdio.h>
#include <sys/types.h>
#include <sys/mman.h>
int main() {
char* core1;
char* core2;
core1 = mmap(NULL,0x10000,PROT_READ|PROT_WRITE,MAP_SHARED|MAP_ANON,-1,0);
if (core1 == MAP_FAILED) goto mmap_err;
printf("mmap %p\n", core1);
core2 = mmap(NULL,0x20000,PROT_READ|PROT_WRITE,MAP_SHARED|MAP_ANON,-1,0);
if (core2 == MAP_FAILED) goto mmap_err;
printf("mmap %p\n", core2);
if (core1 + 0x10000 == core2) {
printf("merge %p...%p...%p\n", core1, core2, core1+0x30000);
/* consider core1 as continuous memory of 0x30000 bytes */
if (munmap(core1, 0x30000) == -1) goto munmap_err; /* FAIL */
} else {
if (munmap(core1, 0x10000) == -1) goto munmap_err; /* OK */
if (munmap(core2, 0x20000) == -1) goto munmap_err;
}
return 0;
mmap_err:
perror("mmap");
return 1;
munmap_err:
perror("munmap");
return 1;
}
---------------------- end of test case --------------------
On my NT 4.0 SP6 running cygwin 1.3.4-2 (see details attached),
I get:
ERDE$ gcc mtest2.c
ERDE$ ./a.exe
mmap 0x1a230000
mmap 0x1a240000
merge 0x1a230000...0x1a240000...0x1a260000
munmap: Invalid argument
Greetings,
Lothar.
On Tue, 6 Nov 2001, Corinna Vinschen wrote:
> Date: Tue, 6 Nov 2001 11:46:42 +0100
> From: Corinna Vinschen <cygwin@cygwin.com>
> To: cygwin <cygwin@cygwin.com>
> Subject: Re: 1.1.3: mmap() returns unusable memory segments: segm fault
>
> On Tue, Nov 06, 2001 at 11:16:07AM +0100, Lothar Linhard wrote:
> >
> > Wow! What a quick respond. Thank you.
> > I'll checkout the CVS tree (anoncvs@anoncvs.cygnus.com)
> > and see if I can compile cygwin.dll and run more mmap
> > tests.
>
> Chris has put the patch into 1.3.4-2 which should be on most mirrors
> in the meantime.
>
> However, there are already 5 mmap test applications in the testsuite
> so you can see what is already tested. I will probably add your test
> as the sixth.
>
> > Is there a list of limitations of Cygwin's mmap?
>
> No. There are limitations given due to OS restrictions. E.g. the
> addresses for mmaps which are always < 0x80000000 on NT/2K/XP and
> always >= 0x80000000 and < 0xc0000000 on 9x/ME which makes the usage
> of MAP_FIXED somewhat complicated. Or the missing VirtualProtect()
> on 9x/ME which doesn't allow to force an invalidation of pages after
> munmap(). I would suggest to look on http://msdn.microsoft.com into
> the description of MapViewOfFileEx() and CreateFileMapping(). Our
> mmap() impementation tries to tweak the Win32 calls so that mmap()
> behaves as POSIX conformant as possible but it's not easy to find
> all border conditions.
>
> Corinna
>
> --
> Corinna Vinschen Please, send mails regarding Cygwin to
> Cygwin Developer mailto:cygwin@cygwin.com
> Red Hat, Inc.
>
> --
> 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/
>
>
output of cygcheck -s -v -r
--
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/