tech-toolchain archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
overriding malloc vs. fork hooks
A program can provide its own allocator. However when you try to link
an alternative malloc statically, you run into conflicts b/c the libc
malloc is still pulled in via malloc fork hooks.
lib/libc/gen/pthread_atfork.c calls __malloc_prefork, and
__malloc_postfork and __malloc_postfork_child respectively and since
their implementations are in the same file as malloc, you get a name
clash.
With dynamic linking you end up calling libc malloc hooks, which is
probably mostly harmless.
As far as I can tell, mimalloc doesn't seem to provide these. dmalloc
doesn't either, but mentions them in contrib/aix_5l_notes.
I'm not sure if we can arrange for program to fail to link dynamically
if they provide malloc, but don't provide the hooks. "Everyone" knows
the set of malloc functions that need to be overriden all at once to
use your own malloc, but the hooks is not in that well known list.
We should at least document this.
Thoughts?
-uwe
Home |
Main Index |
Thread Index |
Old Index