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 :-(


>>>>> Ulrich Drepper writes:

Uli> Andreas Jaeger <aj@suse.de> writes:
>> We really need a way to initialize malloc at the beginning but using
>> __malloc_hook is IMHO the wrong approach.

What I meant was: Using __malloc_hook internally in malloc.c to
initialize malloc and at the same time allowing the use to set
__malloc_hook is broken.

Uli> You mean __malloc_initialize_hook?  I think this is exactly the right
Uli> way.  Initialization must happen as soon as maloc gets used.  Just
Uli> assume you are doing some fancy stuff in the interceptors and return a
Uli> pointer which is not directly the beginning of the block (see mcheck
Uli> etc).  Now, some global constructor or _init() function used malloc
Uli> already and the allocated object somehow appears in the later program
Uli> run and should be freed.  Result: a pointer free() cannot handle.

Uli> By using __malloc_initialize_hook this canot happen since the hooks can
Uli> be installed before the first malloc() call in any case.

The same would happen if __malloc_hook wouldn't be used internally by
glibc.

Could somebody document this properly, please?  <malloc.h> has only a
declaration of__malloc_initialize_hook - but no documentation at all.
The manual only mentions __malloc_hook.  If we're going to declare
that __malloc_hook is only allowed to be set after malloc is
initialized and can be set from __malloc_initialize_hook, we should
document this.

Andreas
-- 
 Andreas Jaeger   
  SuSE Labs aj@suse.de	
   private aj@arthur.rhein-neckar.de

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