This is the mail archive of the
glibc-bugs@sourceware.org
mailing list for the glibc project.
[Bug libc/4714] New: bus error when trying to access page created by mremap()
- From: "tambewilliam at gmail dot com" <sourceware-bugzilla at sourceware dot org>
- To: glibc-bugs at sources dot redhat dot com
- Date: 29 Jun 2007 18:32:45 -0000
- Subject: [Bug libc/4714] New: bus error when trying to access page created by mremap()
- Reply-to: sourceware-bugzilla at sourceware dot org
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;
}
--
Summary: bus error when trying to access page created by mremap()
Product: glibc
Version: unspecified
Status: NEW
Severity: critical
Priority: P2
Component: libc
AssignedTo: drepper at redhat dot com
ReportedBy: tambewilliam at gmail dot com
CC: glibc-bugs at sources dot redhat dot com
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.