This is the mail archive of the glibc-bugs@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

-lmcheck is not thread safe, or it is not safe at all.


 
this is the test code. It will crash when I compiled it with -lmcheck,
but ok when I use MALLOC_CHECK_ .
 
I'm so frustrated. I trust the -lmcheck so much, but it waste me so many
time before I get aware the fault is coming from -lmcheck.
 
damn it.
 
========================================================================
=============
 
#include <stdio.h>
#include <unistd.h>
#include <pthread.h>
#include <stdlib.h>
#include <string.h>
 
void* thread_func(void* arg)
{
     while(1)
     {
          char* tmp = strdup("1234567890abcdefghijklmnopqrstuvwxyz");
          //char* tmp = (char*)malloc(100);
          if(tmp)
                free(tmp);
          usleep(1);
     }
 
     return NULL;
}
 
main()
{
     pthread_t pid;
     int i = 0;
 
     for(i = 0;i < 200; i++){
          pthread_create(&pid,0,thread_func,0);
     }
 
     printf("\nwaiting.\n");
     while(1){
          sleep(1000);
     }
}


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]