Fix tst-obprintf - and mcheck in general
Richard Guenther
rguenther@suse.de
Thu Apr 26 13:31:00 GMT 2012
On Thu, 26 Apr 2012, Marek Polacek wrote:
> 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.
Consider people LD_PRELOADing tcmalloc or so. Not sure if it makes sense
to use mcheck.c then, of course ..
Richard.
--
Richard Guenther <rguenther@suse.de>
SUSE / SUSE Labs
SUSE LINUX Products GmbH - Nuernberg - AG Nuernberg - HRB 16746
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer
More information about the Libc-alpha
mailing list