Fix tst-obprintf - and mcheck in general
Marek Polacek
polacek@redhat.com
Thu Apr 26 13:15:00 GMT 2012
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
More information about the Libc-alpha
mailing list