[SR-Users] WARNING: tm [t_lookup.c:1537]: t_unref(): WARNING: script writer didn't release transaction

Roberto Fichera kernel at tekno-soft.it
Fri Jun 19 10:39:13 CEST 2015


On 06/18/2015 11:24 PM, Daniel-Constantin Mierla wrote:
> Hello,

Hi Daniel,

> save() for REGISTER request sends a 200ok stateless if the transaction
> was not created before.
>
> But an async function creates a transaction, suspending it for a while
> in memory. If the route executed by async is not forwarding the register
> nor sending a reply to it via tm, then the register transaction end up
> in an undecided routing state in memory. That is the reason of the
> warning you get.
>
> As you don't want to process the register in asynchronous mode, might be
> better to use mqueue and rtimer to delegate the tasks for notifications
> to another process.

Ok! I'll try it.

Cheers,
Roberto Fichera.

>
> Cheers,
> Daniel
>
> On 18/06/15 15:37, Roberto Fichera wrote:
>> On 06/10/2015 04:19 PM, Roberto Fichera wrote:
>>> Hi All,
>> Hi All,
>>
>>> I'm getting the warning in the subject after replacing a route() with a async_task_route(). In the called route() I'm
>>> doing some db query and send notify messages using the uac module. The async_task_route() is called
>>> once received a register message.
>>>
>>> Any idea what's is going on?
>> I would show some additional info, the idea is to make asynchronous a db query and some UAC notification message,
>> kamailio is v4.2.5, below is the relevant part of my code:
>>
>> route[REGISTRAR] {
>>         if (is_method("REGISTER"))
>>         {
>>                 if(isflagset(FLT_NATS))
>>                 {
>>                         setbflag(FLB_NATB);
>>                 }
>>
>>     if (!is_avp_set("$avp(received)"))
>>     {
>>       $avp(received) = "sip:" + $si + ":" + $sp + ";transport=" + $proto;
>>     }
>>
>>     # Save and update the contact information
>>                 if (!save("location", "0x04"))
>>                         sl_reply_error();
>>
>>     if(@contact.expires) {
>>         $var(expires) = @contact.expires;
>>     } else {
>>         if(is_present_hf("Expires")) {
>>            $var(expires) = $hdr(Expires);
>>         } else {
>>            $var(expires) = 300;
>>         }
>>     }
>>
>>     if($var(expires) == 0) {
>>        xlog("L_INFO", "$ci|end|unregister request from $Au $si:$sp");
>>        $avp(s:subs_from) = $fU;
>>        $avp(s:subs_status) = "Offline";
>>        route(PUSH_NOTIFICATION);
>>        exit;
>>     }
>>
>>     $avp(s:subs_from) = $fU;
>>     $avp(s:subs_status) = "Online";
>>     route(PUSH_NOTIFICATION);
>>
>> Se cambio la async_route() con una semplice route() tutto funziona correttamente.
>>
>> route[PUSH_NOTIFICATION] {
>>     async_route("ASYNC_PUSH_NOTIFICATION_USERCONTACTS", "5");
>> }
>>
>> route[ASYNC_PUSH_NOTIFICATION_USERCONTACTS] {
>>     $var(subs_to) = $avp(s:subs_from);
>>     xlog("L_INFO", "Request contacts push notification for $var(subs_to)");
>>     sql_query("ca", "select contact from contactsmap where username = '$var(subs_to)'", "ra");
>>     if($dbr(ra=>rows)>0)
>>     {
>>         $var(i) = 0;
>>         while($var(i) < $dbr(ra=>rows))
>>         {
>>             $avp(s:subs_from) = $dbr(ra=>[$var(i),0]);
>>             $avp(s:subs_to) = $var(subs_to);
>>             xlog("L_INFO", "Checking presence of $avp(s:subs_from)");
>>             if(registered("location", "sip:$avp(s:subs_from)@test.net"))
>>             {
>>                 xlog("L_INFO", "Username $avp(s:subs_from) is registered sending push notification");
>>                 route(send_event_notify_presence);
>>             }
>>             else
>>             {
>>                 xlog("L_INFO", "Username $avp(s:subs_from) is not registered, skipping");
>>             }
>>             $var(i) = $var(i) + 1;
>>         }
>>     }
>>     sql_result_free("ra");
>>    t_release();
>> }
>>
>>
>> route[send_event_notify_presence]
>> {
>>   xlog("L_INFO", "request to send NOTIFY from $avp(s:subs_from) to $avp(s:subs_to)");
>>
>>   $uac_req(method)        = "NOTIFY";
>>
>>   $uac_req(ruri) = "sip:" + $avp(s:subs_to) + "@test.net";
>>   $uac_req(turi) = "sip:" + $avp(s:subs_to) + "@test.net";
>>   $uac_req(furi) = "sip:" + $avp(s:subs_from) + "@test.net";
>>   $uac_req(ouri) = "sip:test.net:5060";
>>
>>   $uac_req(hdrs) = "Event: voneus-contact-status\r\nVoneus-Status: " + $avp(s:subs_status) + "\r\n";
>>   $uac_req(body) = "";
>>
>>   return uac_req_send();
>> }
>>
>>
>> and the corresponding backtrack I've got:
>>
>> [root at ip-10-227-0-26 coredump]# coredumpctl gdb
>>            PID: 12881 (kamailio)
>>            UID: 997 (kamailio)
>>            GID: 996 (kamailio)
>>         Signal: 11 (SEGV)
>>      Timestamp: Thu 2015-06-18 14:22:25 BST (6min ago)
>>   Command Line: /usr/sbin/kamailio -P /var/run/kamailio.pid -m 1024 -M 32 -u kamailio -g kamailio -w /tmp
>>     Executable: /usr/sbin/kamailio
>>  Control Group: /system.slice/kamailio.service
>>           Unit: kamailio.service
>>          Slice: system.slice
>>        Boot ID: dbaf18ffab95459080b8f579d1c4c9bc
>>     Machine ID: 9388a5eb453d59f4fd98567b37061720
>>       Hostname: ip-10-227-0-26.localdomain
>>       Coredump: /var/lib/systemd/coredump/core.kamailio.997.dbaf18ffab95459080b8f579d1c4c9bc.12881.1434633745000000.xz
>>        Message: Process 12881 (kamailio) of user 997 dumped core.
>>                
>>                 Stack trace of thread 12881:
>>                 #0  0x000000007464be9a atomic_cmpxchg_int (async.so)
>>                 #1  0x000000007464beee futex_get (async.so)
>>                 #2  0x000000007464d947 async_sleep (async.so)
>>                 #3  0x0000000074650d26 w_async_route (async.so)
>>                 #4  0x0000000008187a7a do_action (kamailio)
>>                 #5  0x0000000008192a9f run_actions (kamailio)
>>                 #6  0x0000000008184b24 do_action (kamailio)
>>                 #7  0x0000000008192a9f run_actions (kamailio)
>>                 #8  0x000000000819310d run_top_route (kamailio)
>>                 #9  0x0000000074866288 reg_ul_expired_contact (registrar.so)
>>                 #10 0x0000000074895e16 run_ul_callbacks (usrloc.so)
>>                 #11 0x0000000074897977 wb_timer (usrloc.so)
>>                 #12 0x0000000074898948 timer_urecord (usrloc.so)
>>                 #13 0x0000000074891bc7 mem_timer_udomain (usrloc.so)
>>                 #14 0x00000000748ba321 synchronize_all_udomains (usrloc.so)
>>                 #15 0x00000000748a3a7d destroy (usrloc.so)
>>                 #16 0x0000000008144dc8 destroy_modules (kamailio)
>>                 #17 0x000000000812eff1 cleanup (kamailio)
>>                 #18 0x000000000813035f shutdown_children (kamailio)
>>                 #19 0x00000000081325bd handle_sigs (kamailio)
>>                 #20 0x000000000813949b main_loop (kamailio)
>>                 #21 0x000000000813da23 main (kamailio)
>>                 #22 0x00000000b7550e8e __libc_start_main (libc.so.6)
>>                 #23 0x00000000080593c1 _start (kamailio)
>>
>>
>> GNU gdb (GDB) Fedora 7.8.2-38.fc21
>> Copyright (C) 2014 Free Software Foundation, Inc.
>> License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
>> This is free software: you are free to change and redistribute it.
>> There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
>> and "show warranty" for details.
>> This GDB was configured as "i686-redhat-linux-gnu".
>> Type "show configuration" for configuration details.
>> For bug reporting instructions, please see:
>> <http://www.gnu.org/software/gdb/bugs/>.
>> Find the GDB manual and other documentation resources online at:
>> <http://www.gnu.org/software/gdb/documentation/>.
>> For help, type "help".
>> Type "apropos word" to search for commands related to "word"...
>> Reading symbols from /usr/sbin/kamailio...Reading symbols from /usr/lib/debug/usr/sbin/kamailio.debug...done.
>> done.
>> [New LWP 12881]
>> [Thread debugging using libthread_db enabled]
>> Using host libthread_db library "/lib/i686/nosegneg/libthread_db.so.1".
>> Core was generated by `/usr/sbin/kamailio -P /var/run/kamailio.pid -m 1024 -M 32 -u kamailio -g kamail'.
>> Program terminated with signal SIGSEGV, Segmentation fault.
>> #0  0x7464be9a in atomic_cmpxchg_int (var=0x3f8, old=0, new_v=1) at ../../atomic/atomic_x86.h:233
>> 233    ATOMIC_FUNC_CMPXCHG(cmpxchg, "cmpxchgl %2, %1", int , int)
>> Missing separate debuginfos, use: debuginfo-install bzip2-libs-1.0.6-14.fc21.i686 elfutils-libelf-0.161-6.fc21.i686
>> elfutils-libs-0.161-6.fc21.i686 glibc-2.20-8.fc21.i686 keyutils-libs-1.5.9-4.fc21.i686 krb5-libs-1.12.2-15.fc21.i686
>> libcom_err-1.42.12-4.fc21.i686 libgcc-4.9.2-6.fc21.i686 libselinux-2.3-9.fc21.i686 libstdc++-4.9.2-6.fc21.i686
>> libxml2-2.9.1-7.fc21.i686 mariadb-libs-10.0.17-1.fc21.i686 openssl-libs-1.0.1k-6.fc21.i686 pcre-8.35-11.fc21.i686
>> systemd-libs-216-25.fc21.i686 xz-libs-5.1.2-14alpha.fc21.i686 zlib-1.2.8-7.fc21.i686
>> (gdb) bt
>> #0  0x7464be9a in atomic_cmpxchg_int (var=0x3f8, old=0, new_v=1) at ../../atomic/atomic_x86.h:233
>> #1  0x7464beee in futex_get (lock=0x3f8) at ../../futexlock.h:101
>> #2  0x7464d947 in async_sleep (msg=0x74ae4240 <_faked_msg>, seconds=5, act=0xb55d9d4c) at async_sleep.c:158
>> #3  0x74650d26 in w_async_route (msg=0x74ae4240 <_faked_msg>, rt=0xb55ba774 "\f\244]\265 ", sec=0xb55ba7d8
>> "\210\237]\265\001") at async_mod.c:249
>> #4  0x08187a7a in do_action (h=0xbfbeafdc, a=0xb55d9ab4, msg=0x74ae4240 <_faked_msg>) at action.c:1100
>> #5  0x08192a9f in run_actions (h=0xbfbeafdc, a=0xb55d9ab4, msg=0x74ae4240 <_faked_msg>) at action.c:1583
>> #6  0x08184b24 in do_action (h=0xbfbeafdc, a=0xb55d9888, msg=0x74ae4240 <_faked_msg>) at action.c:712
>> #7  0x08192a9f in run_actions (h=0xbfbeafdc, a=0xb55d89bc, msg=0x74ae4240 <_faked_msg>) at action.c:1583
>> #8  0x0819310d in run_top_route (a=0xb55d89bc, msg=0x74ae4240 <_faked_msg>, c=0x0) at action.c:1669
>> #9  0x74866288 in reg_ul_expired_contact (ptr=0x753d0ff4, type=8, param=0x0) at regpv.c:694
>> #10 0x74895e16 in run_ul_callbacks (type=8, c=0x753d0ff4) at ul_callback.h:90
>> #11 0x74897977 in wb_timer (_r=0x753d0f8c) at urecord.c:352
>> #12 0x74898948 in timer_urecord (_r=0x753d0f8c) at urecord.c:427
>> #13 0x74891bc7 in mem_timer_udomain (_d=0x75202320, istart=0, istep=1) at udomain.c:968
>> #14 0x748ba321 in synchronize_all_udomains (istart=0, istep=1) at dlist.c:742
>> #15 0x748a3a7d in destroy () at ul_mod.c:481
>> #16 0x08144dc8 in destroy_modules () at sr_module.c:811
>> #17 0x0812eff1 in cleanup (show_status=1) at main.c:569
>> #18 0x0813035f in shutdown_children (sig=15, show_status=1) at main.c:711
>> #19 0x081325bd in handle_sigs () at main.c:802
>> #20 0x0813949b in main_loop () at main.c:1757
>> #21 0x0813da23 in main (argc=13, argv=0xbfbeb914) at main.c:2581
>> (gdb) info threads
>>   Id   Target Id         Frame
>> * 1    Thread 0xb7537700 (LWP 12881) 0x7464be9a in atomic_cmpxchg_int (var=0x3f8, old=0, new_v=1) at
>> ../../atomic/atomic_x86.h:233
>> (gdb) fr 3
>> #3  0x74650d26 in w_async_route (msg=0x74ae4240 <_faked_msg>, rt=0xb55ba774 "\f\244]\265 ", sec=0xb55ba7d8
>> "\210\237]\265\001") at async_mod.c:249
>> 249        if(async_sleep(msg, s, act)<0)
>>
>>
>>> Cheers,
>>> Roberto Fichera.
>>>
>>> _______________________________________________
>>> SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
>>> sr-users at lists.sip-router.org
>>> http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users
>>>
>> _______________________________________________
>> SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
>> sr-users at lists.sip-router.org
>> http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users




More information about the sr-users mailing list