[Dnsmasq-discuss] Segfault in dnsmasq 2.72 compiled from source on CentOS6

Matt Coddington coddington at gmail.com
Mon Apr 6 19:39:20 BST 2015


Just a quick followup here - I worked with Simon providing some core files
and debugging info and he tracked down and fixed the issue.  I've had the
fix running on my systems and have seen no segfaults in over two hours when
attempting the things that were previously making it happen within a minute
or so.  The root cause of the segfault was my querying of the .bind TLD
stats combined with having a config with multiple upstream dns servers i'm
forwarding to based on domain.  Thank you Simon for the quick fix!

Sounds like the fix will be included in 2.73, but in case anyone else wants
the patch to 2.72 prior to that i'm including it here:

diff --git a/src/cache.c b/src/cache.c
index d7bea57..178d654 100644
--- a/src/cache.c
+++ b/src/cache.c
@@ -1367,7 +1367,7 @@ int cache_make_stat(struct txt_record *t)
  }
     port = prettyprint_addr(&serv->addr, daemon->addrbuff);
     lenp = p++; /* length */
-    bytes_avail = (p - buff) + bufflen;
+    bytes_avail = bufflen - (p - buff );
     bytes_needed = snprintf(p, bytes_avail, "%s#%d %u %u",
daemon->addrbuff, port, queries, failed_queries);
     if (bytes_needed >= bytes_avail)
       {
@@ -1381,7 +1381,7 @@ int cache_make_stat(struct txt_record *t)
  lenp = p - 1;
  buff = new;
  bufflen = newlen;
- bytes_avail = (p - buff) + bufflen;
+ bytes_avail =  bufflen - (p - buff );
  bytes_needed = snprintf(p, bytes_avail, "%s#%d %u %u", daemon->addrbuff,
port, queries, failed_queries);
       }
     *lenp = bytes_needed;


matt


On Sat, Apr 4, 2015 at 1:54 PM, Simon Kelley <simon at thekelleys.org.uk>
wrote:

> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Matt,
>
> Please could you try building dnsmasq with
>
> make CFLAGS=-g
>
> and when/if that crashes, send me the binary and the corefile?
>
> It will be much easier to debug if compiled with debug symbols, which
> is what CFLAGS=-g does.
>
>
> Cheers,
>
> Simon.
>
>
>
> On 04/04/15 15:30, Matt Coddington wrote:
> > Hi, I am wanting to use the "statistics available as DNS queries in
> > the .bind TLD" feature of dnsmasq. The currently available RPM in
> > the CentOS repo's is 2.48, and that .bind TLD feature isn't
> > available until 2.69.
> >
> > I downloaded the source for 2.72 and am using the binary generated
> > with a straight up "make".
> >
> > On a system with a reasonable amount of DNS traffic (it's an MTA
> > sending a couple thousand emails per day), the 2.72 binary
> > segfaults usually in about 1-5 minutes (though once I had it run
> > for a few hours before segfaulting). When I run the stock CentOS
> > 2.48 RPM version it does not segfault. I also compiled my own 2.48
> > to see if maybe there was some sort of issue with my compilation
> > environment and that also has not segfaulted in over a day, so this
> > does seem to be an issue that is related to some difference
> > between 2.48 and 2.72.
> >
> > I captured a core file from one of the segfaults. I don't have a
> > lot of experience with that sort of debugging, but the stack trace
> > seems pretty huge to me - it is almost 35000 deep. Here is the last
> > bit of it where it finally gets into the dnsmasq code as opposed to
> > system libraries:
> >
> > #34784 0x000000000040b4d6 in whine_malloc (size=144) at util.c:258
> > #34785 0x0000000000413a68 in allocate_frec (now=1427863329,
> > wait=0x7fff78f2d3ac, force=0) at forward.c:1946 #34786 get_new_frec
> > (now=1427863329, wait=0x7fff78f2d3ac, force=0) at forward.c:2107
> > #34787 0x0000000000418e86 in set_dns_listeners (now=1427863329,
> > set=0x7fff78f2d5e0, maxfdp=0x7fff78f2d6ac) at dnsmasq.c:1403 #34788
> > 0x000000000041a909 in main (argc=<value optimized out>, argv=<value
> > optimized out>) at dnsmasq.c:809
> >
> > I'm happy to share the abrtd dump directory w/the core file and
> > other info if that would be helpful - just let me know how you'd
> > like to receive it.
> >
> > thanks! matt
> >
> >
> >
> > _______________________________________________ Dnsmasq-discuss
> > mailing list Dnsmasq-discuss at lists.thekelleys.org.uk
> > http://lists.thekelleys.org.uk/mailman/listinfo/dnsmasq-discuss
> >
>
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v2.0.22 (GNU/Linux)
>
> iEYEARECAAYFAlUgJWoACgkQKPyGmiibgrdlvgCeOnQdTJgWelZcxwMYqeUW7y5t
> qd8AniH0/mXda4Ar5Bykcw07rkYGCTK5
> =RFDC
> -----END PGP SIGNATURE-----
>
> _______________________________________________
> Dnsmasq-discuss mailing list
> Dnsmasq-discuss at lists.thekelleys.org.uk
> http://lists.thekelleys.org.uk/mailman/listinfo/dnsmasq-discuss
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.thekelleys.org.uk/pipermail/dnsmasq-discuss/attachments/20150406/dcb49168/attachment.html>


More information about the Dnsmasq-discuss mailing list