Hi Stephen,<br><br>Thanks for your advise, i tried it, i issued below commands, however, i did not find any core named files under freeswitch bin directory, and below is the screen showing, i could you identify the root cause, could you please help, thanks a lot!<br>
<br>gdb -c core.xxx freeswitch<br>ddb&gt;run<br>...(fs running up)<br>gdb&gt;bt full<br><br>freeswitch@freeswitch&gt; 2011-10-25 10:30:44.161051 [WARNING] sofia_reg.c:1337 SIP auth challenge (INVITE) on sofia profile &#39;internal&#39; for [<a href="mailto:13910936628@124.193.106.104">13910936628@124.193.106.104</a>] from ip 222.128.70.10<br>
2011-10-25 10:30:45.081037 [NOTICE] switch_channel.c:897 New Channel sofia/internal/<a href="mailto:13580358068@124.193.106.104">13580358068@124.193.106.104</a> [38946a57-c673-4705-8433-36f4b066d01c]<br>[New Thread 0xb71d6b90 (LWP 19991)]<br>
is_b is: 0<br>excute external cmd: check_billing_before_answer 13580358068 13910936628 38946a57-c673-4705-8433-36f4b066d01c 9 222.128.70.10<br>2011-10-25 10:30:45.081037 [INFO] mod_nibblebill.c:1017 check_billing_before_routing, in_username: 13580358068, in_calledstation: 13910936628, in_uniqueid: 38946a57-c673-4705-8433-36f4b066d01c in_type: 9, in_network_addr: 222.128.70.10 <br>
Detaching after fork from child process 19992.<br>the result of excuting external cmd: <br>the result of excuting external cmd: 60<br><br>Program received signal SIGSEGV, Segmentation fault.<br>[Switching to Thread 0xb71d6b90 (LWP 19991)]<br>
0x008ff698 in switch_core_get_state_handler@plt () from /usr/local/freeswitch/lib/libfreeswitch.so.1<br>(gdb) bt full<br><span style="background-color: rgb(255, 255, 0);">#0  0x008ff698 in switch_core_get_state_handler@plt ()</span><br>
   from /usr/local/freeswitch/lib/libfreeswitch.so.1<br>No symbol table info available.<br>#1  0x0092d558 in switch_core_session_run (session=0x81bc238) at src/switch_core_state_machine.c:373<br>        global_proceed = 1<br>
        proceed = &lt;value optimized out&gt;<br>        ptr = &lt;value optimized out&gt;<br>        rstatus = &lt;value optimized out&gt;<br>        state = &lt;value optimized out&gt;<br>        endstate = &lt;value optimized out&gt;<br>
        endpoint_interface = &lt;value optimized out&gt;<br>        driver_state_handler = 0xcb8420<br>        application_state_handler = &lt;value optimized out&gt;<br>        new_loops = 60000<br>        __PRETTY_FUNCTION__ = &quot;switch_core_session_run&quot;<br>
        __func__ = &quot;switch_core_session_run&quot;<br>#2  0x009275ca in switch_core_session_thread (thread=0x823fdd8, obj=0x81bc238)<br>    at src/switch_core_session.c:1309<br>        session = 0x81bc238<br>        event = &lt;value optimized out&gt;<br>
        event_str = 0x0<br>        val = &lt;value optimized out&gt;<br>        __func__ = &quot;switch_core_session_thread&quot;<br>        __PRETTY_FUNCTION__ = &quot;switch_core_session_thread&quot;<br>#3  0x009c2d16 in dummy_worker (opaque=0x823fdd8) at threadproc/unix/thread.c:138<br>
---Type &lt;return&gt; to continue, or q &lt;return&gt; to quit---<br>No locals.<br>#4  0x002af832 in start_thread () from /lib/libpthread.so.0<br>No symbol table info available.<br>#5  0x0078145e in clone () from /lib/libc.so.6<br>
No symbol table info available.<br>(gdb) <br><br><div class="gmail_quote">2011/10/24 Stephen Wilde <span dir="ltr">&lt;<a href="mailto:wstephen80@gmail.com">wstephen80@gmail.com</a>&gt;</span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
You can issue a:<div><br></div><div>gdb -c core.xxx freeswitch</div><div><br></div><div>in freeswitch bin directory where core.xxx is the name of the generated core dump then, in gdb:</div><div><br></div><div>bt full</div>

<div><br></div><div>to show the stack backtrace</div><div><div></div><div class="h5"><div><br><div class="gmail_quote">On Mon, Oct 24, 2011 at 11:53 AM, fieldpeak <span dir="ltr">&lt;<a href="mailto:fieldpeak@gmail.com" target="_blank">fieldpeak@gmail.com</a>&gt;</span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi Stephen,<br><br>Thanks for your kindly help, however, i changed it as your advise, the core still dumped.<br><br>below is the updated code,<div>

<br><br>static switch_status_t check_billing_before_routing(switch_core_session_t *session)<br>
{<br>    //charles, check billing before routing the call<br>    <br>    char buf[128];<br></div>   <span style="background-color:rgb(255, 255, 0)"> char cmd[100];</span><div><div></div><div><br>    FILE *pp = NULL;<br>
<br>    const char* in_username = NULL;<br>
    const char* in_calledstation = NULL;<br>    const char* in_uniqueid = NULL;<br>    const char* in_network_addr = NULL;<br>    const char* in_type = &quot;9&quot;;<br>    int is_b;<br>    <br>    //const char* full_cmd;<br>


    int i_continue = 1;<br>    switch_channel_t *channel = NULL;<br><br><br>    in_uniqueid = switch_core_session_get_uuid(session);<br>    <br>    channel = switch_core_session_get_channel(session);<br><br>    /*only billing on a leg*/<br>


    is_b = channel &amp;&amp; switch_channel_get_originator_caller_profile(channel);<br>    printf(&quot;is_b is: %d\n&quot;, is_b);<br>    if(is_b)<br>    {<br>    return SWITCH_STATUS_SUCCESS;<br>    }<br><br>    /* Lock this session&#39;s data for this module while we tinker with it */<br>


    if (globals.mutex) {<br>        switch_mutex_lock(globals.mutex);<br>    }<br>    <br>    <br>    in_username = switch_channel_get_variable(channel, &quot;caller_id_number&quot;);<br>    in_calledstation = switch_channel_get_variable(channel, &quot;destination_number&quot;);<br>


    in_network_addr = switch_channel_get_variable(channel, &quot;network_addr&quot;);<br><br>    <br>    /* Done checking - release lock */<br>    if (globals.mutex) {<br>        switch_mutex_unlock(globals.mutex);<br>    }<br>


    <br><br>    switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, &quot;check_billing_before_routing, in_username: %s, in_calledstation: %s, in_uniqueid: %s in_type: %s, in_network_addr: %s \n&quot;, in_username, in_calledstation, in_uniqueid, in_type, in_network_addr);<br>


    <br></div></div>   <span style="background-color:rgb(255, 255, 0)"> strcpy(cmd,&quot;&quot;);</span><br style="background-color:rgb(255, 255, 0)"><span style="background-color:rgb(255, 255, 0)">    strcat(cmd, &quot;check_billing_before_answer&quot;);</span><div>

<div></div><div><br style="background-color:rgb(255, 255, 0)">
<span style="background-color:rgb(255, 255, 0)">    strcat(cmd, &quot; &quot;);</span><br>    strcat(cmd, in_username);<br>    strcat(cmd, &quot; &quot;);<br>    strcat(cmd, in_calledstation);<br>    strcat(cmd, &quot; &quot;);<br>


    strcat(cmd, in_uniqueid);<br>    strcat(cmd, &quot; &quot;);<br>    strcat(cmd, in_type);<br>    strcat(cmd, &quot; &quot;);<br>    strcat(cmd, in_network_addr);<br><br>    printf(&quot;excute external cmd: &quot;);<br>


    printf(cmd);<br>    printf(&quot;\n&quot;);<br><br>    if( (pp = popen(cmd, &quot;r&quot;)) == NULL )<br>    {<br>        printf(&quot;popen() error!\n&quot;);<br>        exit(1);<br>    }<br><br>    while(fgets(buf, sizeof buf, pp))<br>


    {<br>        printf(&quot;the result of excuting external cmd: %s&quot;, buf);<br>    }<br><br>    if(pp)<br>    {<br>        pclose(pp); <br>    }<br><br>    i_continue =  atoi(buf);<br><br>    printf(&quot;i_continue: %d&quot;, i_continue);<br>


<br><br>    if (!i_continue) {<br>        <br>        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, &quot;call was not authorized to continue \n&quot;);<br>    <br>        transfer_call(session, globals.nobal_action);<br>


    }<br><br>    <br><br><br>    return SWITCH_STATUS_SUCCESS;<br><br>}<br><br><br></div></div><div><div></div><div><div class="gmail_quote">2011/10/24 Stephen Wilde <span dir="ltr">&lt;<a href="mailto:wstephen80@gmail.com" target="_blank">wstephen80@gmail.com</a>&gt;</span><br>


<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Can you try to change the allocation of cmd as:<div><br></div><div><span style="font-family:arial, sans-serif;font-size:medium"><table style="padding-top:0px;padding-right:0px;padding-bottom:0px;padding-left:0px;border-collapse:collapse;background-color:rgb(255, 255, 255);width:1248px;background-repeat:initial initial" cellpadding="0">




<tbody><tr><td style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;font-family:arial, sans-serif;vertical-align:top;padding-top:0px;padding-right:0px;padding-bottom:0px;padding-left:0px">
<div style="padding-top:0px;padding-right:0px;padding-bottom:1px;padding-left:0px"><div><div style="color:rgb(0, 0, 0);padding-top:4px;padding-right:8px;padding-bottom:4px;padding-left:8px">
<div><div style="clear:both;padding-bottom:0px"><div style="margin-bottom:10px;border-right-width:1px;border-bottom-width:1px;border-left-width:1px;border-top-style:solid;border-right-style:solid;border-bottom-style:solid;border-left-style:solid;border-top-color:rgb(239, 239, 239);border-right-color:rgb(239, 239, 239);border-left-color:rgb(239, 239, 239);border-bottom-color:rgb(226, 226, 226);border-top-width:0px;border-top-left-radius:7px 7px;border-top-right-radius:7px 7px;border-bottom-right-radius:7px 7px;border-bottom-left-radius:7px 7px;width:999px">




<div style="padding-top:3px;background-color:rgb(255, 255, 255);border-right-width:1px;border-bottom-width:1px;border-left-width:1px;border-right-style:solid;border-bottom-style:solid;border-left-style:solid;border-right-color:rgb(188, 188, 188);border-bottom-color:rgb(188, 188, 188);border-left-color:rgb(188, 188, 188);border-top-width:1px;border-top-style:solid;border-top-color:rgb(188, 188, 188);border-top-left-radius:7px 7px;border-top-right-radius:7px 7px;border-bottom-right-radius:7px 7px;border-bottom-left-radius:7px 7px">




<div><div><div><div><div style="font-size:13px;margin-top:5px;margin-right:15px;margin-bottom:5px;margin-left:15px;padding-bottom:20px">
<div>char cmd[100];</div><div><br></div><div>....</div><div><br></div><div>
<p style="margin:0.0px 0.0px 0.0px 0.0px;font:13.0px Arial"></p><p style="margin:0.0px 0.0px 0.0px 0.0px;font:13.0px Arial">strcat(cmd, &quot;check_billing_before_answer &quot;);</p><p></p>
<p style="margin:0.0px 0.0px 0.0px 0.0px;font:13.0px Arial">strcat(cmd, in_username);</p>
<p style="margin:0.0px 0.0px 0.0px 0.0px;font:13.0px Arial">strcat(cmd, &quot; &quot;);</p><p style="margin:0.0px 0.0px 0.0px 0.0px;font:13.0px Arial"><br></p><p style="margin:0.0px 0.0px 0.0px 0.0px;font:13.0px Arial">....</p>



</div></div></div></div></div></div></div></div></div></div></div></div></div></td></tr></tbody></table></span><font face="arial, sans-serif"><span style="border-collapse:collapse"><br>
</span></font><div class="gmail_quote"><div><div></div><div>On Mon, Oct 24, 2011 at 10:39 AM, fieldpeak <span dir="ltr">&lt;<a href="mailto:fieldpeak@gmail.com" target="_blank">fieldpeak@gmail.com</a>&gt;</span> wrote:<br>


</div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div></div><div>

Hi Friends,<br><br>i&#39;m using mod_nibblebill for billing on FS, i bundled event processing<br>fucntions when status change,<br>e.g. /* on_routing */ check_billing_before_routing,<br>and * on_hangup */ process_hangup, as below,<br>





however, i found if i make a call containing two-legs e.g. user 1001 call user 1002, then the FS core dump. but if i only make one leg call, e.g. call 888 for IVR, then no problem occure, i found the problem within function &quot;check_billing_before_routing&quot; (because once i comment all of lines within this func, the core did not dump). below is the func &quot;check_billing_before_routing&quot;, can anyone help advise what&#39;s wrong? how should i correct it, thanks.<br>





<br>static switch_status_t check_billing_before_routing(switch_core_session_t *session)<br>{<br>    //charles, check billing before routing the call<br>    <br>    char buf[128];<br>    char cmd[100] = &quot;check_billing_before_answer&quot;;<br>





    FILE *pp = NULL;<br><br>    const char* in_username = NULL;<br>    const char* in_calledstation = NULL;<br>    const char* in_uniqueid = NULL;<br>    const char* in_network_addr = NULL;<br>    const char* in_type = &quot;9&quot;;<br>





    int is_b;<br>    <br>    //const char* full_cmd;<br>    int i_continue = 1;<br>    switch_channel_t *channel = NULL;<br><br><br>    in_uniqueid = switch_core_session_get_uuid(session);<br>    <br>    channel = switch_core_session_get_channel(session);<br>





<br>    /*only billing on a leg*/<br>    is_b = channel &amp;&amp; switch_channel_get_originator_caller_profile(channel);<br>    printf(&quot;is_b is: %d\n&quot;, is_b);<br>    if(is_b)<br>    {<br>    return SWITCH_STATUS_SUCCESS;<br>





    }<br><br>    /* Lock this session&#39;s data for this module while we tinker with it */<br>    if (globals.mutex) {<br>        switch_mutex_lock(globals.mutex);<br>    }<br>    <br>    <br>    in_username = switch_channel_get_variable(channel, &quot;caller_id_number&quot;);<br>





    in_calledstation = switch_channel_get_variable(channel, &quot;destination_number&quot;);<br>    in_network_addr = switch_channel_get_variable(channel, &quot;network_addr&quot;);<br><br>    <br>    /* Done checking - release lock */<br>





    if (globals.mutex) {<br>        switch_mutex_unlock(globals.mutex);<br>    }<br>    <br><br>    switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, &quot;check_billing_before_routing, in_username: %s, in_calledstation: %s, in_uniqueid: %s in_type: %s, in_network_addr: %s \n&quot;, in_username, in_calledstation, in_uniqueid, in_type, in_network_addr);<br>





    <br><br>    strcat(cmd, &quot; &quot;);<br>    strcat(cmd, in_username);<br>    strcat(cmd, &quot; &quot;);<br>    strcat(cmd, in_calledstation);<br>    strcat(cmd, &quot; &quot;);<br>    strcat(cmd, in_uniqueid);<br>





    strcat(cmd, &quot; &quot;);<br>    strcat(cmd, in_type);<br>    strcat(cmd, &quot; &quot;);<br>    strcat(cmd, in_network_addr);<br><br>    printf(&quot;excute external cmd: &quot;);<br>    printf(cmd);<br>    printf(&quot;\n&quot;);<br>





<br>    if( (pp = popen(cmd, &quot;r&quot;)) == NULL )<br>    {<br>        printf(&quot;popen() error!\n&quot;);<br>        exit(1);<br>    }<br><br>    while(fgets(buf, sizeof buf, pp))<br>    {<br>        printf(&quot;the result of excuting external cmd: %s&quot;, buf);<br>





    }<br><br>    if(pp)<br>    {<br>        pclose(pp); <br>    }<br><br>    i_continue =  atoi(buf);<br><br>    printf(&quot;i_continue: %d&quot;, i_continue);<br><br><br>    if (!i_continue) {<br>        <br>        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, &quot;call was not authorized to continue \n&quot;);<br>





    <br>        transfer_call(session, globals.nobal_action);<br>    }<br><br>    <br><br><br>    return SWITCH_STATUS_SUCCESS;<br><br>}<br><br><br><span style="background-color:rgb(255, 255, 51)">Core dump logs:</span><br>





<br>freeswitch@freeswitch&gt; 2011-10-24 16:30:26.583369 [NOTICE] mod_xml_rpc.c:969 Starting HTTP Port 8787, DocRoot [/usr/local/freeswitch/htdocs]<br>2011-10-24 16:30:29.454743 [WARNING] sofia_reg.c:1337 SIP auth challenge (INVITE) on sofia profile &#39;internal&#39; for [<a href="mailto:6628@224.193.106.204" target="_blank">6628@224.193.106.204</a>] from ip 223.128.70.10<br>





2011-10-24 16:30:30.254710 [NOTICE] switch_channel.c:897 New Channel sofia/internal/<a href="mailto:8068@224.193.106.204" target="_blank">8068@224.193.106.204</a> [196a50b8-eaa0-4ef0-a674-18602117f5ec]<br>is_b is: 0<br>excute external cmd: check_billing_before_answer 8068 6628 196a50b8-eaa0-4ef0-a674-18602117f5ec 9 223.128.70.10<br>





2011-10-24 16:30:30.254710 [INFO] mod_nibblebill.c:1017 check_billing_before_routing, in_username: 8068, in_calledstation: 6628, in_uniqueid: 196a50b8-eaa0-4ef0-a674-18602117f5ec in_type: 9, in_network_addr: 223.128.70.10 <br>





the result of excuting external cmd: <br>the result of excuting external cmd: 60<br>Segmentation fault (core dumped)<br>[root@freeswitch bin]# <br><font color="#888888"><br>-- <br>Regards,<br>Charles<br><br>
</font><br><br></div></div>
FreeSWITCH-users mailing list<br>
<a href="mailto:FreeSWITCH-users@lists.freeswitch.org" target="_blank">FreeSWITCH-users@lists.freeswitch.org</a><br>
<a href="http://lists.freeswitch.org/mailman/listinfo/freeswitch-users" target="_blank">http://lists.freeswitch.org/mailman/listinfo/freeswitch-users</a><br>
UNSUBSCRIBE:<a href="http://lists.freeswitch.org/mailman/options/freeswitch-users" target="_blank">http://lists.freeswitch.org/mailman/options/freeswitch-users</a><br>
<a href="http://www.freeswitch.org" target="_blank">http://www.freeswitch.org</a><br>
<br></blockquote></div><br></div>
<br><br>
FreeSWITCH-users mailing list<br>
<a href="mailto:FreeSWITCH-users@lists.freeswitch.org" target="_blank">FreeSWITCH-users@lists.freeswitch.org</a><br>
<a href="http://lists.freeswitch.org/mailman/listinfo/freeswitch-users" target="_blank">http://lists.freeswitch.org/mailman/listinfo/freeswitch-users</a><br>
UNSUBSCRIBE:<a href="http://lists.freeswitch.org/mailman/options/freeswitch-users" target="_blank">http://lists.freeswitch.org/mailman/options/freeswitch-users</a><br>
<a href="http://www.freeswitch.org" target="_blank">http://www.freeswitch.org</a><br>
<br></blockquote></div><br><br clear="all"><br></div></div><font color="#888888">-- <br>Regards,<br>Charles<br><br>
</font><br><br>
FreeSWITCH-users mailing list<br>
<a href="mailto:FreeSWITCH-users@lists.freeswitch.org" target="_blank">FreeSWITCH-users@lists.freeswitch.org</a><br>
<a href="http://lists.freeswitch.org/mailman/listinfo/freeswitch-users" target="_blank">http://lists.freeswitch.org/mailman/listinfo/freeswitch-users</a><br>
UNSUBSCRIBE:<a href="http://lists.freeswitch.org/mailman/options/freeswitch-users" target="_blank">http://lists.freeswitch.org/mailman/options/freeswitch-users</a><br>
<a href="http://www.freeswitch.org" target="_blank">http://www.freeswitch.org</a><br>
<br></blockquote></div><br></div>
</div></div><br><br>
FreeSWITCH-users mailing list<br>
<a href="mailto:FreeSWITCH-users@lists.freeswitch.org">FreeSWITCH-users@lists.freeswitch.org</a><br>
<a href="http://lists.freeswitch.org/mailman/listinfo/freeswitch-users" target="_blank">http://lists.freeswitch.org/mailman/listinfo/freeswitch-users</a><br>
UNSUBSCRIBE:<a href="http://lists.freeswitch.org/mailman/options/freeswitch-users" target="_blank">http://lists.freeswitch.org/mailman/options/freeswitch-users</a><br>
<a href="http://www.freeswitch.org" target="_blank">http://www.freeswitch.org</a><br>
<br></blockquote></div><br><br clear="all"><br>-- <br>Regards,<br>Charles<br><br>