[prev in list] [next in list] [prev in thread] [next in thread]
List: glibc-alpha
Subject: Re: test showing address space leak in glibc 2.3.2 !!
From: "Bruce Korb" <bruce.korb () gmail ! com>
Date: 2008-04-10 22:06:24
Message-ID: 668c430c0804101506y281ab16dx9e25fb568032dd60 () mail ! gmail ! com
[Download RAW message or body]
On Thu, Apr 10, 2008 at 1:55 PM, Ulrich Drepper <drepper@redhat.com> wrote:
> Take this elsewhere. It has nothing to do with glibc development.
Who else is doing the malloc code in glibc?
Here is a short program that shows the problem. I'm done now.
You can either fix it or not, but it is a malloc bug. Don't reply to me.
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <pthread.h>
typedef void * (thread_base_fn_t)(void *);
pthread_mutex_t startmutex = PTHREAD_MUTEX_INITIALIZER;
int thdct = 0;
int thdno = 0;
static thread_base_fn_t get_mem, toss_mem;
int
main(int argc, char ** argv)
{
srand((int) time(NULL));
for (;;) {
pthread_t dummy;
if (pthread_create(&dummy, NULL, get_mem, NULL) != 0) {
fprintf(stderr, "pthread_create FAILED on thread #%d\n", thdno);
exit(1);
}
if (pthread_mutex_lock(&startmutex) != 0) abort();
thdct++;
pthread_mutex_unlock(&startmutex);
while (thdct >= 4)
sleep(1);
}
}
static void *
get_mem(void * arg)
{
pthread_t dummy;
unsigned int * mem = malloc(0x100);
int ct = 0x100 / sizeof(unsigned int);
unsigned int val = rand();
if (mem == NULL) {
fprintf(stderr, "MALLOC FAILED on thread #%d\n", thdno);
exit(1);
}
while (--ct >= 0)
mem[ct] = val;
if (pthread_create(&dummy, NULL, toss_mem, mem) != 0) {
fprintf(stderr, "PTHREAD_CREATE FAILED on thread #%d\n", thdno);
exit(1);
}
return NULL;
}
static void *
toss_mem(void * arg)
{
unsigned int * mem = arg;
unsigned int val = *mem;
free(arg);
if (pthread_mutex_lock(&startmutex) != 0) abort();
thdno++;
printf("th %5d %d -- 0x%08X\n", thdno, thdct, val);
thdct--;
pthread_mutex_unlock(&startmutex);
}
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic