This is the mail archive of the glibc-bugs@sourceware.org mailing list for the glibc 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]

[Bug libc/4714] bus error when trying to access page created by mremap()


------- Additional Comments From tambewilliam at gmail dot com  2007-07-02 02:43 -------
Subject: Re:  New: bus error when trying to access page created
 by mremap()

I don't mean to press anybody, but please, can somebody help to find a 
work around if there is not immediate solutions.

Sincerely,
William Tambe


tambewilliam at gmail dot com wrote:
> In the code below, I mmap() a single page of 4096 and simply mremap() the same
> page to 2*4096 which is 8192.
> 
> Then when I try to write anywhere after 4096 bytes, in the newly expanded area.
> I get Bus error.
> 
> Can somebody please help me?
> 
> 
> #define _GNU_SOURCE
> #include <sys/mman.h>
> #include <unistd.h>
> 
> #include <stdio.h>
> 
> main() {
>         void *ptr;
>         if ((ptr=mmap(0, 4096, PROT_READ|PROT_WRITE,
>                 MAP_ANONYMOUS|MAP_SHARED|MAP_GROWSDOWN, 0, 0)) == -1) {
>                 printf("failed to mmap\n");
>                 return;
>         }
> 
>         if ((ptr=mremap(ptr, 4096, 8192, MREMAP_MAYMOVE)) == -1) {
>                 printf("failed to mremap\n");
>                 return;
>         }
>         
>         //why does this failed. I am well in the interval [4096, 8192]
>         *(unsigned int *)(ptr + 4096 + 8)= 10;
> }
> 


-- 


http://sourceware.org/bugzilla/show_bug.cgi?id=4714

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


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