This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Segfault in MAP_NORESERVE mmap above ~4GB


Hi Erik,

On May 12 15:30, Erik Bray wrote:
> Hi all,
> 
> This issue pertains to Cygwin 64-bit.  The following example program
> demonstrates the issue:
> 
> $ cat mmap_test.c
> #include <sys/mman.h>
> #include <stdio.h>
> #include <windows.h>
> 
> 
> #define VSIZE 0x100001000
> #define SIZE 0x1000
> 
> 
> void foo() {
>     void *top, *bot, *c;
> 
>     c = mmap(NULL, VSIZE, PROT_READ|PROT_WRITE,
>              MAP_PRIVATE|MAP_ANONYMOUS|MAP_NORESERVE, -1, 0);
> 
>     top = c + VSIZE;
>     bot = top - SIZE;
> 
>     printf("     c = 0x%016lx\n", c);
>     printf("   top = 0x%016lx\n", top);
>     printf("   bot = 0x%016lx\n", bot);
> 
>     printf("  c[0] = %ul\n", *((unsigned long *)c));
>     printf("bot[0] = %ul\n", *((unsigned long *)bot));
> }
> 
> 
> int main(void) {
>     foo();
>     return 0;
> }
> 
> $ gcc mmap_test.c -o mmap_test
> 
> $ ./mmap_test.exe
>      c = 0x000006feffff0000
>    top = 0x000006ffffff1000
>    bot = 0x000006ffffff0000
>   c[0] = 0l
> Segmentation fault (core dumped)
> 
> --------------------------------------------------

Thanks especially for the testcase.  I just applied a fix for this
which, hopefully, catches all problems with too small length/size
variables and parameters.

I've uploaded a new developer snapshot to https://cygwin.com/snapshots/

Would you mind to inspect the patch(*) critically?


Thanks a lot,
Corinna


(*) https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;a=commitdiff;h=0aa738220bb9dea2ad479e484560767b36701947

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

Attachment: signature.asc
Description: PGP signature


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]