]> git.ipfire.org Git - thirdparty/bind9.git/commit
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)
commit0d6839d832db49dcf3258bea5645316779a2ae76
treed719301212b2707e3bfed05351e4765e3e66a465
parent234b9d4922ecf272a632d9a40a10e84b61f6cd57
parent4eb2cd364ac866c924e761c0596abae5e6428146
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.

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

See merge request isc-projects/bind9!10320