[PATCH] Allow to use different prefixes for jemalloc-specific functions and libc functions

Mike Hommey mh+jemalloc at glandium.org
Mon Mar 19 23:53:31 PDT 2012


On Tue, Mar 13, 2012 at 10:49:50AM +0100, Mike Hommey wrote:
> On Mon, Mar 12, 2012 at 03:15:54PM -0700, Jason Evans wrote:
> > 
> > On Mar 12, 2012, at 1:36 PM, Jason Evans wrote:
> > 
> > > On Mar 12, 2012, at 1:12 PM, Jason Evans wrote:
> > >> On Mar 12, 2012, at 12:28 PM, Mike Hommey wrote:
> > >>> On Mon, Mar 12, 2012 at 11:44:41AM -0700, Jason Evans wrote:
> > >>>> 
> > >>>> The name mangling that is specified via --with-mangling overrides --with-jemalloc-prefix, so I thought this would do what you want.
> > >>>> 
> > >>>> ./autogen.sh --enable-cc-silence --enable-prof --enable-debug --with-mangling=malloc:__wrap_malloc,calloc:__wrap_calloc,realloc:__wrap_realloc,free:__wrap_free --with-jemalloc-prefix=je_
> > >>> 
> > >>> After running that, this is what jemalloc_defs.h contains:
> > >>> […]
> > >>> 
> > >>> Even without --with-jemalloc-prefix=je_, I get the same output.
> > >> 
> > >> What operating system are you using?
> > > 
> > > I reproduced the problem on an Ubuntu 10.04 system, and will come up with a fix.
> > 
> > This should be fixed now:
> > 
> >   http://www.canonware.com/cgi-bin/gitweb.cgi?p=jemalloc.git;a=commitdiff;h=08fc3b2d5173512a2c1fdbe11cf00c8c70bad503
> 
> It works as expected. Thanks.

It broke commit 4bb09830, because it made the hooks only present if
there is no JEMALLOC_PREFIX, which is good, but not enough: I'm building
with JEMALLOC_PREFIX=je_ and mangling to have malloc, free, etc.
declared as malloc, free, etc., which is the typical case where the
hooks from commit 4bb09830 are necessary (without the hooks, Firefox
crashes on shutdown because libc tries to deallocate tls data with
jemalloc's free, when it allocated it internally ; arguably, there's a
bug in the libc, there).

The only way I can think of that would make it work is to use a
configure option to add the hooks (checking whether the mangling leads
to the relevant functions overriding libc's doesn't look very possible
from the preprocessor).

Mike



More information about the jemalloc-discuss mailing list