<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<div style="direction: ltr; font-family: Aptos, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Hi Matthias,</div>
<div style="direction: ltr; font-family: Aptos, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
I’m working with the Opnsense team to see if they can offer the development build as an option to install.  </div>
<div style="direction: ltr; font-family: Aptos, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div id="mail-editor-reference-message-container">
<div class="ms-outlook-mobile-reference-message skipProofing" style="direction: ltr;">
</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>Dnsmasq-discuss <dnsmasq-discuss-bounces@lists.thekelleys.org.uk> on behalf of Matthias Andree via Dnsmasq-discuss <dnsmasq-discuss@lists.thekelleys.org.uk><br>
<b>Date: </b>Thursday, January 29, 2026 at 7:52 PM<br>
<b>To: </b>dnsmasq-discuss@lists.thekelleys.org.uk <dnsmasq-discuss@lists.thekelleys.org.uk><br>
<b>Subject: </b>Re: [Dnsmasq-discuss] Potential memory leak<br>
<br>
</div>
<blockquote>
<div id="mail-editor-reference-message-container">
<div class="ms-outlook-mobile-reference-message skipProofing" style="direction: ltr;">
<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 href="mailto:simon@thekelleys.org.uk" class="moz-txt-link-rfc2396E" data-outlook-id="89239e73-8793-479a-a2a9-873ef77db403">
<simon@thekelleys.org.uk></a><br>
<b>Date: </b>Wednesday, January 28, 2026 at 11:17 AM<br>
<b>To: </b>Niten Jaiswal <a href="mailto:niten@jaiswal.net" class="moz-txt-link-rfc2396E" data-outlook-id="ec2b6254-f78f-4ec0-be33-f705822958f7">
<niten@jaiswal.net></a>, <a href="mailto:dnsmasq-discuss@lists.thekelleys.org.uk" class="moz-txt-link-abbreviated" data-outlook-id="67bb366d-d308-4c6b-a20d-441d4297a455">
dnsmasq-discuss@lists.thekelleys.org.uk</a> <a href="mailto:dnsmasq-discuss@lists.thekelleys.org.uk" class="moz-txt-link-rfc2396E" data-outlook-id="dbebe4af-7c6c-4254-9568-ff5a52eba3bd">
<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>
<div class="ms-outlook-mobile-reference-message skipProofing" style="direction: ltr;">
<br>
</div>
<div class="moz-cite-prefix">Am 28.01.26 um 20:10 schrieb Niten Jaiswal via Dnsmasq-discuss:</div>
<blockquote>
<div class="ms-outlook-mobile-reference-message skipProofing" style="direction: ltr; font-family: Aptos, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
HI Simon,</div>
<div class="ms-outlook-mobile-reference-message skipProofing" 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 class="ms-outlook-mobile-reference-message skipProofing" style="direction: ltr; font-family: Aptos, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
</blockquote>
<p class="ms-outlook-mobile-reference-message skipProofing"><br>
</p>
<p class="ms-outlook-mobile-reference-message skipProofing">Niten, </p>
<p class="ms-outlook-mobile-reference-message skipProofing">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 class="ms-outlook-mobile-reference-message skipProofing">In order to debug properly, please build dnsmasq from ports, update your ports checkout, or download and unpack the port: <br>
<a href="https://gitlab.com/FreeBSD/freebsd-ports/-/archive/main/freebsd-ports-main.tar.bz2?ref_type=heads&path=dns/dnsmasq-devel" class="moz-txt-link-freetext" data-outlook-id="6cbdafe6-6d4a-47bd-b357-4473147ef4ac" style="margin-top: 0px; margin-bottom: 0px;">https://gitlab.com/FreeBSD/freebsd-ports/-/archive/main/freebsd-ports-main.tar.bz2?ref_type=heads&path=dns/dnsmasq-devel</a></p>
<p class="ms-outlook-mobile-reference-message skipProofing">then cd to the directory where you unpacked it and "make WITH_DEBUG=yes", if that succeeds, "make WITH_DEBUG=yes reinstall".</p>
<p class="ms-outlook-mobile-reference-message skipProofing">Then, restart dnsmasq in with valgrind:</p>
<p class="ms-outlook-mobile-reference-message skipProofing">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 class="ms-outlook-mobile-reference-message skipProofing">A leak report of a synthetic leak program that deliberately leaks memory with valgrind looks like this:</p>
<blockquote>
<div class="ms-outlook-mobile-reference-message skipProofing" style="font-family: monospace;">
<span style="color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">$ valgrind --trace-children=yes --leak-check=full ~/leak</span><br>
<span style="color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">==20388== Memcheck, a memory error detector</span><br>
<span style="color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">==20388== Copyright (C) 2002-2024, and GNU GPL'd, by Julian Seward et al.</span><br>
<span style="color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">==20388== Using Valgrind-3.26.0 and LibVEX; rerun with -h for copyright info</span><br>
<span style="color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">==20388== Command: /home/mandree/leak</span><br>
<span style="color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">==20388==  </span><br>
<span style="color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">line 5: x = 0x5600040</span><br>
<span style="color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">line 7: x = 0x56010e0</span><br>
<span style="color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">==20388==  </span><br>
<span style="color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">==20388== HEAP SUMMARY:</span><br>
<span style="color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">==20388==     in use at exit: 4,113 bytes in 2 blocks</span><br>
<span style="color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">==20388==   total heap usage: 3 allocs, 1 frees, 4,136 bytes allocated</span><br>
<span style="color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">==20388==  </span><br>
<span style="color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">==20388== 17 bytes in 1 blocks are definitely lost in loss record 1 of 2</span><br>
<span style="color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">==20388==    at 0x484D224: malloc (vg_replace_malloc.c:451)</span><br>
<span style="color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">==20388==    by 0x20168F: main (leak.c:4)</span><br>
<span style="color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">==20388==  </span><br>
<span style="color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">==20388== LEAK SUMMARY:</span><br>
<span style="color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">==20388==    definitely lost: 17 bytes in 1 blocks</span><br>
<span style="color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">==20388==    indirectly lost: 0 bytes in 0 blocks</span><br>
<span style="color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">==20388==      possibly lost: 0 bytes in 0 blocks</span><br>
<span style="color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">==20388==    still reachable: 0 bytes in 0 blocks</span><br>
<span style="color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">==20388==         suppressed: 4,096 bytes in 1 blocks</span><br>
<span style="color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">==20388==  </span><br>
<span style="color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">==20388== For lists of detected and suppressed errors, rerun with: -s</span><br>
<span style="color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">==20388== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 0 from 0)</span><br>
<br>
</div>
</blockquote>
<div class="ms-outlook-mobile-reference-message skipProofing" style="direction: ltr;">
<br>
<br>
<br>
</div>
</div>
</body>
</html>