This is the mail archive of the
glibc-bugs@sourceware.org
mailing list for the glibc project.
[Bug linuxthreads/1337] New: reports "malloc: top chunk is corrupt" when allocates second 2GB of memory buffer after pthread_create()
- From: "igorodet at cray dot com" <sourceware-bugzilla at sourceware dot org>
- To: glibc-bugs at sources dot redhat dot com
- Date: 13 Sep 2005 16:47:34 -0000
- Subject: [Bug linuxthreads/1337] New: reports "malloc: top chunk is corrupt" when allocates second 2GB of memory buffer after pthread_create()
- Reply-to: sourceware-bugzilla at sourceware dot org
OS: SuSe 2.6.5
CPU: AMD Opteron (2 way SMP)
Memory: 8 GB
Steps to reproduce:
1. Compile the following program WITHOUT '-static' option set
2. set env. variable MALLOC_CHECK_ to 1
3. execute program
Output I see:
******************
malloc: using debugging hooks
malloc: top chunk is corrupt
free(): invalid pointer 0x2a959a4010!
free(): invalid pointer 0x2b159c5010!
s_buf=0x2a959a4010 r_buf=0x2b159c5010 size=0x80000000
******************
4. Compile with '-static' - problem disappears
5. Run dynamically compiled version, but with env. variable
'export LD_ASSUME_KERNEL=2.4.1' - problem does not exist
Program:
*****************************************************
#include <stdio.h>
#include <stdlib.h>
#include <malloc.h>
char *s_buf;
char *r_buf;
static void *
ErrorHandler(void *arg)
{
}
int main(int argc,char *argv[])
{
int i;
size_t size = 2*1024*1024*1024L;;
int loop;
pthread_t pthr_hndl;
int res;
res = mallopt(M_MMAP_MAX, 0);
pthread_create(&pthr_hndl, NULL, ErrorHandler, NULL);
pthread_join(pthr_hndl, NULL);
s_buf = malloc(size);
r_buf = malloc(size);
printf("s_buf=%p r_buf=%p size=0x%lx \n", s_buf, r_buf, size);
free(s_buf);
free(r_buf);
return 0;
}
************************************************************************
Comments:
Problem exists only when M_MMAP_MAX is set to 1 (or 2) and program creates thread.
Looks like in this case malloc tries to use mmap and then gets confused when
performs heap integrity checks.
--
Summary: reports "malloc: top chunk is corrupt" when allocates
second 2GB of memory buffer after pthread_create()
Product: glibc
Version: 2.3.3
Status: NEW
Severity: normal
Priority: P2
Component: linuxthreads
AssignedTo: gotom at debian dot or dot jp
ReportedBy: igorodet at cray dot com
CC: glibc-bugs at sources dot redhat dot com
http://sourceware.org/bugzilla/show_bug.cgi?id=1337
------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.