just making some experiments and traces. first of all: I'm not a bind9 expert so I have not found the place where bind dload's the dlz module, but the issue seems to be the following:
the dlz module gets loaded, the default tdb implementation is in a .so file loaded by this. then the ldb modules are loaded with RTLD_DEEPBIND (spoiler: there is a env variable LDB_MODULES_DISABLE_DEEPBIND that if set fixes the issue, but why this works will be apparent in a second) now we have tdb using jemalloc (since bind9 does not RTLD_DEEPBIND load dlz modules, maybe that would be the most straight forward fix, but again I'm not a bind9 expert) and because of RTLD_DEEPBIND the ldb modules prefer glibc. And here is the issue: a call to tdb_fetch uses jemalloc whereas the ldb module will call glibc's free, as we saw The good thing is that we have a workaround that works without any recompilation (echo 'LDB_MODULES_DISABLE_DEEPBIND=1' >> /etc/default/named) It is very unlikly that we have a symbol conflict elsewhere so I think in the meantime this is the fix for now 👍