[SR-Users] Script @Startup

Nicolas Breuer Nicolas.Breuer at belcenter.biz
Fri Oct 19 11:18:25 CEST 2018


(gdb) frame 11
#11 0x000000000044228a in run_child_one_init_route () at core/action.c:1684
1684                            run_top_route(event_rt.rlist[rt], fmsg, &ctx);
(gdb) info locals
fmsg = 0xa6aa00
ctx = {rec_lev = 1, run_flags = 0, last_retcode = 1, jmp_env = {{__jmpbuf = {140678378993552, -1520124323598420234, 4294928, 140721990527328, 0, 0, -1520124323569060106, 1522118751708919542}, __mask_was_saved = 0, __saved_mask = {__val = {
          5370834, 0, 222124372227, 206158430256, 140721990526112, 140721990525920, 2048, 140721990526016, 6867428, 7822112, 0, 140678378993552, 140678383605488, 19200, 5314551824, 140721990526224}}}}}
bctx = 0x100000000
rtb = 1
rt = 1
keng = 0x0
evname = {s = 0x76eaa0 "core:worker-one-init", len = 20}
__FUNCTION__ = "run_child_one_init_route"
(gdb) list
1679                    fmsg = faked_msg_next();
1680                    rtb = get_route_type();
1681                    set_route_type(REQUEST_ROUTE);
1682                    init_run_actions_ctx(&ctx);
1683                    if(keng==NULL) {
1684                            run_top_route(event_rt.rlist[rt], fmsg, &ctx);
1685                    } else {
1686                            bctx = sr_kemi_act_ctx_get();
1687                            sr_kemi_act_ctx_set(&ctx);
1688                            if(keng->froute(fmsg, EVENT_ROUTE,
(gdb) frame 1
#1  0x0000000000732f9c in select_cfg_var (res=0x7ffc6441d620, s=0x7ff23cf77c68, msg=0xa6aa00) at core/cfg/cfg_select.c:223
223                             memcpy(res, p, sizeof(str));
(gdb) info locals
group = 0x7ff23cd16020
var = 0x7ff23cd16de8
p = 0x0
i = 0
buf = '\000' <repeats 21 times>
__FUNCTION__ = "select_cfg_var"
(gdb) list
218                             res->s = *(char **)p;
219                             res->len = (res->s) ? strlen(res->s) : 0;
220                             break;
221
222                     case CFG_VAR_STR:
223                             memcpy(res, p, sizeof(str));
224                             break;
225
226                     default:
227                             LM_DBG("unsupported variable type: %d\n",
(gdb) p *res
$1 = {s = 0x0, len = 0}
(gdb) p *s
$2 = {f = {0x731eae <select_cfg_var>, 0, 0, 0}, param_offset = {0, 3, 0, 0, 0}, params = {{type = SEL_PARAM_STR, v = {i = 1022852069, s = {s = 0x7ff23cf77be5 "cfg_get.kamalio.myip)", len = 7}, p = 0x7ff23cf77be5}}, {type = SEL_PARAM_PTR, v = {
        i = 1020354592, s = {s = 0x7ff23cd16020 "\001", len = 7}, p = 0x7ff23cd16020}}, {type = SEL_PARAM_PTR, v = {i = 1020358120, s = {s = 0x7ff23cd16de8 "0v\n=\362\177", len = 4}, p = 0x7ff23cd16de8}}, {type = SEL_PARAM_INT, v = {i = 0,
        s = {s = 0x0, len = 0}, p = 0x0}} <repeats 29 times>}, n = 3}
(gdb)




AVP Query :

In avp query, i get and '$sel(cfg_get.kamalio.myip)'
A variable set in my config file.


De : Daniel-Constantin Mierla <miconda at gmail.com>
Envoyé : vendredi 19 octobre 2018 11:12
À : Nicolas Breuer <Nicolas.Breuer at belcenter.biz>; Kamailio (SER) - Users Mailing List <sr-users at lists.kamailio.org>
Objet : Re: [SR-Users] Script @Startup


Can you get from gdb the output from the next command:

frame 11

info locals

list

frame 1

info locals

list

p *res

p* s



Then, the issue is accessing select variables from config parameters, like $sel(...). Apparently they are not initialized completely at that time. I tried a quick fix with the previous patch. Can you do the event route without using $sel(...)?  What is exactly the avp db query you have in the event route?

Cheers,
Daniel

On 19.10.18 10:00, Nicolas Breuer wrote:
Loaded symbols for /usr/lib64/kamailio/modules/nathelper.so
Reading symbols from /usr/lib64/kamailio/modules/debugger.so...done.
Loaded symbols for /usr/lib64/kamailio/modules/debugger.so
Reading symbols from /lib64/libnss_dns.so.2...(no debugging symbols found)...done.
Loaded symbols for /lib64/libnss_dns.so.2
Core was generated by `/usr/sbin/kamailio -f /etc/kamailio/kamailio.cfg -P /var/run/kamailio/kamailio.'.
Program terminated with signal 11, Segmentation fault.
#0  0x00000033b7a89780 in memcpy () from /lib64/libc.so.6
Missing separate debuginfos, use: debuginfo-install glibc-2.12-1.212.el6.x86_64 keyutils-libs-1.4-5.el6.x86_64 krb5-libs-1.10.3-65.el6.x86_64 libcom_err-1.41.12-24.el6.x86_64 libselinux-2.0.94-7.el6.x86_64 mysql-libs-5.1.73-8.el6_8.x86_64 nss-softokn-freebl-3.14.3-23.3.el6_8.x86_64 openssl-1.0.1e-57.el6.x86_64 zlib-1.2.3-29.el6.x86_64
(gdb) bt
#0  0x00000033b7a89780 in memcpy () from /lib64/libc.so.6
#1  0x0000000000732f9c in select_cfg_var (res=0x7ffc6441d620, s=0x7ff23cf77c68, msg=0xa6aa00) at core/cfg/cfg_select.c:223
#2  0x00000000005abd33 in run_select (res=0x7ffc6441d620, s=0x7ff23cf77c68, msg=0xa6aa00) at core/select.c:425
#3  0x00007ff23aef0ff5 in pv_get_select (msg=0xa6aa00, param=0x7ff23cf77b98, res=0x7ffc6441d740) at pv_select.c:61
#4  0x000000000052e6cf in pv_get_spec_value (msg=0xa6aa00, sp=0x7ff23cf77b80, value=0x7ffc6441d740) at core/pvapi.c:1380
#5  0x000000000052eb87 in pv_printf (msg=0xa6aa00, list=0x7ff23d0a9108, buf=0x7ff23c5d6720 "select Status FROM x_providers_SIP where Provider like 'PROXY%' and (Proxy_ID='", len=0x7ffc6441d80c) at core/pvapi.c:1439
#6  0x00007ff23c3adc55 in ops_dbquery_avps (msg=0xa6aa00, query=0x7ff23d0a9108, dest=0x7ff23d0a9218) at avpops_impl.c:744
#7  0x00007ff23c39f9ff in w_dbquery2_avps (msg=0xa6aa00, query=0x7ff23d0a9108 "\340\250\323<\362\177", dest=0x7ff23d0a9218 "\004") at avpops.c:1020
#8  0x0000000000434a11 in do_action (h=0x7ffc6441e350, a=0x7ff23cd3a420, msg=0xa6aa00) at core/action.c:1079
#9  0x00000000004414f8 in run_actions (h=0x7ffc6441e350, a=0x7ff23cd38bf0, msg=0xa6aa00) at core/action.c:1564
#10 0x0000000000441bf4 in run_top_route (a=0x7ff23cd38bf0, msg=0xa6aa00, c=0x7ffc6441e350) at core/action.c:1646
#11 0x000000000044228a in run_child_one_init_route () at core/action.c:1684
#12 0x00000000004249f8 in main_loop () at main.c:1618
#13 0x000000000042bec1 in main (argc=13, argv=0x7ffc6441e968) at main.c:2645

De : Daniel-Constantin Mierla <miconda at gmail.com><mailto:miconda at gmail.com>
Envoyé : vendredi 19 octobre 2018 09:52
À : Nicolas Breuer <Nicolas.Breuer at belcenter.biz><mailto:Nicolas.Breuer at belcenter.biz>; Kamailio (SER) - Users Mailing List <sr-users at lists.kamailio.org><mailto:sr-users at lists.kamailio.org>
Objet : Re: [SR-Users] Script @Startup


Take again the backtrace with gdb.

Daniel

On 19.10.18 09:43, Nicolas Breuer wrote:
Hello,

I tried and same error:

Oct 19 09:42:20 proxy1 /usr/sbin/kamailio[2005]: NOTICE: <script>: ------------------Starting UP Kamailio Server------------------
Oct 19 09:42:20 proxy1 /usr/sbin/kamailio[2005]: NOTICE: <script>: ***************************************************************
Oct 19 09:42:20 proxy1 /usr/sbin/kamailio[2005]: NOTICE: <script>: >> Checking the state of the instance...
Oct 19 09:42:20 proxy1 kernel: kamailio[2005]: segfault at 0 ip 00000033b7a89780 sp 00007ffc6441d3e8 error 4 in libc-2.12.so[33b7a00000+18b000]
Oct 19 09:42:20 proxy1 /usr/sbin/kamailio[2004]: ALERT: <core> [main.c:741]: handle_sigs(): child process 2005 exited by a signal 11
Oct 19 09:42:20 proxy1 /usr/sbin/kamailio[2004]: ALERT: <core> [main.c:744]: handle_sigs(): core was generated

[root at proxy1 src]# kamailio -v
version: kamailio 5.2.0-pre0 (x86_64/linux)
flags: STATS: Off, USE_TCP, USE_TLS, USE_SCTP, TLS_HOOKS, USE_RAW_SOCKS, DISABLE_NAGLE, USE_MCAST, DNS_IP_HACK, SHM_MEM, SHM_MMAP, PKG_MALLOC, Q_MALLOC, F_MALLOC, TLSF_MALLOC, DBG_SR_MEMORY, USE_FUTEX, FAST_LOCK-ADAPTIVE_WAIT, USE_DNS_CACHE, USE_DNS_FAILOVER, USE_NAPTR, USE_DST_BLACKLIST, HAVE_RESOLV_RES
ADAPTIVE_WAIT_LOOPS=1024, MAX_RECV_BUFFER_SIZE 262144 MAX_URI_SIZE 1024, BUF_SIZE 65535, DEFAULT PKG_SIZE 8MB
poll method support: poll, epoll_lt, epoll_et, sigio_rt, select.
id: unknown
compiled on 09:39:18 Oct 19 2018 with gcc 4.4.7



De : Daniel-Constantin Mierla <miconda at gmail.com><mailto:miconda at gmail.com>
Envoyé : jeudi 18 octobre 2018 09:01
À : Nicolas Breuer <Nicolas.Breuer at belcenter.biz><mailto:Nicolas.Breuer at belcenter.biz>; Kamailio (SER) - Users Mailing List <sr-users at lists.kamailio.org><mailto:sr-users at lists.kamailio.org>
Objet : Re: [SR-Users] Script @Startup


Can you try with master branch or the patch from the commit linked next?

  - https://github.com/kamailio/kamailio/commit/a4b6a5cb1dda7576b265a23c91321b7f2a034658

If all ok, I will backport to 5.1 branch.

Cheers,
Daniel

On 17.10.18 19:45, Nicolas Breuer wrote:
version: kamailio 5.1.5 (x86_64/linux) d06080
flags: STATS: Off, USE_TCP, USE_TLS, USE_SCTP, TLS_HOOKS, USE_RAW_SOCKS, DISABLE_NAGLE, USE_MCAST, DNS_IP_HACK, SHM_MEM, SHM_MMAP, PKG_MALLOC, Q_MALLOC, F_MALLOC, TLSF_MALLOC, DBG_SR_MEMORY, USE_FUTEX, FAST_LOCK-ADAPTIVE_WAIT, USE_DNS_CACHE, USE_DNS_FAILOVER, USE_NAPTR, USE_DST_BLACKLIST, HAVE_RESOLV_RES
ADAPTIVE_WAIT_LOOPS=1024, MAX_RECV_BUFFER_SIZE 262144 MAX_URI_SIZE 1024, BUF_SIZE 65535, DEFAULT PKG_SIZE 8MB
poll method support: poll, epoll_lt, epoll_et, sigio_rt, select.
id: d06080
compiled on 10:02:52 Aug 22 2018 with gcc 4.4.7

De : Daniel-Constantin Mierla <miconda at gmail.com><mailto:miconda at gmail.com>
Envoyé : mercredi 17 octobre 2018 19:44
À : Nicolas Breuer <nicolas.breuer at belcenter.biz><mailto:nicolas.breuer at belcenter.biz>; Kamailio (SER) - Users Mailing List <sr-users at lists.kamailio.org><mailto:sr-users at lists.kamailio.org>
Objet : Re: [SR-Users] Script @Startup


Hello,

what is exact version you are running?

Output for: kamailio -v

Cheers,
Daniel

On 17.10.18 19:36, Nicolas Breuer wrote:
Hello,

I found the core file.

Loaded symbols for /usr/lib64/kamailio/modules/alias_db.so
Reading symbols from /usr/lib64/kamailio/modules/nathelper.so...Reading symbols from /usr/lib/debug/usr/lib64/kamailio/modules/nathelper.so.debug...done.
done.
Loaded symbols for /usr/lib64/kamailio/modules/nathelper.so
Reading symbols from /usr/lib64/kamailio/modules/debugger.so...Reading symbols from /usr/lib/debug/usr/lib64/kamailio/modules/debugger.so.debug...done.
done.
Loaded symbols for /usr/lib64/kamailio/modules/debugger.so
Core was generated by `/usr/sbin/kamailio -f /etc/kamailio/kamailio.cfg -P /var/run/kamailio/kamailio.'.
Program terminated with signal 11, Segmentation fault.
#0  0x00000033b7a89780 in memcpy () from /lib64/libc.so.6
Missing separate debuginfos, use: debuginfo-install glibc-2.12-1.212.el6.x86_64 keyutils-libs-1.4-5.el6.x86_64 krb5-libs-1.10.3-65.el6.x86_64 libcom_err-1.41.12-24.el6.x86_64 libselinux-2.0.94-7.el6.x86_64 mysql-libs-5.1.73-8.el6_8.x86_64 nss-softokn-freebl-3.14.3-23.3.el6_8.x86_64 openssl-1.0.1e-57.el6.x86_64 zlib-1.2.3-29.el6.x86_64
(gdb) bt
#0  0x00000033b7a89780 in memcpy () from /lib64/libc.so.6
#1  0x000000000071e803 in select_cfg_var (res=0x7fff67b56690, s=0x7f90d37f34f8, msg=0xa50460) at core/cfg/cfg_select.c:223
#2  0x000000000059d429 in run_select (res=0x7fff67b56690, s=0x7f90d37f34f8, msg=0xa50460) at core/select.c:425
#3  0x00007f90d178740d in pv_get_select (msg=0xa50460, param=0x7f90d37f3428, res=0x7fff67b567b0) at pv_select.c:61
#4  0x0000000000523e09 in pv_get_spec_value (msg=0xa50460, sp=0x7f90d37f3410, value=0x7fff67b567b0) at core/pvapi.c:1380
#5  0x00000000005242be in pv_printf (msg=0xa50460, list=0x7f90d3924998, buf=0x7f90d2e58260 "select Status FROM x_providers_SIP where Provider like 'PROXY%' and (Proxy_ID='", len=0x7fff67b5687c) at core/pvapi.c:1439
#6  0x00007f90d2c2f9f0 in ops_dbquery_avps (msg=0xa50460, query=0x7f90d3924998, dest=0x7f90d3924aa8) at avpops_impl.c:744
#7  0x00007f90d2c218f5 in w_dbquery2_avps (msg=0xa50460, query=0x7f90d3924998 "pa[Ó177", dest=0x7f90d3924aa8 "\004") at avpops.c:1022
#8  0x0000000000434041 in do_action (h=0x7fff67b57300, a=0x7f90d35b5cb0, msg=0xa50460) at core/action.c:1079
#9  0x0000000000440bd5 in run_actions (h=0x7fff67b57300, a=0x7f90d35b4480, msg=0xa50460) at core/action.c:1565
#10 0x0000000000441361 in run_top_route (a=0x7f90d35b4480, msg=0xa50460, c=0x7fff67b57300) at core/action.c:1654
#11 0x0000000000441910 in run_child_one_init_route () at core/action.c:1680
#12 0x000000000042424b in main_loop () at main.c:1616
#13 0x000000000042b5ee in main (argc=13, argv=0x7fff67b578e8) at main.c:2638



De : Daniel-Constantin Mierla <miconda at gmail.com><mailto:miconda at gmail.com>
Envoyé : mercredi 17 octobre 2018 19:16
À : Kamailio (SER) - Users Mailing List <sr-users at lists.kamailio.org><mailto:sr-users at lists.kamailio.org>; Nicolas Breuer <nicolas.breuer at belcenter.biz><mailto:nicolas.breuer at belcenter.biz>
Objet : Re: [SR-Users] Script @Startup


Hello,

the log message says that core file was generated, get the backtrace from it with gdb and post it here in order to see where the crash was.

Cheers,
Daniel

On 17.10.18 18:59, Nicolas Breuer wrote:

Hello,



Doing an avp_db_query works but we  have a crash just after 😊



Oct 17 18:58:11 proxy1 kernel: kamailio[8987]: segfault at 0 ip 00000033b7a89780 sp 00007fff8e7765a8 error 4 in libc-2.12.so[33b7a00000+18b000]

Oct 17 18:58:12 proxy1 /usr/sbin/kamailio[8986]: ALERT: <core> [main.c:739]: handle_sigs(): child process 8987 exited by a signal 11

Oct 17 18:58:12 proxy1 /usr/sbin/kamailio[8986]: ALERT: <core> [main.c:742]: handle_sigs(): core was generated





-----Message d'origine-----
De : sr-users <sr-users-bounces at lists.kamailio.org><mailto:sr-users-bounces at lists.kamailio.org> De la part de Mikko Lehto
Envoyé : mercredi 17 octobre 2018 09:28
À : Kamailio (SER) - Users Mailing List <sr-users at lists.kamailio.org><mailto:sr-users at lists.kamailio.org>
Objet : Re: [SR-Users] Script @Startup
Importance : Haute



Nicolas Breuer <nicolas.breuer at belcenter.biz<mailto:nicolas.breuer at belcenter.biz>>:



> Is there a way to execute some codes/scripts at the launch of the Kamailio Server ?

>

> So only once when we launch the server.



Hi, maybe event route core:worker-one-init is helpful to you.



See: http://kamailio.org/wiki/cookbooks/5.1.x/core#event_route



--

Mikko



_______________________________________________

Kamailio (SER) - Users Mailing List

sr-users at lists.kamailio.org<mailto:sr-users at lists.kamailio.org>

https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users








_______________________________________________

Kamailio (SER) - Users Mailing List

sr-users at lists.kamailio.org<mailto:sr-users at lists.kamailio.org>

https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users







--

Daniel-Constantin Mierla -- www.asipto.com<http://www.asipto.com>

www.twitter.com/miconda<http://www.twitter.com/miconda> -- www.linkedin.com/in/miconda<http://www.linkedin.com/in/miconda>

Kamailio World Conference -- www.kamailioworld.com<http://www.kamailioworld.com>

Kamailio Advanced Training, Nov 12-14, 2018, in Berlin -- www.asipto.com<http://www.asipto.com>






--

Daniel-Constantin Mierla -- www.asipto.com<http://www.asipto.com>

www.twitter.com/miconda<http://www.twitter.com/miconda> -- www.linkedin.com/in/miconda<http://www.linkedin.com/in/miconda>

Kamailio World Conference -- www.kamailioworld.com<http://www.kamailioworld.com>

Kamailio Advanced Training, Nov 12-14, 2018, in Berlin -- www.asipto.com<http://www.asipto.com>





--

Daniel-Constantin Mierla -- www.asipto.com<http://www.asipto.com>

www.twitter.com/miconda<http://www.twitter.com/miconda> -- www.linkedin.com/in/miconda<http://www.linkedin.com/in/miconda>

Kamailio World Conference -- www.kamailioworld.com<http://www.kamailioworld.com>

Kamailio Advanced Training, Nov 12-14, 2018, in Berlin -- www.asipto.com<http://www.asipto.com>




--

Daniel-Constantin Mierla -- www.asipto.com<http://www.asipto.com>

www.twitter.com/miconda<http://www.twitter.com/miconda> -- www.linkedin.com/in/miconda<http://www.linkedin.com/in/miconda>

Kamailio World Conference -- www.kamailioworld.com<http://www.kamailioworld.com>

Kamailio Advanced Training, Nov 12-14, 2018, in Berlin -- www.asipto.com<http://www.asipto.com>



--

Daniel-Constantin Mierla -- www.asipto.com<http://www.asipto.com>

www.twitter.com/miconda<http://www.twitter.com/miconda> -- www.linkedin.com/in/miconda<http://www.linkedin.com/in/miconda>

Kamailio World Conference -- www.kamailioworld.com<http://www.kamailioworld.com>

Kamailio Advanced Training, Nov 12-14, 2018, in Berlin -- www.asipto.com<http://www.asipto.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.kamailio.org/pipermail/sr-users/attachments/20181019/c46c572a/attachment.html>


More information about the sr-users mailing list