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

Re: Fix tst-obprintf - and mcheck in general


On Thu, Apr 26, 2012 at 02:53:07PM +0200, Andreas Jaeger wrote:
> Richard and myself analyzed the tst-obprintf failure with GCC 4.7.
> 
> It turned out that this is the fault of GCC optimizing away the following 
> from malloc/mcheck.c:
>       /* We call malloc() once here to ensure it is initialized.  */
>       void *p = malloc (0);
>       free (p);
> 
> gcc sees the malloc(0);free pair and removes it completely.
> 
> And now malloc is not properly initialized and we screw up if both mcheck 
> is used (via tst-obprintf) and MALLOC_CHECK_ is set (as it is in my 
> environment).
> 
> One option is to compile with -fno-builtin-malloc, the alternative would be 
> to use some otherways to initialize the malloc implementation.

Perhaps we could call e.g. malloc_get_state ();.  That shouldn't be optimized
away and calls ptmalloc_init.  Not sure what's better though.

	Marek


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