]> git.ipfire.org Git - thirdparty/bind9.git/commit
Improve stability of the jemalloc workaround
authorMichał Kępień <michal@isc.org>
Wed, 1 Nov 2023 17:04:07 +0000 (18:04 +0100)
committerMichał Kępień <michal@isc.org>
Wed, 1 Nov 2023 17:04:07 +0000 (18:04 +0100)
commite974f98eb4171b50a005084deb15dd519c8fbb85
treef95b3f13a5a597d361d638bbf4bd40d89018f7cf
parent3488ada94b2465ba6bce4ac59617da50c2fd9d98
Improve stability of the jemalloc workaround

When jemalloc is linked into BIND 9 binaries (rather than preloaded or
used as the system allocator), depending on the decisions made by the
linker, the malloc() symbol may be resolved to a non-jemalloc
implementation at runtime.  Such a scenario foils the workaround added
in commit 2da371d005c472dea349110e3ef9a6ed7b18b824 as it relies on the
jemalloc implementation of malloc() to be executed.

Handle the above scenario properly by calling mallocx() explicitly
instead of relying on the runtime resolution of the malloc() symbol.
Use trivial wrapper functions to avoid the need to copy multiple #ifdef
lines from lib/isc/mem.c to lib/isc/trampoline.c.  Using a simpler
alternative, e.g. calling isc_mem_create() & isc_mem_destroy(), was
already considered before and rejected, as described in the log message
for commit 2da371d005c472dea349110e3ef9a6ed7b18b824.

ADJUST_ZERO_ALLOCATION_SIZE() is only used in isc__mem_free_noctx() to
concisely avoid compilation warnings about its 'size' parameter not
being used when building against jemalloc < 4.0.0 (as sdallocx() is then
redefined to dallocx(), which has a different signature).
lib/isc/mem.c
lib/isc/mem_p.h
lib/isc/trampoline.c