]> git.ipfire.org Git - thirdparty/bind9.git/commit
[9.20] fix: dev: copy __FILE__ when allocating memory
authorColin Vidal <colin@isc.org>
Thu, 27 Mar 2025 15:49:17 +0000 (15:49 +0000)
committerColin Vidal <colin@isc.org>
Thu, 27 Mar 2025 15:49:17 +0000 (15:49 +0000)
commit59635e33d0ab2415a7e265f15ec91d2e4fb5b7d5
tree736c3754db9b249a1ace642fa25d8d07ae826b11
parent7c4603fc4a1c94d0f6f2a3392df658cb1f4075d6
parentc1352b79ca910d551d38062882f05adad763ba39
[9.20] fix: dev: copy __FILE__ when allocating memory

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.

Backport of MR !10320

Merge branch 'backport-colin-memdump-plugins-9.20' into 'bind-9.20'

See merge request isc-projects/bind9!10336