[PATCH v2] malloc: Remove malloc hooks (Bug 23328)
DJ Delorie
dj@redhat.com
Mon Jul 2 15:49:00 GMT 2018
Florian Weimer <fw@deneb.enyo.de> writes:
>> + void *(*hook) (size_t, const void *)
>> + = atomic_forced_read (__glibc_malloc_hook);
>> + if (__builtin_expect (hook != NULL, 0))
>> + return (*hook) (sz, RETURN_ADDRESS (0));
>
> Should this use atomic_load_relaxed instead?
It's a copy of what's in malloc/malloc.c
>> + HOOK (malloc, NULL);
>
> I think you can simplify HOOK considerably if you always initialize
> all function pointers. Then you don't need to use atomics there
> because pthread_create always initializes malloc before creating new
> threads.
I tried that, but you end up being just as complicated due to having to
check for "set to dummy hooks", plus implementing the dummy hooks,
plus... etc. It turned out to not be worth the effort, even once I got
it working properly (bootstrapping an interposed malloc is not trivial).
More information about the Libc-alpha
mailing list