This is the mail archive of the
glibc-bugs@sourceware.org
mailing list for the glibc project.
[Bug libc/10776] New: With M_MMAP_MAX=0 free() causes undefined behaviour.
- From: "Christian dot Meier at informatik dot stud dot uni-erlangen dot de" <sourceware-bugzilla at sourceware dot org>
- To: glibc-bugs at sources dot redhat dot com
- Date: 14 Oct 2009 13:03:02 -0000
- Subject: [Bug libc/10776] New: With M_MMAP_MAX=0 free() causes undefined behaviour.
- Reply-to: sourceware-bugzilla at sourceware dot org
Calling the following at the beginning of main causes an application (with many
allocations) to behave undefined.
if (mlockall(MCL_CRRENT|MCL_FUTURE))
return 1;
mallopt(M_TRIM_THRESHOLD, -1);
mallopt(M_MMAP_MAX, 0);
int * buffer = (int*) malloc(10*1024*1024);
if (!buffer)
return 1;
for (int i = 0; i < 10*1024*1024/sizeof(int); ++i) {
buffer[i] = 42;
}
free(buffer);
However, commenting out either free(buffer); or mallopt(M_MAP_MAX, 0); causes
the application to behave as expected.
--
Summary: With M_MMAP_MAX=0 free() causes undefined behaviour.
Product: glibc
Version: 2.10
Status: NEW
Severity: normal
Priority: P2
Component: libc
AssignedTo: drepper at redhat dot com
ReportedBy: Christian dot Meier at informatik dot stud dot uni-
erlangen dot de
CC: glibc-bugs at sources dot redhat dot com
http://sourceware.org/bugzilla/show_bug.cgi?id=10776
------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.