public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libc/15560] New: munmap subregion of memory maped by mmap
@ 2013-06-02 6:40 zylcf818 at 163 dot com
2013-06-02 6:42 ` [Bug libc/15560] " zylcf818 at 163 dot com
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: zylcf818 at 163 dot com @ 2013-06-02 6:40 UTC (permalink / raw)
To: glibc-bugs
http://sourceware.org/bugzilla/show_bug.cgi?id=15560
Bug ID: 15560
Summary: munmap subregion of memory maped by mmap
Product: glibc
Version: unspecified
Status: NEW
Severity: minor
Priority: P2
Component: libc
Assignee: unassigned at sourceware dot org
Reporter: zylcf818 at 163 dot com
CC: drepper.fsp at gmail dot com
in rhel6.2, I mmap 3 pages, and munmap the middle page, but the behavior of
munmap() seems to be strange, below is code:
#include <sys/mman.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <cstring>
int main(int argc, char *argv[])
{
char* addr = (char*)mmap(NULL, 4096*3, PROT_READ|PROT_WRITE,
MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
if (addr == MAP_FAILED)
printf("Failed to mmap\n");
memcpy(addr, "abc", 3);
memcpy(addr+4096, "def", 3);
memcpy(addr+8192, "ghi", 3);
// printf("%10p\n", addr);
// printf("%10p\n", addr+4096);
// printf("%10p\n", addr+8192);
// printf("%s\n", addr);
// printf("%s\n", addr+4096);
// printf("%s\n", addr+8192);
int rs = munmap(addr+4096, 4096);
if ( rs != 0 )
printf("failed to munmap\n");
printf("%s\n", addr);
printf("%s\n", addr+4096);
printf("%s\n", addr+8192);
memcpy(addr, "123", 3);
memcpy(addr+4096, "456", 3);
memcpy(addr+8192, "789", 3);
printf("%s\n", addr);
printf("%s\n", addr+4096);
printf("%s\n", addr+8192);
exit(EXIT_SUCCESS);
} /* main */
>g++ -g -o mmap mmap.cpp
>./mmap
abc
abc
ghi
123
123
789
if I comment off printf... in code, the result is what I expect:
0x7f3c4a274000
0x7f3c4a275000
0x7f3c4a276000
abc
def
ghi
abc
Segmentation fault (core dumped) <--- what I expect
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug libc/15560] munmap subregion of memory maped by mmap
2013-06-02 6:40 [Bug libc/15560] New: munmap subregion of memory maped by mmap zylcf818 at 163 dot com
@ 2013-06-02 6:42 ` zylcf818 at 163 dot com
2013-06-02 8:10 ` schwab@linux-m68k.org
2014-06-13 17:33 ` fweimer at redhat dot com
2 siblings, 0 replies; 4+ messages in thread
From: zylcf818 at 163 dot com @ 2013-06-02 6:42 UTC (permalink / raw)
To: glibc-bugs
http://sourceware.org/bugzilla/show_bug.cgi?id=15560
--- Comment #1 from zhangyue <zylcf818 at 163 dot com> ---
Maybe I report this problem to kernel guys?
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug libc/15560] munmap subregion of memory maped by mmap
2013-06-02 6:40 [Bug libc/15560] New: munmap subregion of memory maped by mmap zylcf818 at 163 dot com
2013-06-02 6:42 ` [Bug libc/15560] " zylcf818 at 163 dot com
@ 2013-06-02 8:10 ` schwab@linux-m68k.org
2014-06-13 17:33 ` fweimer at redhat dot com
2 siblings, 0 replies; 4+ messages in thread
From: schwab@linux-m68k.org @ 2013-06-02 8:10 UTC (permalink / raw)
To: glibc-bugs
http://sourceware.org/bugzilla/show_bug.cgi?id=15560
Andreas Schwab <schwab@linux-m68k.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution|--- |INVALID
--- Comment #2 from Andreas Schwab <schwab@linux-m68k.org> ---
The compiler is optimizing out the memory loads, which is a perfectly valid
transformation in the presense of undefined behaviour.
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug libc/15560] munmap subregion of memory maped by mmap
2013-06-02 6:40 [Bug libc/15560] New: munmap subregion of memory maped by mmap zylcf818 at 163 dot com
2013-06-02 6:42 ` [Bug libc/15560] " zylcf818 at 163 dot com
2013-06-02 8:10 ` schwab@linux-m68k.org
@ 2014-06-13 17:33 ` fweimer at redhat dot com
2 siblings, 0 replies; 4+ messages in thread
From: fweimer at redhat dot com @ 2014-06-13 17:33 UTC (permalink / raw)
To: glibc-bugs
https://sourceware.org/bugzilla/show_bug.cgi?id=15560
Florian Weimer <fweimer at redhat dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Flags| |security-
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2014-06-13 17:33 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-06-02 6:40 [Bug libc/15560] New: munmap subregion of memory maped by mmap zylcf818 at 163 dot com
2013-06-02 6:42 ` [Bug libc/15560] " zylcf818 at 163 dot com
2013-06-02 8:10 ` schwab@linux-m68k.org
2014-06-13 17:33 ` fweimer at redhat dot com
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).