=====================================================================
Asterisk-11.5.1 Centos6 app_confbrige.c
[b]APP: MyConfbridgeCount(Confbridgename,variablename)
it will return no of user in conference if conference is created or else zero.
Task: Using Dailplan user want to retrive no of user in conference
’6050’ => 1. Verbose(3,“testMyConfbridgeCount”) [pbx_config]
2. MyConfbridgeCount(4000,count) [pbx_config]
3. verbose(3,"== ${count} ====") [pbx_config]
issue:Currently asterisk core dumped as soon as app2 load . [/b]
I want to load module as after join confbridge by any user , using MyConfbridgeCount() to know no of conference user count .
file: app/app_confbrige.c
partial code of app_confbridge.c:
static const char *const app2 =“MyConfbridgeCount”;
static int count_exec(struct ast_channel *chan, const char *data)
{
int res = 0;
struct conference_bridge *conf=NULL;
int count;
char *localdata;
char val[80] = “0”;
struct ao2_iterator i;
//struct conference_bridge *bridge = NULL;
struct conference_bridge tmp;
AST_DECLARE_APP_ARGS(args,
AST_APP_ARG(confno);
AST_APP_ARG(varname);
);
ast_verb(3,"\n============Inside count_exec =============\n");
if ( ast_strlen_zero(data)) {
ast_log(LOG_WARNING, "MyConfbrigeCount requires an argument (conference number)\n");
ast_verb(3, "\n MyConfbrigeCount requires an argument (conference number\n ");
return -1;
}
if (!ao2_container_count(conference_bridges)) {
ast_verb(3, "No active conferences.");
ast_log(LOG_NOTICE, "No active conferences.");
return -1;
}
if (!(localdata = ast_strdupa(data))){
return -1;
}
AST_STANDARD_APP_ARGS(args, localdata);
ast_copy_string(tmp.name, args.confno, sizeof(tmp.name));
conf = ao2_find(conference_bridges, &tmp, OBJ_POINTER);
if (conf) {
ao2_lock(conf);
count = conf->markedusers;
ao2_unlock(conf);
}else{
count = 0;
}
if (!ast_strlen_zero(args.varname)) {
snprintf(val, sizeof(val), "%d", count);
pbx_builtin_setvar_helper(chan, args.varname, val);
} else {
if ( ast_channel_state(chan)!= AST_STATE_UP) {
ast_answer(chan);
}
res = ast_say_number(chan, count, "",ast_channel_language(chan),(char *) NULL);
}
return res;
}
static int load_module(void)
{
ast_verb(3 ,"==Inside load_module==");
res |= ast_register_application_xml(app2,count_exec);
return res;
}
static int unload_module(void)
{
res |= ast_unregister_application(app2);
return res;
}
static struct ast_cli_entry cli_confbridge[] = {
AST_CLI_DEFINE(admincount_exec, “MyConfbrigdeCount Show Number of adminUser(s) in Conference.” ),
}
=============core dumap=================================================
Program terminated with signal 11, Segmentation fault.
#0 __strlen_ia32 () at …/sysdeps/i386/i586/strlen.S:56
56 cmpb %dh, (%eax) /* is byte NUL? /
Missing separate debuginfos, use: debuginfo-install bzip2-libs-1.0.5-7.el6_0.i686 cyrus-sasl-lib-2.1.23-8.el6.i686 db4-4.7.25-16.el6.i686 elfutils-libelf-0.152-1.el6.i686 expat-2.0.1-11.el6_2.i686 gnutls-2.8.5-4.el6_2.2.i686 keyutils-libs-1.4-4.el6.i686 krb5-libs-1.10.3-10.el6_4.3.i686 libacl-2.2.49-4.el6.i686 libattr-2.4.44-4.el6.i686 libcap-2.16-5.2.el6.i686 libcom_err-1.41.12-14.el6.i686 libcurl-7.19.7-26.el6_2.4.i686 libgcc-4.4.7-3.el6.i686 libgcrypt-1.4.5-9.el6_2.2.i686 libgpg-error-1.7-4.el6.i686 libical-0.43-6.el6.i686 libidn-1.18-2.el6.i686 libproxy-0.3.0-2.el6.i686 libselinux-2.0.94-5.3.el6_4.1.i686 libsrtp-1.4.4-4.20101004cvs.el6.i686 libssh2-1.2.2-7.el6.i686 libtasn1-2.3-3.el6.i686 libtool-ltdl-2.2.6-15.5.el6.i686 libuuid-2.17.2-12.9.el6_4.3.i686 libxml2-2.7.6-12.el6_4.1.i686 lm_sensors-libs-3.1.1-17.el6.i686 lua-5.1.4-4.1.el6.i686 Mysql-connector-odbc-5.1.5r1144-7.el6.i686 Mysql-libs-5.1.69-1.el6_4.i686 ncurses-libs-5.7-3.20090208.el6.i686 neon-0.29.3-3.el6_4.i686 net-snmp-libs-5.5-44.el6_4.1.i686 nspr-4.8.6-1.el6.i686 nss-3.12.7-2.el6.i686 nss-softokn-freebl-3.12.7-1.1.el6.i686 nss-util-3.12.7-1.el6.i686 openldap-2.4.19-15.el6.i686 openssl-1.0.0-27.el6_4.2.i686 pakchois-0.4-3.2.el6.i686 perl-libs-5.10.1-136.el6.i686 popt-1.13-7.el6.i686 rpm-libs-4.8.0-32.el6.i686 sqlite-3.6.20-1.el6.i686 tcp_wrappers-libs-7.6-57.el6.i686 unixODBC-2.2.14-12.el6_3.i686 xz-libs-4.999.9-0.3.beta.20091007git.el6.i686 zlib-1.2.3-29.el6.i686
(gdb) bt
#0 __strlen_ia32 () at …/sysdeps/i386/i586/strlen.S:56
#1 0x00c1b4df in _IO_vfprintf_internal (s=0xfffffffe, format=, ap=) at vfprintf.c:1641
#2 0x00c409f0 in _IO_vsnprintf (string=0x835af1c “\374 – \n======== inside count_exec == data is at address:[0xbf918b64] data:[nnel)\n”, maxlen=,
format=0xbf9175c0 "\374 – \n======== inside count_exec == data is at address:[%p] data:[%s] ", ‘=’ <repeats 11 times>, “\n”,
args=0xbf917724 “d\213\221\277\376\377\377\377\213\261\065\b”) at vsnprintf.c:120
#3 0x081a0f94 in __ast_str_helper (buf=0xbf9176a8, max_len=0, append=0,
fmt=0xbf9175c0 "\374 – \n======== inside count_exec == data is at address:[%p] data:[%s] ", ‘=’ <repeats 11 times>, “\n”,
ap=0xbf917724 “d\213\221\277\376\377\377\377\213\261\065\b”) at strings.c:76
#4 0x081b17d0 in ast_str_set_va (buf=0xbf9176a8, max_len=0,
fmt=0xbf9175c0 "\374 – \n======== inside count_exec == data is at address:[%p] data:[%s] ", ‘=’ <repeats 11 times>, “\n”,
ap=0xbf917724 “d\213\221\277\376\377\377\377\213\261\065\b”) at /usr/src/My-asterisk/asterisk-11.5.1/include/asterisk/strings.h:803
#5 0x08134a6f in __ast_verbose_ap (file=0xe1ca74 “app_confbridge.c”, line=2453, func=0xe20652 “count_exec”, level=3, callid=0x0,
fmt=0xbf9175c0 "\374 – \n======== inside count_exec == data is at address:[%p] data:[%s] ", ‘=’ <repeats 11 times>, “\n”,
ap=0xbf917724 “d\213\221\277\376\377\377\377\213\261\065\b”) at logger.c:1818
#6 0x08134b0b in __ast_verbose (file=0xe1ca74 “app_confbridge.c”, line=2453, func=0xe20652 “count_exec”, level=3,
fmt=0xe1da30 "\n======== inside count_exec == data is at address:[%p] data:[%s] ", ‘=’ <repeats 11 times>, “\n”) at logger.c:1836
#7 0x00e09a45 in count_exec (chan=0xe23c18, data=0xfffffffe <Address 0xfffffffe out of bounds>) at app_confbridge.c:2453
#8 0x080d40eb in __ast_cli_register (e=0xe23c18, ed=0x0) at cli.c:2118
#9 0x080d4459 in ast_cli_register (e=0xe23c18) at cli.c:2178
#10 0x080d4482 in ast_cli_register_multiple (e=0xe237a0, len=13) at cli.c:2189
#11 0x00e11f7d in load_module () at app_confbridge.c:4771
#12 0x0812ba89 in start_resource (mod=0x87fa908) at loader.c:845
#13 0x0812c45c in load_resource_list (load_order=0xbf918e90, global_symbols=0, mod_count=0xbf918e88) at loader.c:1045
#14 0x0812ca5a in load_modules (preload_only=0) at loader.c:1198
#15 0x080895f7 in main (argc=4, argv=0xbf91a3a4) at asterisk.c:4180
(gdb)
#0 __strlen_ia32 () at …/sysdeps/i386/i586/strlen.S:56
#1 0x00c1b4df in _IO_vfprintf_internal (s=0xfffffffe, format=, ap=) at vfprintf.c:1641
#2 0x00c409f0 in _IO_vsnprintf (string=0x835af1c “\374 – \n======== inside count_exec == data is at address:[0xbf918b64] data:[nnel)\n”, maxlen=,
format=0xbf9175c0 "\374 – \n======== inside count_exec == data is at address:[%p] data:[%s] ", ‘=’ <repeats 11 times>, “\n”,
args=0xbf917724 “d\213\221\277\376\377\377\377\213\261\065\b”) at vsnprintf.c:120
#3 0x081a0f94 in __ast_str_helper (buf=0xbf9176a8, max_len=0, append=0,
fmt=0xbf9175c0 "\374 – \n======== inside count_exec == data is at address:[%p] data:[%s] ", ‘=’ <repeats 11 times>, “\n”,
ap=0xbf917724 “d\213\221\277\376\377\377\377\213\261\065\b”) at strings.c:76
#4 0x081b17d0 in ast_str_set_va (buf=0xbf9176a8, max_len=0,
fmt=0xbf9175c0 "\374 – \n======== inside count_exec == data is at address:[%p] data:[%s] ", ‘=’ <repeats 11 times>, “\n”,
ap=0xbf917724 “d\213\221\277\376\377\377\377\213\261\065\b”) at /usr/src/My-asterisk/asterisk-11.5.1/include/asterisk/strings.h:803
#5 0x08134a6f in __ast_verbose_ap (file=0xe1ca74 “app_confbridge.c”, line=2453, func=0xe20652 “count_exec”, level=3, callid=0x0,
fmt=0xbf9175c0 "\374 – \n======== inside count_exec == data is at address:[%p] data:[%s] ", ‘=’ <repeats 11 times>, “\n”,
ap=0xbf917724 “d\213\221\277\376\377\377\377\213\261\065\b”) at logger.c:1818
#6 0x08134b0b in __ast_verbose (file=0xe1ca74 “app_confbridge.c”, line=2453, func=0xe20652 “count_exec”, level=3,
fmt=0xe1da30 “\n======== inside count_exec == data is at address:[%p] data:[%s] “, ‘=’ <repeats 11 times>, “\n”) at logger.c:1836
#7 0x00e09a45 in count_exec (chan=0xe23c18, data=0xfffffffe <Address 0xfffffffe out of bounds>) at app_confbridge.c:2453
#8 0x080d40eb in __ast_cli_register (e=0xe23c18, ed=0x0) at cli.c:2118
#9 0x080d4459 in ast_cli_register (e=0xe23c18) at cli.c:2178
#10 0x080d4482 in ast_cli_register_multiple (e=0xe237a0, len=13) at cli.c:2189
#11 0x00e11f7d in load_module () at app_confbridge.c:4771
#12 0x0812ba89 in start_resource (mod=0x87fa908) at loader.c:845
#13 0x0812c45c in load_resource_list (load_order=0xbf918e90, global_symbols=0, mod_count=0xbf918e88) at loader.c:1045
#14 0x0812ca5a in load_modules (preload_only=0) at loader.c:1198
#15 0x080895f7 in main (argc=4, argv=0xbf91a3a4) at asterisk.c:4180
(gdb) frame 6
#6 0x08134b0b in __ast_verbose (file=0xe1ca74 “app_confbridge.c”, line=2453, func=0xe20652 “count_exec”, level=3,
fmt=0xe1da30 “\n======== inside count_exec == data is at address:[%p] data:[%s] “, ‘=’ <repeats 11 times>, “\n”) at logger.c:1836
1836 __ast_verbose_ap(file, line, func, level, callid, fmt, ap);
(gdb) frame 7
#7 0x00e09a45 in count_exec (chan=0xe23c18, data=0xfffffffe <Address 0xfffffffe out of bounds>) at app_confbridge.c:2453
warning: Source file is more recent than executable.
2453 ast_verb(3,”\n======== inside count_exec === data is at address:[%p] data:[%s] ===========\n”,&data,data);
(gdb)
#7 0x00e09a45 in count_exec (chan=0xe23c18, data=0xfffffffe <Address 0xfffffffe out of bounds>) at app_confbridge.c:2453
2453 ast_verb(3,”\n======== inside count_exec === data is at address:[%p] data:[%s] ===========\n”,&data,data);
(gdb) frame 8
#8 0x080d40eb in __ast_cli_register (e=0xe23c18, ed=0x0) at cli.c:2118
2118 e->handler(e, CLI_INIT, &a);
(gdb) frame 9
#9 0x080d4459 in ast_cli_register (e=0xe23c18) at cli.c:2178
2178 return __ast_cli_register(e, NULL);
(gdb) frame 10
#10 0x080d4482 in ast_cli_register_multiple (e=0xe237a0, len=13) at cli.c:2189
2189 res |= ast_cli_register(e + i);
(gdb) frame 11
#11 0x00e11f7d in load_module () at app_confbridge.c:4771
4771 res |= ast_cli_register_multiple(cli_confbridge, sizeof(cli_confbridge) / sizeof(struct ast_cli_entry));
(gdb) frame 12
#12 0x0812ba89 in start_resource (mod=0x87fa908) at loader.c:845
845 res = mod->info->load();
(gdb) frame 13
#13 0x0812c45c in load_resource_list (load_order=0xbf918e90, global_symbols=0, mod_count=0xbf918e88) at loader.c:1045
1045 switch (start_resource(mod)) {
(gdb) frame 14
#14 0x0812ca5a in load_modules (preload_only=0) at loader.c:1198
1198 if ((res = load_resource_list(&load_order, 0, &modulecount)) < 0) {
(gdb) frame 15
#15 0x080895f7 in main (argc=4, argv=0xbf91a3a4) at asterisk.c:4180
4180 if ((moduleresult = load_modules(0))) { / Load modules */
(gdb) frame 5
#5 0x08134a6f in __ast_verbose_ap (file=0xe1ca74 “app_confbridge.c”, line=2453, func=0xe20652 “count_exec”, level=3, callid=0x0,
fmt=0xbf9175c0 "\374 – \n======== inside count_exec == data is at address:[%p] data:[%s] ", ‘=’ <repeats 11 times>, “\n”,
ap=0xbf917724 “d\213\221\277\376\377\377\377\213\261\065\b”) at logger.c:1818
1818 res = ast_str_set_va(&buf, 0, fmt, ap);
(gdb) frame 4
#4 0x081b17d0 in ast_str_set_va (buf=0xbf9176a8, max_len=0,
fmt=0xbf9175c0 "\374 – \n======== inside count_exec == data is at address:[%p] data:[%s] ", ‘=’ <repeats 11 times>, “\n”,
ap=0xbf917724 “d\213\221\277\376\377\377\377\213\261\065\b”) at /usr/src/My-asterisk/asterisk-11.5.1/include/asterisk/strings.h:803
803 AST_INLINE_API(int attribute((format(printf, 3, 0))) ast_str_set_va(struct ast_str **buf, ssize_t max_len, const char *fmt, va_list ap),
(gdb) frame 3
#3 0x081a0f94 in __ast_str_helper (buf=0xbf9176a8, max_len=0, append=0,
fmt=0xbf9175c0 "\374 – \n======== inside count_exec == data is at address:[%p] data:[%s] ", ‘=’ <repeats 11 times>, “\n”,
ap=0xbf917724 “d\213\221\277\376\377\377\377\213\261\065\b”) at strings.c:76
76 res = vsnprintf((*buf)->__AST_STR_STR + offset, (*buf)->__AST_STR_LEN - offset, fmt, aq);
(gdb) frame 2
#2 0x00c409f0 in _IO_vsnprintf (string=0x835af1c “\374 – \n======== inside count_exec == data is at address:[0xbf918b64] data:[nnel)\n”, maxlen=,
format=0xbf9175c0 "\374 – \n======== inside count_exec == data is at address:[%p] data:[%s] ", ‘=’ <repeats 11 times>, “\n”,
args=0xbf917724 “d\213\221\277\376\377\377\377\213\261\065\b”) at vsnprintf.c:120
120 ret = INTUSE(_IO_vfprintf) (&sf.f._sbf._f, format, args);
(gdb) frame 1
#1 0x00c1b4df in _IO_vfprintf_internal (s=0xfffffffe, format=, ap=) at vfprintf.c:1641
1641 process_string_arg (((struct printf_spec ) NULL));
(gdb) frame 0
#0 __strlen_ia32 () at …/sysdeps/i386/i586/strlen.S:56
56 cmpb %dh, (%eax) / is byte NUL? */
(gdb)