<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<blockquote type="cite"
cite="mid:DM4PR18MB54519DED3C6D5EACA9CB3AABB891A@DM4PR18MB5451.namprd18.prod.outlook.com">
<div id="mail-editor-reference-message-container">
<div class="ms-outlook-mobile-reference-message skipProofing">
<meta name="Generator" content="Microsoft Exchange Server">
</div>
<div class="ms-outlook-mobile-reference-message skipProofing"
style="text-align: left; padding: 3pt 0in 0in; border-width: 1pt medium medium; border-style: solid none none; border-color: rgb(181, 196, 223) currentcolor currentcolor; font-family: Aptos; font-size: 12pt; color: black;">
<b>From: </b>Simon Kelley <a class="moz-txt-link-rfc2396E" href="mailto:simon@thekelleys.org.uk"><simon@thekelleys.org.uk></a><br>
<b>Date: </b>Wednesday, January 28, 2026 at 11:17 AM<br>
<b>To: </b>Niten Jaiswal <a class="moz-txt-link-rfc2396E" href="mailto:niten@jaiswal.net"><niten@jaiswal.net></a>,
<a class="moz-txt-link-abbreviated" href="mailto:dnsmasq-discuss@lists.thekelleys.org.uk">dnsmasq-discuss@lists.thekelleys.org.uk</a>
<a class="moz-txt-link-rfc2396E" href="mailto:dnsmasq-discuss@lists.thekelleys.org.uk"><dnsmasq-discuss@lists.thekelleys.org.uk></a><br>
<b>Subject: </b>Re: [Dnsmasq-discuss] Potential memory leak<br>
<br>
</div>
<div class="PlainText" style="font-size: 11pt;">I've just pushed
some changes to the git repo, whichinclude a new option<br>
called --log-malloc. If you can run that code, and enable
log-malloc and<br>
save the log file, that might be interesting. There will be a
reasonable<br>
amount of activity after startup, but once the various tables
reach<br>
equilibrium size, it should be pretty quiet. If it's not, or
there are<br>
some very large allocations, that could give us a clue.<br>
<br>
This has been quite useful: I found a few non-optimal
behaviours, which<br>
I've fixed, but nothing that actually leaks memory.<br>
<br>
</div>
</div>
</blockquote>
<br>
<div class="moz-cite-prefix">Am 28.01.26 um 20:10 schrieb Niten
Jaiswal via Dnsmasq-discuss:<br>
</div>
<blockquote type="cite"
cite="mid:DM4PR18MB54519DED3C6D5EACA9CB3AABB891A@DM4PR18MB5451.namprd18.prod.outlook.com">
<div
style="direction: ltr; font-family: Aptos, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
HI Simon,</div>
<div
style="direction: ltr; font-family: Aptos, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
I’m not sure if I can run your version on opnsense. The
opnsense team gave me a patch to install that will remove the
quiet options and have shown me how to enable the logging you
requested. I will turn everything on later today.</div>
<div
style="direction: ltr; font-family: Aptos, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div
style="direction: ltr; font-family: Aptos, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
</div>
</blockquote>
<p><br>
</p>
<p>Niten, </p>
<p>that's not useful. Please compile a debug version of dnsmasq from
ports; I have just updated the FreeBSD port dns/dnsmasq-devel to
v2.93test2, and then either add the log-malloc option, or
alternatively, install valgrind (pkg install valgrind) and run
dnsmasq under valgrind (slower) instead. Check how you normally
call it, shut it down, then add the valgrind + options before
dnsmasq, and a -d at the end, and watch.</p>
<p>In order to debug properly, please build dnsmasq from ports,
update your ports checkout, or download and unpack the port: <br>
<a class="moz-txt-link-freetext" href="https://gitlab.com/FreeBSD/freebsd-ports/-/archive/main/freebsd-ports-main.tar.bz2?ref_type=heads&path=dns/dnsmasq-devel">https://gitlab.com/FreeBSD/freebsd-ports/-/archive/main/freebsd-ports-main.tar.bz2?ref_type=heads&path=dns/dnsmasq-devel</a></p>
<p>then cd to the directory where you unpacked it and "make
WITH_DEBUG=yes", if that succeeds, "make WITH_DEBUG=yes
reinstall".</p>
<p>Then, restart dnsmasq in with valgrind:</p>
<p>valgrind --trace-children=yes --leak-check=full
/usr/local/sbin/dnsmasq -x /var/run/dnsmasq.pid -C
/usr/local/etc/dnsmasq.conf -d<br>
<br>
</p>
<p>A leak report of a synthetic leak program that deliberately leaks
memory with valgrind looks like this:</p>
<p>
<blockquote type="cite"><span style="font-family:monospace"><span
style="color:#000000;background-color:#ffffff;">$ valgrind
--trace-children=yes --leak-check=full ~/leak</span><span
style="color:#000000;background-color:#ffffff;">
</span><br>
<span style="color:#000000;background-color:#ffffff;">==20388==
Memcheck, a memory error detector</span><span
style="color:#000000;background-color:#ffffff;">
</span><br>
<span style="color:#000000;background-color:#ffffff;">==20388==
Copyright (C) 2002-2024, and GNU GPL'd, by Julian Seward et
al.</span><span
style="color:#000000;background-color:#ffffff;">
</span><br>
<span style="color:#000000;background-color:#ffffff;">==20388==
Using Valgrind-3.26.0 and LibVEX; rerun with -h for
copyright info</span><span
style="color:#000000;background-color:#ffffff;">
</span><br>
<span style="color:#000000;background-color:#ffffff;">==20388==
Command: /home/mandree/leak</span><span
style="color:#000000;background-color:#ffffff;">
</span><br>
<span style="color:#000000;background-color:#ffffff;">==20388==
</span><span style="color:#000000;background-color:#ffffff;"> </span><br>
<span style="color:#000000;background-color:#ffffff;">line 5:
x = 0x5600040</span><span
style="color:#000000;background-color:#ffffff;">
</span><br>
<span style="color:#000000;background-color:#ffffff;">line 7:
x = 0x56010e0</span><span
style="color:#000000;background-color:#ffffff;">
</span><br>
<span style="color:#000000;background-color:#ffffff;">==20388==
</span><span style="color:#000000;background-color:#ffffff;"> </span><br>
<span style="color:#000000;background-color:#ffffff;">==20388==
HEAP SUMMARY:</span><span
style="color:#000000;background-color:#ffffff;">
</span><br>
<span style="color:#000000;background-color:#ffffff;">==20388==
in use at exit: 4,113 bytes in 2 blocks</span><span
style="color:#000000;background-color:#ffffff;">
</span><br>
<span style="color:#000000;background-color:#ffffff;">==20388==
total heap usage: 3 allocs, 1 frees, 4,136 bytes allocated</span><span
style="color:#000000;background-color:#ffffff;">
</span><br>
<span style="color:#000000;background-color:#ffffff;">==20388==
</span><span style="color:#000000;background-color:#ffffff;"> </span><br>
<span style="color:#000000;background-color:#ffffff;">==20388==
17 bytes in 1 blocks are definitely lost in loss record 1 of
2</span><span
style="color:#000000;background-color:#ffffff;">
</span><br>
<span style="color:#000000;background-color:#ffffff;">==20388==
at 0x484D224: malloc (vg_replace_malloc.c:451)</span><span
style="color:#000000;background-color:#ffffff;">
</span><br>
<span style="color:#000000;background-color:#ffffff;">==20388==
by 0x20168F: main (leak.c:4)</span><span
style="color:#000000;background-color:#ffffff;">
</span><br>
<span style="color:#000000;background-color:#ffffff;">==20388==
</span><span style="color:#000000;background-color:#ffffff;"> </span><br>
<span style="color:#000000;background-color:#ffffff;">==20388==
LEAK SUMMARY:</span><span
style="color:#000000;background-color:#ffffff;">
</span><br>
<span style="color:#000000;background-color:#ffffff;">==20388==
definitely lost: 17 bytes in 1 blocks</span><span
style="color:#000000;background-color:#ffffff;">
</span><br>
<span style="color:#000000;background-color:#ffffff;">==20388==
indirectly lost: 0 bytes in 0 blocks</span><span
style="color:#000000;background-color:#ffffff;">
</span><br>
<span style="color:#000000;background-color:#ffffff;">==20388==
possibly lost: 0 bytes in 0 blocks</span><span
style="color:#000000;background-color:#ffffff;">
</span><br>
<span style="color:#000000;background-color:#ffffff;">==20388==
still reachable: 0 bytes in 0 blocks</span><span
style="color:#000000;background-color:#ffffff;">
</span><br>
<span style="color:#000000;background-color:#ffffff;">==20388==
suppressed: 4,096 bytes in 1 blocks</span><span
style="color:#000000;background-color:#ffffff;">
</span><br>
<span style="color:#000000;background-color:#ffffff;">==20388==
</span><span style="color:#000000;background-color:#ffffff;"> </span><br>
<span style="color:#000000;background-color:#ffffff;">==20388==
For lists of detected and suppressed errors, rerun with: -s</span><span
style="color:#000000;background-color:#ffffff;">
</span><br>
<span style="color:#000000;background-color:#ffffff;">==20388==
ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 0 from
0)</span><br>
<span style="color:#000000;background-color:#ffffff;">
</span><br>
</span>
</blockquote>
<br>
<br>
<br>
</p>
</body>
</html>