]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
fix: dev: copy __FILE__ when allocating memory
authorColin Vidal <colin@isc.org>
Thu, 27 Mar 2025 12:15:24 +0000 (12:15 +0000)
committerColin Vidal <colin@isc.org>
Thu, 27 Mar 2025 12:15:24 +0000 (12:15 +0000)
When allocating memory under -m trace|record, the __FILE__ pointer is
stored, so it can be printed out later in order to figure out in which
file an allocation leaked. (among others, like the line number).

However named crashes when called with -m record and using a plugin
leaking memory. The reason is that plugins are unloaded earlier than
when the leaked allocations are dumped (obviously, as it's done as late
as possible). In such circumstances, `__FILE__` is dangling because the
dynamically loaded library (the plugin) is not in memory anymore.

Fix the crash by systematically copying the `__FILE__` string
instead of copying the pointer. Of course, this make each allocation to
consume a bit more memory (and longer, as it needs to calculate the
length of `__FILE__`) but this occurs only under -m trace|record debugging
flags.

Merge branch 'colin-memdump-plugins' into 'main'

See merge request isc-projects/bind9!10320


Trivial merge