This is the mail archive of the libc-alpha@sourceware.cygnus.com 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]

Re: Problem with __malloc_hooks :-(


> 
> 
> The following program shows a problem I noticed with a current glibc
> 2.1.3 CVS versions and XEmacs [1]:
> 
> #define _GNU_SOURCE 
> #include <stdlib.h>
> #include <malloc.h>
> 
> int
> main (int argc, char argv[])
> {
>   char *p;
>   
>   if (argc == 1)
>     {
>       __malloc_hook = NULL;
>       __realloc_hook = NULL;
>       __free_hook = NULL;
>     }
> 
>   p = malloc (1000);
>   printf ("%p\n", p);
>   return 0;
> }
> 
> Have a look at the output:
> 
> gromit:/tmp:[0]$ ./malloc 
> (nil)
> gromit:/tmp:[0]$ ./malloc 1
> 0x8049670
> 
> If __malloc_hook is NULL, malloc returns NULL.  The problem is that
> malloc internally uses __malloc_hook and the current CVS version
> doesn't call malloc before main any more :-(.
> 
> Wolfram, can you give me some feedback, please?
> 

Have you tried my preinit patch? It is for the static libpthread bug
which Ulrich fixed with a different approach. But it seems that my
patch has other potential benefits :-).

-- 
H.J. Lu (hjl@gnu.org)

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