Hi Lucian,
Lucian Cojocar wrote,

> Waldemar Brodkorb <wbx <at> ucibc-ng.org> writes:
> 
> > 
> > Hi Lucian,
> > Lucian Cojocar wrote,
> > 
> > > Hi,
> > > 
> > > Any follow-up on this patch?
> > 
> > Not yet. You are saying the second segmentation fault would be
> > expected. What is then the exact benefit of the patch, if the result
> > is a segfault? 
> 
> 'memset' will work on a range >= 2GB.
> 
> > Or do you have a simple testcase showing breakage before your patch
> > and non-breakage after?
> 
> Yes, I have a test which works in an environment where you can use more than 
> 2GB contiguous virtual memory (e.g. have enough swap to accommodate 2GB 
> contiguous virtual memory).
> 
> """
> #include <string.h>
> #include <stdio.h>
> #include <sys/mman.h>
> 
> #define GB (size_t)(1*(1 << 30ul))
> #define TWO_GB (2*(size_t)(GB))
> #define S (size_t)(TWO_GB+4096)
> 
> int
> main(void)
> {
>       char *p = NULL;
>       p = mmap(NULL, S, PROT_READ|PROT_WRITE, MAP_ANONYMOUS|MAP_PRIVATE, 
> -1, 0);
>       if (p == MAP_FAILED) {
>               perror("mmap");
>               exit(-1);
>       }
>       printf("&p[0] = %p\n", &p[0]);
>       printf("&p[S] = %p\n", &p[S]);
> 
>       printf("memsetting ...");
>       memset(p, 0xaa, S);
>       printf("done\n");
> 
>       printf("p[S-1]=%02x\n", (unsigned char)p[S-1]);
>       exit(0);
> }
> """
> 
> ~# ./main-buggy-memset.elf 
> &p[0] = 0x36f66000
> &p[S] = 0xb6f67000
> Segmentation fault
> ~# ./main-fixed-memset.elf 
> &p[0] = 0x36f8a000
> &p[S] = 0xb6f8b000
> memsetting ...done
> p[S-1]=aa
> ~# free -h
>              total       used       free     shared    buffers     cached
> Mem:          247M        56M       191M       252K       4.3M        33M
> -/+ buffers/cache:        19M       228M
> Swap:          10G        16M        10G

Applied and pushed,
 Thanks you,
   Waldemar
_______________________________________________
devel mailing list
devel@uclibc-ng.org
http://mailman.uclibc-ng.org/cgi-bin/mailman/listinfo/devel

Reply via email to