<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 12pt;
font-family:Calibri
}
--></style></head>
<body class='hmmessage'><div dir='ltr'><br>&nbsp;<BR><div>&gt; Date: Sat, 22 Jun 2013 11:32:04 -0500<br>&gt; From: krice@freeswitch.org<br>&gt; To: freeswitch-users@lists.freeswitch.org; freeswitch-dev@lists.freeswitch.org<br>&gt; Subject: Re: [Freeswitch-dev] [Freeswitch-users] origin/master's HEAD is        segfaulting<br>&gt; <br>&gt; Oh come on people... Jira... That's where you report bugs... And yes a<br>&gt; segfault is a bug<br>&gt; </div><div>&nbsp;</div><div>I guess I should not my rant against "jira" :).</div><div>&nbsp;</div><div>I will post it there with further info. In between, same thing happens for 1.5.whateverlatest</div><div>tag. Which left me a little surprised.</div><div><br>&gt; <br>&gt; On 6/22/13 9:03 AM, "arif hossain" &lt;aftnix@live.com&gt; wrote:<br>&gt; <br>&gt; &gt; Hi,<br>&gt; &gt; <br>&gt; &gt; I'm on this commit :<br>&gt; &gt; arif@khost:~/src/freeswitch$ git show HEAD<br>&gt; &gt; commit f8122e39c51240b99bf07a767afe2f8a698f1486<br>&gt; &gt; <br>&gt; &gt; Now its segfaulting on startup.<br>&gt; &gt; <br>&gt; &gt;&gt; From generated core :<br>&gt; &gt; <br>&gt; &gt; Program terminated with signal 11, Segmentation fault.<br>&gt; &gt; #0 &nbsp;0x00007f245cc28df1 in su_casematch (s1=0x7f245cc7fc57 "",<br>&gt; &gt; &nbsp; &nbsp; s2=0x3000000030 &lt;Address 0x3000000030 out of bounds&gt;) at su_string.c:224<br>&gt; &gt; 224 &nbsp; &nbsp; &nbsp; &nbsp;unsigned char a = *s1++, b = *s2++;<br>&gt; &gt; <br>&gt; &gt; Clearly s2 is wrongly initialized.<br>&gt; &gt; <br>&gt; &gt; The backtrace :<br>&gt; &gt; <br>&gt; &gt; (gdb) bt<br>&gt; &gt; #0 &nbsp;0x00007f245cc28df1 in su_casematch (s1=0x7f245cc7fc57 "",<br>&gt; &gt; &nbsp; &nbsp; s2=0x3000000030 &lt;Address 0x3000000030 out of bounds&gt;) at su_string.c:224<br>&gt; &gt; #1 &nbsp;0x00007f245cc377ff in tport_server_addrinfo (mr=0x7f243c003c30,<br>&gt; &gt; &nbsp; &nbsp; canon=0x7f243c003bfe "[::1]", family=0, host=0x7f245c958670 "::1",<br>&gt; &gt; &nbsp; &nbsp; service=0x7f243c003c04 "5060", protocol=0x7f245cc7fc56 "*",<br>&gt; &gt; &nbsp; &nbsp; transports=0x7f245c9589c0, return_addrinfo=0x7f245c958608) at tport.c:1814<br>&gt; &gt; #2 &nbsp;0x00007f245cc370a1 in tport_bind_server (mr=0x7f243c003c30,<br>&gt; &gt; &nbsp; &nbsp; tpn=0x7f245c958770, transports=0x7f245c9589c0, public=tport_type_local,<br>&gt; &gt; &nbsp; &nbsp; tags=0x7f245c958730) at tport.c:1652<br>&gt; &gt; #3 &nbsp;0x00007f245cc36762 in tport_tbind (self=0x7f243c003c30,<br>&gt; &gt; &nbsp; &nbsp; tpn=0x7f245c958a50, transports=0x7f245c9589c0,<br>&gt; &gt; &nbsp; &nbsp; tag=0x7f245cecae20 &lt;tptag_ident&gt;, value=139794152182707) at tport.c:1524<br>&gt; &gt; #4 &nbsp;0x00007f245cb8882d in nta_agent_add_tport (self=0x7f243c001e40,<br>&gt; &gt; &nbsp; &nbsp; uri=0x7f24400099c0, tag=0x7f245cecae20 &lt;tptag_ident&gt;,<br>&gt; &gt; &nbsp; &nbsp; value=139794152182707) at nta.c:2237<br>&gt; &gt; #5 &nbsp;0x00007f245cbc4e71 in nua_stack_init_transport (nua=0x7f2440007970,<br>&gt; &gt; &nbsp; &nbsp; tags=0x7f24400098f0) at nua_register.c:1216<br>&gt; &gt; #6 &nbsp;0x00007f245cbd6b6b in nua_stack_init (root=0x7f243c001130,<br>&gt; &gt; &nbsp; &nbsp; nua=0x7f2440007970) at nua_stack.c:194<br>&gt; &gt; #7 &nbsp;0x00007f245cc24441 in su_pthread_port_clone_main (varg=0x7f245c9d03d0)<br>&gt; &gt; &nbsp; &nbsp; at su_pthread_port.c:340<br>&gt; &gt; #8 &nbsp;0x00007f2460ffae9a in start_thread ()<br>&gt; &gt; &nbsp; &nbsp;from /lib/x86_64-linux-gnu/libpthread.so.0<br>&gt; &gt; ---Type &lt;return&gt; to continue, or q &lt;return&gt; to quit---<br>&gt; &gt; #9 &nbsp;0x00007f2460d27ccd in clone () from /lib/x86_64-linux-gnu/libc.so.6<br>&gt; &gt; #10 0x0000000000000000 in ?? ()<br>&gt; &gt; <br>&gt; &gt; <br>&gt; &gt; In tport_server_addrinfo() :<br>&gt; &gt; <br>&gt; &gt; (gdb) list tport_server_addrinfo<br>&gt; &gt; ...<br>&gt; &gt; 1800 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;char const * const transports[],<br>&gt; &gt; ...<br>&gt; &gt; ...<br>&gt; &gt; 1811 &nbsp; &nbsp; &nbsp;for (i = 0, N = 0; transports[i] &amp;&amp; N &lt; TPORT_N; i++) {<br>&gt; &gt; 1812 &nbsp; &nbsp; &nbsp; &nbsp;su_addrinfo_t *ai = &amp;hints[N];<br>&gt; &gt; 1813 &nbsp;&nbsp;<br>&gt; &gt; 1814 &nbsp; &nbsp; &nbsp; &nbsp;if (!su_casematch(protocol, transports[i]) &amp;&amp;<br>&gt; &gt; !su_strmatch(protocol, "*"))<br>&gt; &gt; <br>&gt; &gt; So char const * const transports[] is not correctly initialized before using<br>&gt; &gt; its values in the for loop.<br>&gt; &gt; <br>&gt; &gt; (gdb) p transports[0]<br>&gt; &gt; $3 = 0x3000000030 &lt;Address 0x3000000030 out of bounds&gt;<br>&gt; &gt; (gdb) p transports[1]<br>&gt; &gt; $4 = 0x7f245c958d00 "`\215\225\\$\177"<br>&gt; &gt; <br>&gt; &gt; So transports[0] is the problematic initialization here.<br>&gt; &gt; <br>&gt; &gt; Going back further, in libs/sofia-sip/libsofia-sip-ua/nta/nta.c: 2150<br>&gt; &gt; <br>&gt; &gt; &nbsp; &nbsp;char const * const * tports = tports_sip;<br>&gt; &gt; <br>&gt; &gt; And here<br>&gt; &gt; <br>&gt; &gt; (gdb) ptype tports_sip<br>&gt; &gt; type = const char * const[5]<br>&gt; &gt; (gdb) p tports_sip[0]<br>&gt; &gt; $6 = 0x7f245cc7fc38 "udp"<br>&gt; &gt; (gdb) p tports[0]<br>&gt; &gt; $7 = 0x3000000030 &lt;Address 0x3000000030 out of bounds&gt;<br>&gt; &gt; (gdb) ptype tports_sip<br>&gt; &gt; type = const char * const[5]<br>&gt; &gt; (gdb) p tports<br>&gt; &gt; $11 = (const char * const *) 0x7f245c9589c0<br>&gt; &gt; (gdb) p &amp;tports_sip<br>&gt; &gt; $12 = (const char * const(*)[5]) 0x7f245cebf660 &lt;tports_sip&gt;<br>&gt; &gt; <br>&gt; &gt; As it can be seen, tports diverged from initial tports_sip.<br>&gt; &gt; It has been done in following snippet :<br>&gt; &gt; <br>&gt; &gt; &nbsp;2197 &nbsp; &nbsp; &nbsp; if (strchr(tp, ',')) {<br>&gt; &gt; &nbsp;2198 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; int i; char *t, *tps[9] = {0};<br>&gt; &gt; &nbsp;2199<br>&gt; &gt; &nbsp;2200 &nbsp; &nbsp; &nbsp; &nbsp; /* Split tp into transports */<br>&gt; &gt; &nbsp;2201 &nbsp; &nbsp; &nbsp; &nbsp; for (i = 0, t = tp; t &amp;&amp; i &lt; 8; i++) {<br>&gt; &gt; &nbsp;2202 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; tps[i] = t;<br>&gt; &gt; &nbsp;2203 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if ((t = strchr(t, ',')))<br>&gt; &gt; &nbsp;2204 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; *t++ = '\0';<br>&gt; &gt; &nbsp;2205 &nbsp; &nbsp; &nbsp; &nbsp; }<br>&gt; &gt; &nbsp;2206<br>&gt; &gt; &nbsp;2207 &nbsp; &nbsp; &nbsp; &nbsp; tps[i] = NULL;<br>&gt; &gt; &nbsp;2208 &nbsp; &nbsp; &nbsp; &nbsp; tports = (char const * const *)tps;<br>&gt; &gt; <br>&gt; &gt; <br>&gt; &gt; Now :<br>&gt; &gt; <br>&gt; &gt; (gdb) p tp<br>&gt; &gt; $20 = &nbsp; "udp\000tcp\000H\215\225\\$\177\000\000\240\252\354\\"..<br>&gt; &gt; <br>&gt; &gt; So above code should parse "udp" in tports[0]. Which is not the case here.<br>&gt; &gt; <br>&gt; &gt; I'm assuming this bug has to generated from a more higher level, rather than<br>&gt; &gt; happened in a file which has not been touched since 2006( I git blamed it).<br>&gt; &gt; <br>&gt; &gt; But bt does not have any calls to "non-sofia" stuff.<br>&gt; &gt; <br>&gt; &gt; This su_casematch() was called from two threads,<br>&gt; &gt; <br>&gt; &gt; &nbsp; 4 &nbsp; &nbsp;Thread 0x7f245eccb700 (LWP 7622) 0x00007f245cc28df1 in su_casematch (<br>&gt; &gt; &nbsp; &nbsp; s1=0x7f245cc7fc57 "", s2=0x3000000030 &lt;Address 0x3000000030 out of<br>&gt; &gt; bounds&gt;)<br>&gt; &gt; &nbsp; &nbsp; at su_string.c:224<br>&gt; &gt; <br>&gt; &gt; * 1 &nbsp; &nbsp;Thread 0x7f245c959700 (LWP 7623) 0x00007f245cc28df1 in su_casematch (<br>&gt; &gt; &nbsp; &nbsp; s1=0x7f245cc7fc57 "", s2=0x3000000030 &lt;Address 0x3000000030 out of<br>&gt; &gt; bounds&gt;)<br>&gt; &gt; &nbsp; &nbsp; at su_string.c:224<br>&gt; &gt; <br>&gt; &gt; <br>&gt; &gt; Both calls to su_casematch seems problematic.<br>&gt; &gt; <br>&gt; &gt; Sorry for a long BUGREPORT. Actually i thought i should post &nbsp;my investigation<br>&gt; &gt; if it helps the devs(After git blaming, i highly suspect that my investigation<br>&gt; &gt; unearthed nothing , problem generated from elsewhere, which i could not find).<br>&gt; &gt; <br>&gt; &gt; I've not started git bisecting. If it helps, i will be happy to do that.<br>&gt; &gt; <br>&gt; &gt; <br>&gt; &gt; <br>&gt; &gt; <br>&gt; &gt; <br>&gt; &gt; --&nbsp;<br>&gt; &gt; Cheers<br>&gt; &gt; arif            <br>&gt; &gt; _________________________________________________________________________<br>&gt; &gt; Professional FreeSWITCH Consulting Services:<br>&gt; &gt; consulting@freeswitch.org<br>&gt; &gt; http://www.freeswitchsolutions.com<br>&gt; &gt; <br>&gt; &gt; FreeSWITCH-powered IP PBX: The CudaTel Communication Server<br>&gt; &gt; http://www.cudatel.com<br>&gt; &gt; <br>&gt; &gt; Official FreeSWITCH Sites<br>&gt; &gt; http://www.freeswitch.org<br>&gt; &gt; http://wiki.freeswitch.org<br>&gt; &gt; http://www.cluecon.com<br>&gt; &gt; <br>&gt; &gt; FreeSWITCH-users mailing list<br>&gt; &gt; FreeSWITCH-users@lists.freeswitch.org<br>&gt; &gt; http://lists.freeswitch.org/mailman/listinfo/freeswitch-users<br>&gt; &gt; UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users<br>&gt; &gt; http://www.freeswitch.org<br>&gt; <br>&gt; -- <br>&gt; Ken<br>&gt; http://www.FreeSWITCH.org<br>&gt; http://www.ClueCon.com<br>&gt; http://www.OSTAG.org<br>&gt; irc.freenode.net #freeswitch<br>&gt; <br>&gt; <br>&gt; <br>&gt; _________________________________________________________________________<br>&gt; Professional FreeSWITCH Consulting Services:<br>&gt; consulting@freeswitch.org<br>&gt; http://www.freeswitchsolutions.com<br>&gt; <br>&gt; FreeSWITCH-powered IP PBX: The CudaTel Communication Server<br>&gt; http://www.cudatel.com<br>&gt; <br>&gt; Official FreeSWITCH Sites<br>&gt; http://www.freeswitch.org<br>&gt; http://wiki.freeswitch.org<br>&gt; http://www.cluecon.com<br>&gt; <br>&gt; FreeSWITCH-dev mailing list<br>&gt; FreeSWITCH-dev@lists.freeswitch.org<br>&gt; http://lists.freeswitch.org/mailman/listinfo/freeswitch-dev<br>&gt; UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-dev<br>&gt; http://www.freeswitch.org<br></div>                                               </div></body>
</html>