This is the mail archive of the
libc-alpha@sourceware.cygnus.com
mailing list for the glibc project.
Re: Problem with __malloc_hooks :-(
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.
You mean __malloc_initialize_hook? I think this is exactly the right
way. Initialization must happen as soon as maloc gets used. Just
assume you are doing some fancy stuff in the interceptors and return a
pointer which is not directly the beginning of the block (see mcheck
etc). Now, some global constructor or _init() function used malloc
already and the allocated object somehow appears in the later program
run and should be freed. Result: a pointer free() cannot handle.
By using __malloc_initialize_hook this canot happen since the hooks can
be installed before the first malloc() call in any case.
--
---------------. drepper at gnu.org ,-. 1325 Chesapeake Terrace
Ulrich Drepper \ ,-------------------' \ Sunnyvale, CA 94089 USA
Cygnus Solutions `--' drepper at cygnus.com `------------------------