Advise on FS core dump
Hi Friends, i'm using mod_nibblebill for billing on FS, i bundled event processing fucntions when status change, e.g. /* on_routing */ check_billing_before_routing, and * on_hangup */ process_hangup, as below, 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 "check_billing_before_routing" (because once i comment all of lines within this func, the core did not dump). below is the func "check_billing_before_routing", can anyone help advise what's wrong? how should i correct it, thanks. static switch_status_t check_billing_before_routing(switch_core_session_t *session) { //charles, check billing before routing the call char buf[128]; char cmd[100] = "check_billing_before_answer"; FILE *pp = NULL; const char* in_username = NULL; const char* in_calledstation = NULL; const char* in_uniqueid = NULL; const char* in_network_addr = NULL; const char* in_type = "9"; int is_b; //const char* full_cmd; int i_continue = 1; switch_channel_t *channel = NULL; in_uniqueid = switch_core_session_get_uuid(session); channel = switch_core_session_get_channel(session); /*only billing on a leg*/ is_b = channel && switch_channel_get_originator_caller_profile(channel); printf("is_b is: %d\n", is_b); if(is_b) { return SWITCH_STATUS_SUCCESS; } /* Lock this session's data for this module while we tinker with it */ if (globals.mutex) { switch_mutex_lock(globals.mutex); } in_username = switch_channel_get_variable(channel, "caller_id_number"); in_calledstation = switch_channel_get_variable(channel, "destination_number"); in_network_addr = switch_channel_get_variable(channel, "network_addr"); /* Done checking - release lock */ if (globals.mutex) { switch_mutex_unlock(globals.mutex); } switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "check_billing_before_routing, in_username: %s, in_calledstation: %s, in_uniqueid: %s in_type: %s, in_network_addr: %s \n", in_username, in_calledstation, in_uniqueid, in_type, in_network_addr); strcat(cmd, " "); strcat(cmd, in_username); strcat(cmd, " "); strcat(cmd, in_calledstation); strcat(cmd, " "); strcat(cmd, in_uniqueid); strcat(cmd, " "); strcat(cmd, in_type); strcat(cmd, " "); strcat(cmd, in_network_addr); printf("excute external cmd: "); printf(cmd); printf("\n"); if( (pp = popen(cmd, "r")) == NULL ) { printf("popen() error!\n"); exit(1); } while(fgets(buf, sizeof buf, pp)) { printf("the result of excuting external cmd: %s", buf); } if(pp) { pclose(pp); } i_continue = atoi(buf); printf("i_continue: %d", i_continue); if (!i_continue) { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, "call was not authorized to continue \n"); transfer_call(session, globals.nobal_action); } return SWITCH_STATUS_SUCCESS; } Core dump logs: freeswitch@freeswitch> 2011-10-24 16:30:26.583369 [NOTICE] mod_xml_rpc.c:969 Starting HTTP Port 8787, DocRoot [/usr/local/freeswitch/htdocs] 2011-10-24 16:30:29.454743 [WARNING] sofia_reg.c:1337 SIP auth challenge (INVITE) on sofia profile 'internal' for [6628@224.193.106.204] from ip 223.128.70.10 2011-10-24 16:30:30.254710 [NOTICE] switch_channel.c:897 New Channel sofia/internal/8068@224.193.106.204 [196a50b8-eaa0-4ef0-a674-18602117f5ec] is_b is: 0 excute external cmd: check_billing_before_answer 8068 6628 196a50b8-eaa0-4ef0-a674-18602117f5ec 9 223.128.70.10 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 the result of excuting external cmd: the result of excuting external cmd: 60 Segmentation fault (core dumped) [root@freeswitch bin]# -- Regards, Charles
Can you try to change the allocation of cmd as: char cmd[100]; .... strcat(cmd, "check_billing_before_answer "); strcat(cmd, in_username); strcat(cmd, " "); .... On Mon, Oct 24, 2011 at 10:39 AM, fieldpeak <fieldpeak@gmail.com> wrote:
Hi Friends,
i'm using mod_nibblebill for billing on FS, i bundled event processing fucntions when status change, e.g. /* on_routing */ check_billing_before_routing, and * on_hangup */ process_hangup, as below, 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 "check_billing_before_routing" (because once i comment all of lines within this func, the core did not dump). below is the func "check_billing_before_routing", can anyone help advise what's wrong? how should i correct it, thanks.
static switch_status_t check_billing_before_routing(switch_core_session_t *session) { //charles, check billing before routing the call
char buf[128]; char cmd[100] = "check_billing_before_answer"; FILE *pp = NULL;
const char* in_username = NULL; const char* in_calledstation = NULL; const char* in_uniqueid = NULL; const char* in_network_addr = NULL; const char* in_type = "9"; int is_b;
//const char* full_cmd; int i_continue = 1; switch_channel_t *channel = NULL;
in_uniqueid = switch_core_session_get_uuid(session);
channel = switch_core_session_get_channel(session);
/*only billing on a leg*/ is_b = channel && switch_channel_get_originator_caller_profile(channel); printf("is_b is: %d\n", is_b); if(is_b) { return SWITCH_STATUS_SUCCESS; }
/* Lock this session's data for this module while we tinker with it */ if (globals.mutex) { switch_mutex_lock(globals.mutex); }
in_username = switch_channel_get_variable(channel, "caller_id_number"); in_calledstation = switch_channel_get_variable(channel, "destination_number"); in_network_addr = switch_channel_get_variable(channel, "network_addr");
/* Done checking - release lock */ if (globals.mutex) { switch_mutex_unlock(globals.mutex); }
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "check_billing_before_routing, in_username: %s, in_calledstation: %s, in_uniqueid: %s in_type: %s, in_network_addr: %s \n", in_username, in_calledstation, in_uniqueid, in_type, in_network_addr);
strcat(cmd, " "); strcat(cmd, in_username); strcat(cmd, " "); strcat(cmd, in_calledstation); strcat(cmd, " "); strcat(cmd, in_uniqueid); strcat(cmd, " "); strcat(cmd, in_type); strcat(cmd, " "); strcat(cmd, in_network_addr);
printf("excute external cmd: "); printf(cmd); printf("\n");
if( (pp = popen(cmd, "r")) == NULL ) { printf("popen() error!\n"); exit(1); }
while(fgets(buf, sizeof buf, pp)) { printf("the result of excuting external cmd: %s", buf); }
if(pp) { pclose(pp); }
i_continue = atoi(buf);
printf("i_continue: %d", i_continue);
if (!i_continue) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, "call was not authorized to continue \n");
transfer_call(session, globals.nobal_action); }
return SWITCH_STATUS_SUCCESS;
}
Core dump logs:
freeswitch@freeswitch> 2011-10-24 16:30:26.583369 [NOTICE] mod_xml_rpc.c:969 Starting HTTP Port 8787, DocRoot [/usr/local/freeswitch/htdocs] 2011-10-24 16:30:29.454743 [WARNING] sofia_reg.c:1337 SIP auth challenge (INVITE) on sofia profile 'internal' for [6628@224.193.106.204] from ip 223.128.70.10 2011-10-24 16:30:30.254710 [NOTICE] switch_channel.c:897 New Channel sofia/internal/8068@224.193.106.204 [196a50b8-eaa0-4ef0-a674-18602117f5ec] is_b is: 0 excute external cmd: check_billing_before_answer 8068 6628 196a50b8-eaa0-4ef0-a674-18602117f5ec 9 223.128.70.10 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 the result of excuting external cmd: the result of excuting external cmd: 60 Segmentation fault (core dumped) [root@freeswitch bin]#
-- Regards, Charles
FreeSWITCH-users mailing list FreeSWITCH-users@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org
Hi Stephen, Thanks for your kindly help, however, i changed it as your advise, the core still dumped. below is the updated code, static switch_status_t check_billing_before_routing(switch_core_session_t *session) { //charles, check billing before routing the call char buf[128]; char cmd[100]; FILE *pp = NULL; const char* in_username = NULL; const char* in_calledstation = NULL; const char* in_uniqueid = NULL; const char* in_network_addr = NULL; const char* in_type = "9"; int is_b; //const char* full_cmd; int i_continue = 1; switch_channel_t *channel = NULL; in_uniqueid = switch_core_session_get_uuid(session); channel = switch_core_session_get_channel(session); /*only billing on a leg*/ is_b = channel && switch_channel_get_originator_caller_profile(channel); printf("is_b is: %d\n", is_b); if(is_b) { return SWITCH_STATUS_SUCCESS; } /* Lock this session's data for this module while we tinker with it */ if (globals.mutex) { switch_mutex_lock(globals.mutex); } in_username = switch_channel_get_variable(channel, "caller_id_number"); in_calledstation = switch_channel_get_variable(channel, "destination_number"); in_network_addr = switch_channel_get_variable(channel, "network_addr"); /* Done checking - release lock */ if (globals.mutex) { switch_mutex_unlock(globals.mutex); } switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "check_billing_before_routing, in_username: %s, in_calledstation: %s, in_uniqueid: %s in_type: %s, in_network_addr: %s \n", in_username, in_calledstation, in_uniqueid, in_type, in_network_addr); strcpy(cmd,""); strcat(cmd, "check_billing_before_answer"); strcat(cmd, " "); strcat(cmd, in_username); strcat(cmd, " "); strcat(cmd, in_calledstation); strcat(cmd, " "); strcat(cmd, in_uniqueid); strcat(cmd, " "); strcat(cmd, in_type); strcat(cmd, " "); strcat(cmd, in_network_addr); printf("excute external cmd: "); printf(cmd); printf("\n"); if( (pp = popen(cmd, "r")) == NULL ) { printf("popen() error!\n"); exit(1); } while(fgets(buf, sizeof buf, pp)) { printf("the result of excuting external cmd: %s", buf); } if(pp) { pclose(pp); } i_continue = atoi(buf); printf("i_continue: %d", i_continue); if (!i_continue) { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, "call was not authorized to continue \n"); transfer_call(session, globals.nobal_action); } return SWITCH_STATUS_SUCCESS; } 2011/10/24 Stephen Wilde <wstephen80@gmail.com>
Can you try to change the allocation of cmd as:
char cmd[100];
....
strcat(cmd, "check_billing_before_answer ");
strcat(cmd, in_username);
strcat(cmd, " ");
....
On Mon, Oct 24, 2011 at 10:39 AM, fieldpeak <fieldpeak@gmail.com> wrote:
Hi Friends,
i'm using mod_nibblebill for billing on FS, i bundled event processing fucntions when status change, e.g. /* on_routing */ check_billing_before_routing, and * on_hangup */ process_hangup, as below, 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 "check_billing_before_routing" (because once i comment all of lines within this func, the core did not dump). below is the func "check_billing_before_routing", can anyone help advise what's wrong? how should i correct it, thanks.
static switch_status_t check_billing_before_routing(switch_core_session_t *session) { //charles, check billing before routing the call
char buf[128]; char cmd[100] = "check_billing_before_answer"; FILE *pp = NULL;
const char* in_username = NULL; const char* in_calledstation = NULL; const char* in_uniqueid = NULL; const char* in_network_addr = NULL; const char* in_type = "9"; int is_b;
//const char* full_cmd; int i_continue = 1; switch_channel_t *channel = NULL;
in_uniqueid = switch_core_session_get_uuid(session);
channel = switch_core_session_get_channel(session);
/*only billing on a leg*/ is_b = channel && switch_channel_get_originator_caller_profile(channel); printf("is_b is: %d\n", is_b); if(is_b) { return SWITCH_STATUS_SUCCESS; }
/* Lock this session's data for this module while we tinker with it */ if (globals.mutex) { switch_mutex_lock(globals.mutex); }
in_username = switch_channel_get_variable(channel, "caller_id_number"); in_calledstation = switch_channel_get_variable(channel, "destination_number"); in_network_addr = switch_channel_get_variable(channel, "network_addr");
/* Done checking - release lock */ if (globals.mutex) { switch_mutex_unlock(globals.mutex); }
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "check_billing_before_routing, in_username: %s, in_calledstation: %s, in_uniqueid: %s in_type: %s, in_network_addr: %s \n", in_username, in_calledstation, in_uniqueid, in_type, in_network_addr);
strcat(cmd, " "); strcat(cmd, in_username); strcat(cmd, " "); strcat(cmd, in_calledstation); strcat(cmd, " "); strcat(cmd, in_uniqueid); strcat(cmd, " "); strcat(cmd, in_type); strcat(cmd, " "); strcat(cmd, in_network_addr);
printf("excute external cmd: "); printf(cmd); printf("\n");
if( (pp = popen(cmd, "r")) == NULL ) { printf("popen() error!\n"); exit(1); }
while(fgets(buf, sizeof buf, pp)) { printf("the result of excuting external cmd: %s", buf); }
if(pp) { pclose(pp); }
i_continue = atoi(buf);
printf("i_continue: %d", i_continue);
if (!i_continue) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, "call was not authorized to continue \n");
transfer_call(session, globals.nobal_action); }
return SWITCH_STATUS_SUCCESS;
}
Core dump logs:
freeswitch@freeswitch> 2011-10-24 16:30:26.583369 [NOTICE] mod_xml_rpc.c:969 Starting HTTP Port 8787, DocRoot [/usr/local/freeswitch/htdocs] 2011-10-24 16:30:29.454743 [WARNING] sofia_reg.c:1337 SIP auth challenge (INVITE) on sofia profile 'internal' for [6628@224.193.106.204] from ip 223.128.70.10 2011-10-24 16:30:30.254710 [NOTICE] switch_channel.c:897 New Channel sofia/internal/8068@224.193.106.204[196a50b8-eaa0-4ef0-a674-18602117f5ec] is_b is: 0 excute external cmd: check_billing_before_answer 8068 6628 196a50b8-eaa0-4ef0-a674-18602117f5ec 9 223.128.70.10 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 the result of excuting external cmd: the result of excuting external cmd: 60 Segmentation fault (core dumped) [root@freeswitch bin]#
-- Regards, Charles
FreeSWITCH-users mailing list FreeSWITCH-users@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org
FreeSWITCH-users mailing list FreeSWITCH-users@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org
-- Regards, Charles
You can issue a: gdb -c core.xxx freeswitch in freeswitch bin directory where core.xxx is the name of the generated core dump then, in gdb: bt full to show the stack backtrace On Mon, Oct 24, 2011 at 11:53 AM, fieldpeak <fieldpeak@gmail.com> wrote:
Hi Stephen,
Thanks for your kindly help, however, i changed it as your advise, the core still dumped.
below is the updated code,
static switch_status_t check_billing_before_routing(switch_core_session_t *session) { //charles, check billing before routing the call
char buf[128]; char cmd[100];
FILE *pp = NULL;
const char* in_username = NULL; const char* in_calledstation = NULL; const char* in_uniqueid = NULL; const char* in_network_addr = NULL; const char* in_type = "9"; int is_b;
//const char* full_cmd; int i_continue = 1; switch_channel_t *channel = NULL;
in_uniqueid = switch_core_session_get_uuid(session);
channel = switch_core_session_get_channel(session);
/*only billing on a leg*/ is_b = channel && switch_channel_get_originator_caller_profile(channel); printf("is_b is: %d\n", is_b); if(is_b) { return SWITCH_STATUS_SUCCESS; }
/* Lock this session's data for this module while we tinker with it */ if (globals.mutex) { switch_mutex_lock(globals.mutex); }
in_username = switch_channel_get_variable(channel, "caller_id_number"); in_calledstation = switch_channel_get_variable(channel, "destination_number"); in_network_addr = switch_channel_get_variable(channel, "network_addr");
/* Done checking - release lock */ if (globals.mutex) { switch_mutex_unlock(globals.mutex); }
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "check_billing_before_routing, in_username: %s, in_calledstation: %s, in_uniqueid: %s in_type: %s, in_network_addr: %s \n", in_username, in_calledstation, in_uniqueid, in_type, in_network_addr);
strcpy(cmd,""); strcat(cmd, "check_billing_before_answer");
strcat(cmd, " "); strcat(cmd, in_username); strcat(cmd, " "); strcat(cmd, in_calledstation); strcat(cmd, " "); strcat(cmd, in_uniqueid); strcat(cmd, " "); strcat(cmd, in_type); strcat(cmd, " "); strcat(cmd, in_network_addr);
printf("excute external cmd: "); printf(cmd); printf("\n");
if( (pp = popen(cmd, "r")) == NULL ) { printf("popen() error!\n"); exit(1); }
while(fgets(buf, sizeof buf, pp)) { printf("the result of excuting external cmd: %s", buf); }
if(pp) { pclose(pp); }
i_continue = atoi(buf);
printf("i_continue: %d", i_continue);
if (!i_continue) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, "call was not authorized to continue \n");
transfer_call(session, globals.nobal_action); }
return SWITCH_STATUS_SUCCESS;
}
2011/10/24 Stephen Wilde <wstephen80@gmail.com>
Can you try to change the allocation of cmd as:
char cmd[100];
....
strcat(cmd, "check_billing_before_answer ");
strcat(cmd, in_username);
strcat(cmd, " ");
....
On Mon, Oct 24, 2011 at 10:39 AM, fieldpeak <fieldpeak@gmail.com> wrote:
Hi Friends,
i'm using mod_nibblebill for billing on FS, i bundled event processing fucntions when status change, e.g. /* on_routing */ check_billing_before_routing, and * on_hangup */ process_hangup, as below, 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 "check_billing_before_routing" (because once i comment all of lines within this func, the core did not dump). below is the func "check_billing_before_routing", can anyone help advise what's wrong? how should i correct it, thanks.
static switch_status_t check_billing_before_routing(switch_core_session_t *session) { //charles, check billing before routing the call
char buf[128]; char cmd[100] = "check_billing_before_answer"; FILE *pp = NULL;
const char* in_username = NULL; const char* in_calledstation = NULL; const char* in_uniqueid = NULL; const char* in_network_addr = NULL; const char* in_type = "9"; int is_b;
//const char* full_cmd; int i_continue = 1; switch_channel_t *channel = NULL;
in_uniqueid = switch_core_session_get_uuid(session);
channel = switch_core_session_get_channel(session);
/*only billing on a leg*/ is_b = channel && switch_channel_get_originator_caller_profile(channel); printf("is_b is: %d\n", is_b); if(is_b) { return SWITCH_STATUS_SUCCESS; }
/* Lock this session's data for this module while we tinker with it */ if (globals.mutex) { switch_mutex_lock(globals.mutex); }
in_username = switch_channel_get_variable(channel, "caller_id_number"); in_calledstation = switch_channel_get_variable(channel, "destination_number"); in_network_addr = switch_channel_get_variable(channel, "network_addr");
/* Done checking - release lock */ if (globals.mutex) { switch_mutex_unlock(globals.mutex); }
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "check_billing_before_routing, in_username: %s, in_calledstation: %s, in_uniqueid: %s in_type: %s, in_network_addr: %s \n", in_username, in_calledstation, in_uniqueid, in_type, in_network_addr);
strcat(cmd, " "); strcat(cmd, in_username); strcat(cmd, " "); strcat(cmd, in_calledstation); strcat(cmd, " "); strcat(cmd, in_uniqueid); strcat(cmd, " "); strcat(cmd, in_type); strcat(cmd, " "); strcat(cmd, in_network_addr);
printf("excute external cmd: "); printf(cmd); printf("\n");
if( (pp = popen(cmd, "r")) == NULL ) { printf("popen() error!\n"); exit(1); }
while(fgets(buf, sizeof buf, pp)) { printf("the result of excuting external cmd: %s", buf); }
if(pp) { pclose(pp); }
i_continue = atoi(buf);
printf("i_continue: %d", i_continue);
if (!i_continue) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, "call was not authorized to continue \n");
transfer_call(session, globals.nobal_action); }
return SWITCH_STATUS_SUCCESS;
}
Core dump logs:
freeswitch@freeswitch> 2011-10-24 16:30:26.583369 [NOTICE] mod_xml_rpc.c:969 Starting HTTP Port 8787, DocRoot [/usr/local/freeswitch/htdocs] 2011-10-24 16:30:29.454743 [WARNING] sofia_reg.c:1337 SIP auth challenge (INVITE) on sofia profile 'internal' for [6628@224.193.106.204] from ip 223.128.70.10 2011-10-24 16:30:30.254710 [NOTICE] switch_channel.c:897 New Channel sofia/internal/8068@224.193.106.204[196a50b8-eaa0-4ef0-a674-18602117f5ec] is_b is: 0 excute external cmd: check_billing_before_answer 8068 6628 196a50b8-eaa0-4ef0-a674-18602117f5ec 9 223.128.70.10 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 the result of excuting external cmd: the result of excuting external cmd: 60 Segmentation fault (core dumped) [root@freeswitch bin]#
-- Regards, Charles
FreeSWITCH-users mailing list FreeSWITCH-users@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org
FreeSWITCH-users mailing list FreeSWITCH-users@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org
-- Regards, Charles
FreeSWITCH-users mailing list FreeSWITCH-users@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org
Hi Stephen, 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! gdb -c core.xxx freeswitch ddb>run ...(fs running up) gdb>bt full freeswitch@freeswitch> 2011-10-25 10:30:44.161051 [WARNING] sofia_reg.c:1337 SIP auth challenge (INVITE) on sofia profile 'internal' for [ 13910936628@124.193.106.104] from ip 222.128.70.10 2011-10-25 10:30:45.081037 [NOTICE] switch_channel.c:897 New Channel sofia/internal/13580358068@124.193.106.104[38946a57-c673-4705-8433-36f4b066d01c] [New Thread 0xb71d6b90 (LWP 19991)] is_b is: 0 excute external cmd: check_billing_before_answer 13580358068 13910936628 38946a57-c673-4705-8433-36f4b066d01c 9 222.128.70.10 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 Detaching after fork from child process 19992. the result of excuting external cmd: the result of excuting external cmd: 60 Program received signal SIGSEGV, Segmentation fault. [Switching to Thread 0xb71d6b90 (LWP 19991)] 0x008ff698 in switch_core_get_state_handler@plt () from /usr/local/freeswitch/lib/libfreeswitch.so.1 (gdb) bt full #0 0x008ff698 in switch_core_get_state_handler@plt () from /usr/local/freeswitch/lib/libfreeswitch.so.1 No symbol table info available. #1 0x0092d558 in switch_core_session_run (session=0x81bc238) at src/switch_core_state_machine.c:373 global_proceed = 1 proceed = <value optimized out> ptr = <value optimized out> rstatus = <value optimized out> state = <value optimized out> endstate = <value optimized out> endpoint_interface = <value optimized out> driver_state_handler = 0xcb8420 application_state_handler = <value optimized out> new_loops = 60000 __PRETTY_FUNCTION__ = "switch_core_session_run" __func__ = "switch_core_session_run" #2 0x009275ca in switch_core_session_thread (thread=0x823fdd8, obj=0x81bc238) at src/switch_core_session.c:1309 session = 0x81bc238 event = <value optimized out> event_str = 0x0 val = <value optimized out> __func__ = "switch_core_session_thread" __PRETTY_FUNCTION__ = "switch_core_session_thread" #3 0x009c2d16 in dummy_worker (opaque=0x823fdd8) at threadproc/unix/thread.c:138 ---Type <return> to continue, or q <return> to quit--- No locals. #4 0x002af832 in start_thread () from /lib/libpthread.so.0 No symbol table info available. #5 0x0078145e in clone () from /lib/libc.so.6 No symbol table info available. (gdb) 2011/10/24 Stephen Wilde <wstephen80@gmail.com>
You can issue a:
gdb -c core.xxx freeswitch
in freeswitch bin directory where core.xxx is the name of the generated core dump then, in gdb:
bt full
to show the stack backtrace
On Mon, Oct 24, 2011 at 11:53 AM, fieldpeak <fieldpeak@gmail.com> wrote:
Hi Stephen,
Thanks for your kindly help, however, i changed it as your advise, the core still dumped.
below is the updated code,
static switch_status_t check_billing_before_routing(switch_core_session_t *session) { //charles, check billing before routing the call
char buf[128]; char cmd[100];
FILE *pp = NULL;
const char* in_username = NULL; const char* in_calledstation = NULL; const char* in_uniqueid = NULL; const char* in_network_addr = NULL; const char* in_type = "9"; int is_b;
//const char* full_cmd; int i_continue = 1; switch_channel_t *channel = NULL;
in_uniqueid = switch_core_session_get_uuid(session);
channel = switch_core_session_get_channel(session);
/*only billing on a leg*/ is_b = channel && switch_channel_get_originator_caller_profile(channel); printf("is_b is: %d\n", is_b); if(is_b) { return SWITCH_STATUS_SUCCESS; }
/* Lock this session's data for this module while we tinker with it */ if (globals.mutex) { switch_mutex_lock(globals.mutex); }
in_username = switch_channel_get_variable(channel, "caller_id_number"); in_calledstation = switch_channel_get_variable(channel, "destination_number"); in_network_addr = switch_channel_get_variable(channel, "network_addr");
/* Done checking - release lock */ if (globals.mutex) { switch_mutex_unlock(globals.mutex); }
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "check_billing_before_routing, in_username: %s, in_calledstation: %s, in_uniqueid: %s in_type: %s, in_network_addr: %s \n", in_username, in_calledstation, in_uniqueid, in_type, in_network_addr);
strcpy(cmd,""); strcat(cmd, "check_billing_before_answer");
strcat(cmd, " "); strcat(cmd, in_username); strcat(cmd, " "); strcat(cmd, in_calledstation); strcat(cmd, " "); strcat(cmd, in_uniqueid); strcat(cmd, " "); strcat(cmd, in_type); strcat(cmd, " "); strcat(cmd, in_network_addr);
printf("excute external cmd: "); printf(cmd); printf("\n");
if( (pp = popen(cmd, "r")) == NULL ) { printf("popen() error!\n"); exit(1); }
while(fgets(buf, sizeof buf, pp)) { printf("the result of excuting external cmd: %s", buf); }
if(pp) { pclose(pp); }
i_continue = atoi(buf);
printf("i_continue: %d", i_continue);
if (!i_continue) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, "call was not authorized to continue \n");
transfer_call(session, globals.nobal_action); }
return SWITCH_STATUS_SUCCESS;
}
2011/10/24 Stephen Wilde <wstephen80@gmail.com>
Can you try to change the allocation of cmd as:
char cmd[100];
....
strcat(cmd, "check_billing_before_answer ");
strcat(cmd, in_username);
strcat(cmd, " ");
....
On Mon, Oct 24, 2011 at 10:39 AM, fieldpeak <fieldpeak@gmail.com> wrote:
Hi Friends,
i'm using mod_nibblebill for billing on FS, i bundled event processing fucntions when status change, e.g. /* on_routing */ check_billing_before_routing, and * on_hangup */ process_hangup, as below, 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 "check_billing_before_routing" (because once i comment all of lines within this func, the core did not dump). below is the func "check_billing_before_routing", can anyone help advise what's wrong? how should i correct it, thanks.
static switch_status_t check_billing_before_routing(switch_core_session_t *session) { //charles, check billing before routing the call
char buf[128]; char cmd[100] = "check_billing_before_answer"; FILE *pp = NULL;
const char* in_username = NULL; const char* in_calledstation = NULL; const char* in_uniqueid = NULL; const char* in_network_addr = NULL; const char* in_type = "9"; int is_b;
//const char* full_cmd; int i_continue = 1; switch_channel_t *channel = NULL;
in_uniqueid = switch_core_session_get_uuid(session);
channel = switch_core_session_get_channel(session);
/*only billing on a leg*/ is_b = channel && switch_channel_get_originator_caller_profile(channel); printf("is_b is: %d\n", is_b); if(is_b) { return SWITCH_STATUS_SUCCESS; }
/* Lock this session's data for this module while we tinker with it */ if (globals.mutex) { switch_mutex_lock(globals.mutex); }
in_username = switch_channel_get_variable(channel, "caller_id_number"); in_calledstation = switch_channel_get_variable(channel, "destination_number"); in_network_addr = switch_channel_get_variable(channel, "network_addr");
/* Done checking - release lock */ if (globals.mutex) { switch_mutex_unlock(globals.mutex); }
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "check_billing_before_routing, in_username: %s, in_calledstation: %s, in_uniqueid: %s in_type: %s, in_network_addr: %s \n", in_username, in_calledstation, in_uniqueid, in_type, in_network_addr);
strcat(cmd, " "); strcat(cmd, in_username); strcat(cmd, " "); strcat(cmd, in_calledstation); strcat(cmd, " "); strcat(cmd, in_uniqueid); strcat(cmd, " "); strcat(cmd, in_type); strcat(cmd, " "); strcat(cmd, in_network_addr);
printf("excute external cmd: "); printf(cmd); printf("\n");
if( (pp = popen(cmd, "r")) == NULL ) { printf("popen() error!\n"); exit(1); }
while(fgets(buf, sizeof buf, pp)) { printf("the result of excuting external cmd: %s", buf); }
if(pp) { pclose(pp); }
i_continue = atoi(buf);
printf("i_continue: %d", i_continue);
if (!i_continue) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, "call was not authorized to continue \n");
transfer_call(session, globals.nobal_action); }
return SWITCH_STATUS_SUCCESS;
}
Core dump logs:
freeswitch@freeswitch> 2011-10-24 16:30:26.583369 [NOTICE] mod_xml_rpc.c:969 Starting HTTP Port 8787, DocRoot [/usr/local/freeswitch/htdocs] 2011-10-24 16:30:29.454743 [WARNING] sofia_reg.c:1337 SIP auth challenge (INVITE) on sofia profile 'internal' for [6628@224.193.106.204] from ip 223.128.70.10 2011-10-24 16:30:30.254710 [NOTICE] switch_channel.c:897 New Channel sofia/internal/8068@224.193.106.204[196a50b8-eaa0-4ef0-a674-18602117f5ec] is_b is: 0 excute external cmd: check_billing_before_answer 8068 6628 196a50b8-eaa0-4ef0-a674-18602117f5ec 9 223.128.70.10 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 the result of excuting external cmd: the result of excuting external cmd: 60 Segmentation fault (core dumped) [root@freeswitch bin]#
-- Regards, Charles
FreeSWITCH-users mailing list FreeSWITCH-users@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE: http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org
FreeSWITCH-users mailing list FreeSWITCH-users@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org
-- Regards, Charles
FreeSWITCH-users mailing list FreeSWITCH-users@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org
FreeSWITCH-users mailing list FreeSWITCH-users@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org
-- Regards, Charles
Hi Stephen, i have resolved this issue, the root cause is that i define the cmd[100], while the actual string leghth exceed this lenght (178), then caused the core dump, now everything runs fine. Appreciate for your kinldy help which encourging me to make it done, Cheers!! my friend! BR, Charles 2011/10/25 fieldpeak <fieldpeak@gmail.com>
Hi Stephen,
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!
gdb -c core.xxx freeswitch ddb>run ...(fs running up) gdb>bt full
freeswitch@freeswitch> 2011-10-25 10:30:44.161051 [WARNING] sofia_reg.c:1337 SIP auth challenge (INVITE) on sofia profile 'internal' for [13910936628@124.193.106.104] from ip 222.128.70.10 2011-10-25 10:30:45.081037 [NOTICE] switch_channel.c:897 New Channel sofia/internal/13580358068@124.193.106.104[38946a57-c673-4705-8433-36f4b066d01c] [New Thread 0xb71d6b90 (LWP 19991)] is_b is: 0 excute external cmd: check_billing_before_answer 13580358068 13910936628 38946a57-c673-4705-8433-36f4b066d01c 9 222.128.70.10 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 Detaching after fork from child process 19992.
the result of excuting external cmd: the result of excuting external cmd: 60
Program received signal SIGSEGV, Segmentation fault. [Switching to Thread 0xb71d6b90 (LWP 19991)] 0x008ff698 in switch_core_get_state_handler@plt () from /usr/local/freeswitch/lib/libfreeswitch.so.1 (gdb) bt full #0 0x008ff698 in switch_core_get_state_handler@plt () from /usr/local/freeswitch/lib/libfreeswitch.so.1 No symbol table info available. #1 0x0092d558 in switch_core_session_run (session=0x81bc238) at src/switch_core_state_machine.c:373 global_proceed = 1 proceed = <value optimized out> ptr = <value optimized out> rstatus = <value optimized out> state = <value optimized out> endstate = <value optimized out> endpoint_interface = <value optimized out> driver_state_handler = 0xcb8420 application_state_handler = <value optimized out> new_loops = 60000 __PRETTY_FUNCTION__ = "switch_core_session_run" __func__ = "switch_core_session_run" #2 0x009275ca in switch_core_session_thread (thread=0x823fdd8, obj=0x81bc238) at src/switch_core_session.c:1309 session = 0x81bc238 event = <value optimized out> event_str = 0x0 val = <value optimized out> __func__ = "switch_core_session_thread" __PRETTY_FUNCTION__ = "switch_core_session_thread" #3 0x009c2d16 in dummy_worker (opaque=0x823fdd8) at threadproc/unix/thread.c:138 ---Type <return> to continue, or q <return> to quit--- No locals. #4 0x002af832 in start_thread () from /lib/libpthread.so.0 No symbol table info available. #5 0x0078145e in clone () from /lib/libc.so.6 No symbol table info available. (gdb)
2011/10/24 Stephen Wilde <wstephen80@gmail.com>
You can issue a:
gdb -c core.xxx freeswitch
in freeswitch bin directory where core.xxx is the name of the generated core dump then, in gdb:
bt full
to show the stack backtrace
On Mon, Oct 24, 2011 at 11:53 AM, fieldpeak <fieldpeak@gmail.com> wrote:
Hi Stephen,
Thanks for your kindly help, however, i changed it as your advise, the core still dumped.
below is the updated code,
static switch_status_t check_billing_before_routing(switch_core_session_t *session) { //charles, check billing before routing the call
char buf[128]; char cmd[100];
FILE *pp = NULL;
const char* in_username = NULL; const char* in_calledstation = NULL; const char* in_uniqueid = NULL; const char* in_network_addr = NULL; const char* in_type = "9"; int is_b;
//const char* full_cmd; int i_continue = 1; switch_channel_t *channel = NULL;
in_uniqueid = switch_core_session_get_uuid(session);
channel = switch_core_session_get_channel(session);
/*only billing on a leg*/ is_b = channel && switch_channel_get_originator_caller_profile(channel); printf("is_b is: %d\n", is_b); if(is_b) { return SWITCH_STATUS_SUCCESS; }
/* Lock this session's data for this module while we tinker with it */ if (globals.mutex) { switch_mutex_lock(globals.mutex); }
in_username = switch_channel_get_variable(channel, "caller_id_number"); in_calledstation = switch_channel_get_variable(channel, "destination_number"); in_network_addr = switch_channel_get_variable(channel, "network_addr");
/* Done checking - release lock */ if (globals.mutex) { switch_mutex_unlock(globals.mutex); }
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "check_billing_before_routing, in_username: %s, in_calledstation: %s, in_uniqueid: %s in_type: %s, in_network_addr: %s \n", in_username, in_calledstation, in_uniqueid, in_type, in_network_addr);
strcpy(cmd,""); strcat(cmd, "check_billing_before_answer");
strcat(cmd, " "); strcat(cmd, in_username); strcat(cmd, " "); strcat(cmd, in_calledstation); strcat(cmd, " "); strcat(cmd, in_uniqueid); strcat(cmd, " "); strcat(cmd, in_type); strcat(cmd, " "); strcat(cmd, in_network_addr);
printf("excute external cmd: "); printf(cmd); printf("\n");
if( (pp = popen(cmd, "r")) == NULL ) { printf("popen() error!\n"); exit(1); }
while(fgets(buf, sizeof buf, pp)) { printf("the result of excuting external cmd: %s", buf); }
if(pp) { pclose(pp); }
i_continue = atoi(buf);
printf("i_continue: %d", i_continue);
if (!i_continue) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, "call was not authorized to continue \n");
transfer_call(session, globals.nobal_action); }
return SWITCH_STATUS_SUCCESS;
}
2011/10/24 Stephen Wilde <wstephen80@gmail.com>
Can you try to change the allocation of cmd as:
char cmd[100];
....
strcat(cmd, "check_billing_before_answer ");
strcat(cmd, in_username);
strcat(cmd, " ");
....
On Mon, Oct 24, 2011 at 10:39 AM, fieldpeak <fieldpeak@gmail.com>wrote:
Hi Friends,
i'm using mod_nibblebill for billing on FS, i bundled event processing fucntions when status change, e.g. /* on_routing */ check_billing_before_routing, and * on_hangup */ process_hangup, as below, 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 "check_billing_before_routing" (because once i comment all of lines within this func, the core did not dump). below is the func "check_billing_before_routing", can anyone help advise what's wrong? how should i correct it, thanks.
static switch_status_t check_billing_before_routing(switch_core_session_t *session) { //charles, check billing before routing the call
char buf[128]; char cmd[100] = "check_billing_before_answer"; FILE *pp = NULL;
const char* in_username = NULL; const char* in_calledstation = NULL; const char* in_uniqueid = NULL; const char* in_network_addr = NULL; const char* in_type = "9"; int is_b;
//const char* full_cmd; int i_continue = 1; switch_channel_t *channel = NULL;
in_uniqueid = switch_core_session_get_uuid(session);
channel = switch_core_session_get_channel(session);
/*only billing on a leg*/ is_b = channel && switch_channel_get_originator_caller_profile(channel); printf("is_b is: %d\n", is_b); if(is_b) { return SWITCH_STATUS_SUCCESS; }
/* Lock this session's data for this module while we tinker with it */ if (globals.mutex) { switch_mutex_lock(globals.mutex); }
in_username = switch_channel_get_variable(channel, "caller_id_number"); in_calledstation = switch_channel_get_variable(channel, "destination_number"); in_network_addr = switch_channel_get_variable(channel, "network_addr");
/* Done checking - release lock */ if (globals.mutex) { switch_mutex_unlock(globals.mutex); }
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "check_billing_before_routing, in_username: %s, in_calledstation: %s, in_uniqueid: %s in_type: %s, in_network_addr: %s \n", in_username, in_calledstation, in_uniqueid, in_type, in_network_addr);
strcat(cmd, " "); strcat(cmd, in_username); strcat(cmd, " "); strcat(cmd, in_calledstation); strcat(cmd, " "); strcat(cmd, in_uniqueid); strcat(cmd, " "); strcat(cmd, in_type); strcat(cmd, " "); strcat(cmd, in_network_addr);
printf("excute external cmd: "); printf(cmd); printf("\n");
if( (pp = popen(cmd, "r")) == NULL ) { printf("popen() error!\n"); exit(1); }
while(fgets(buf, sizeof buf, pp)) { printf("the result of excuting external cmd: %s", buf); }
if(pp) { pclose(pp); }
i_continue = atoi(buf);
printf("i_continue: %d", i_continue);
if (!i_continue) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, "call was not authorized to continue \n");
transfer_call(session, globals.nobal_action); }
return SWITCH_STATUS_SUCCESS;
}
Core dump logs:
freeswitch@freeswitch> 2011-10-24 16:30:26.583369 [NOTICE] mod_xml_rpc.c:969 Starting HTTP Port 8787, DocRoot [/usr/local/freeswitch/htdocs] 2011-10-24 16:30:29.454743 [WARNING] sofia_reg.c:1337 SIP auth challenge (INVITE) on sofia profile 'internal' for [ 6628@224.193.106.204] from ip 223.128.70.10 2011-10-24 16:30:30.254710 [NOTICE] switch_channel.c:897 New Channel sofia/internal/8068@224.193.106.204[196a50b8-eaa0-4ef0-a674-18602117f5ec] is_b is: 0 excute external cmd: check_billing_before_answer 8068 6628 196a50b8-eaa0-4ef0-a674-18602117f5ec 9 223.128.70.10 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 the result of excuting external cmd: the result of excuting external cmd: 60 Segmentation fault (core dumped) [root@freeswitch bin]#
-- Regards, Charles
FreeSWITCH-users mailing list FreeSWITCH-users@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE: http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org
FreeSWITCH-users mailing list FreeSWITCH-users@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE: http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org
-- Regards, Charles
FreeSWITCH-users mailing list FreeSWITCH-users@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org
FreeSWITCH-users mailing list FreeSWITCH-users@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org
-- Regards, Charles
-- Regards, Charles
participants (2)
-
fieldpeak
-
Stephen Wilde