tech stuff.

Archive for the ‘Telephony’ Category

freeswitch/sofia doesn’t parse resolv.conf properly

leave a comment »

After extensively testing freeswitch in my dev environment — and really liking what I saw — I installed freeswitch 1.0.3 to my production server… and immediately got a seg fault on my first configuration change.  This was a bit perplexing.  Throughout my entire testing period I didn’t experience a single crash, and here was one 3 minutes into my first install.

The core file illuminated the fact that the sofia library in freeswitch was attempting to dereference a null pointer (in an error handling routine of all places) caused by an empty DNS response.  A tcpdump revealed that sofia was attempting to send the DNS query to localhost (strangely) and was being refused (not strangely).  Upgrading to 1.0.4pre8 fixed the segfault, but didn’t change the DNS behavior.

It turns out that sofia implements its own resolver instead of using the system resolver.  Sofia attempts to discover its nameservers from /etc/resolv.conf, but it uses a somewhat more naive parsing than the system resolver.  My production system contained a same-line comment in the nameserver line that was not being parsed out.  As a result, sofia attempted to do an inet_pton(3) on “192.168.1.1 # comment”, which failed.  When all nameservers failed, sofia inserted 127.0.0.1 as a last-ditch effort to find a resolver.

I’ve created a patch to remedy this behavior and submitted it to the freeswitch dev team.

Update:  freeswitch has integrated the patch into their trunk, so if you’re having this problem just update your copy.

Written by Lee Verberne

2009-06-10 at 00:27

Posted in Telephony

Tagged with