[sr-dev] [tracker] Task opened: mtree module causes kamilio to segfault when loading from mysql table

sip-router bugtracker at sip-router.org
Tue Mar 18 16:37:56 CET 2014


THIS IS AN AUTOMATED MESSAGE, DO NOT REPLY.

A new Flyspray task has been opened.  Details are below. 

User who did this - adeel (adeeln) 

Attached to Project - sip-router
Summary - mtree module causes kamilio to segfault when loading from mysql table
Task Type - Bug Report
Category - Module
Status - Unconfirmed
Assigned To - 
Operating System - Linux
Severity - Medium
Priority - Normal
Reported Version - Development
Due in Version - Undecided
Due Date - Undecided
Details - When loading data from a simple MySQL table into mtree, kamailio segfaults on start.


I see the following error when loading the core dump into gdb:

<code>
Core was generated by `/usr/sbin/kamailio -P /var/run/kamailio.pid -u kamailio -g kamailio -f /etc/kam'.
Program terminated with signal 11, Segmentation fault.
#0  __strlen_sse2 () at ../sysdeps/x86_64/multiarch/../strlen.S:31
31      ../sysdeps/x86_64/multiarch/../strlen.S: No such file or directory.</code>

Here's the backtrace from kamailio:

<code>Thread 1 (Thread 0x7f0d45557700 (LWP 11655)):
#0  __strlen_sse2 () at ../sysdeps/x86_64/multiarch/../strlen.S:31
#1  0x00007f0d012f7a8b in mt_load_db (pt=0x7f0cefc555e8) at mtree_mod.c:580
#2  0x00007f0d012f5b1b in mod_init () at mtree_mod.c:300
#3  0x00000000004bc5c2 in init_mod (m=0x7f0d04bc2100) at sr_module.c:967
#4  0x00000000004bc479 in init_mod (m=0x7f0d04bc2498) at sr_module.c:964
#5  0x00000000004bc479 in init_mod (m=0x7f0d04bc2a70) at sr_module.c:964
#6  0x00000000004bc479 in init_mod (m=0x7f0d04bc2eb0) at sr_module.c:964
#7  0x00000000004bc479 in init_mod (m=0x7f0d04bc34c8) at sr_module.c:964
#8  0x00000000004bc479 in init_mod (m=0x7f0d04bc4d90) at sr_module.c:964
#9  0x00000000004bc479 in init_mod (m=0x7f0d04bc52e8) at sr_module.c:964
#10 0x00000000004bc73e in init_modules () at sr_module.c:994
#11 0x00000000004b758d in main (argc=15, argv=0x7fff972fd028) at main.c:2482

Thread 1 (Thread 0x7f0d45557700 (LWP 11655)):
#0  __strlen_sse2 () at ../sysdeps/x86_64/multiarch/../strlen.S:31
No locals.
#1  0x00007f0d012f7a8b in mt_load_db (pt=0x7f0cefc555e8) at mtree_mod.c:580
        db_cols = {0x7f0d01500280 <tprefix_column>, 0x7f0d01500290 <tvalue_column>, 0x0}
        key_cols = {0x7f0d01500270 <tname_column>}
        op = {0x7f0d012fd75a "="}
        vals = {{type = DB1_STRING, nul = 0, free = 58122258, val = {int_val = -272279920, ll_val = 139693539022480, double_val = 6.9017778576990958e-310, time_val = 139693539022480, 
              string_val = 0x7f0cefc55690 "localdids", str_val = {s = 0x7f0cefc55690 "localdids", len = 19910842}, blob_val = {s = 0x7f0cefc55690 "localdids", len = 19910842}, bitmap_val = 4022687376}}}
        tprefix = {s = 0x872be28a <Address 0x872be28a out of bounds>, len = -1758475632}
        tvalue = {s = 0x7fff972fcb00 "\350U\305\357\f\177", len = 48}
        db_res = 0x7f0d04bf8460
        i = 0
        ret = 32767
        new_tree = {tname = {s = 0x7f0cefc55690 "localdids", len = 9}, dbtable = {s = 0x7f0cefc55700 "mtree", len = 5}, type = 2, multi = 0, nrnodes = 0, nritems = 0, memsize = 0, head = 0x0, next = 0x0}
        old_tree = 0x7f0cefc555e8
        bk_head = 0x0
        __FUNCTION__ = "mt_load_db"
#2  0x00007f0d012f5b1b in mod_init () at mtree_mod.c:300
        pt = 0x7f0cefc555e8
        __FUNCTION__ = "mod_init"
#3  0x00000000004bc5c2 in init_mod (m=0x7f0d04bc2100) at sr_module.c:967
        __FUNCTION__ = "init_mod"
#4  0x00000000004bc479 in init_mod (m=0x7f0d04bc2498) at sr_module.c:964
        __FUNCTION__ = "init_mod"
#5  0x00000000004bc479 in init_mod (m=0x7f0d04bc2a70) at sr_module.c:964
        __FUNCTION__ = "init_mod"
#6  0x00000000004bc479 in init_mod (m=0x7f0d04bc2eb0) at sr_module.c:964
        __FUNCTION__ = "init_mod"
#7  0x00000000004bc479 in init_mod (m=0x7f0d04bc34c8) at sr_module.c:964
        __FUNCTION__ = "init_mod"
#8  0x00000000004bc479 in init_mod (m=0x7f0d04bc4d90) at sr_module.c:964
        __FUNCTION__ = "init_mod"
#9  0x00000000004bc479 in init_mod (m=0x7f0d04bc52e8) at sr_module.c:964
        __FUNCTION__ = "init_mod"
#10 0x00000000004bc73e in init_modules () at sr_module.c:994
        t = 0xffffffffffffffff
        i = 0
        __FUNCTION__ = "init_modules"
#11 0x00000000004b758d in main (argc=15, argv=0x7fff972fd028) at main.c:2482
        cfg_stream = 0x1b91010
        c = -1
        r = 0
        tmp = 0x7fff972fdc11 ""
        tmp_len = 0
        port = 4257814
        proto = 32525
        options = 0x5f68b8 ":f:cm:M:dVIhEeb:l:L:n:vKrRDTN:W:w:t:u:g:P:G:SQ:O:a:A:"
        ret = -1
        seed = 3871773532
        rfd = 4
        debug_save = 0
        debug_flag = 0
        dont_fork_cnt = 0
        n_lst = 0x7f0d44b8d3a0
        p = 0x1 <Address 0x1 out of bounds>
        __FUNCTION__ = "main"</code>


here's the mtree parameters in my config:

<code># ----- mtree params ------
modparam("mtree", "db_url", "mysql://kamailio:Gc!E10vod2bT@localhost/kamailio")
modparam("mtree", "db_table", "mtree")
modparam("mtree", "tprefix_column", "phonenumber")
modparam("mtree", "tvalue_column", "value")
modparam("mtree", "fetch_rows", 4000)
modparam("mtree", "mtree", "name=localdids;dbtable=mtree;type=2;multi=0")
modparam("mtree", "mt_tree_type", 2)
modparam("mtree", "char_list", "0123456789+")
modparam("mtree", "pv_value", "$avp(s:didmatch)")
modparam("mtree", "mt_ignore_duplicates", 1)
</code>


and Kamailio was compiled with the following options:

<code>make -j3 CC=x86_64-pc-linux-gnu-gcc CPU_TYPE= SCTP=0 CC_EXTRA_OPTS=-I/usr/gnu/include mode=release TLS_HOOKS=0 FLAVOUR=kamailio group_include='kxml kstandard kmysql' include_modules='mi_fifo regex sipcapture siputils statistics textops textopsx tm uac uac_redirect xlog' exclude_modules=iptrtpproxy prefix='/usr/' all</code>

Here's MySQL structure and sample data:

<code>mysql> desc mtree;
+-------------+---------------------+------+-----+---------+----------------+
| Field       | Type                | Null | Key | Default | Extra          |
+-------------+---------------------+------+-----+---------+----------------+
| id          | int(10) unsigned    | NO   | PRI | NULL    | auto_increment |
| phonenumber | bigint(20) unsigned | NO   | UNI | NULL    |                |
| value       | tinyint(1)          | NO   |     | 1       |                |
+-------------+---------------------+------+-----+---------+----------------+

mysql> select * from mtree limit 3;
+----+-------------+-------+
| id | phonenumber | value |
+----+-------------+-------+
|  1 |  2267800202 |     1 |
|  2 |  2267800203 |     1 |
|  3 |  2893400187 |     1 |
+----+-------------+-------+
</code>



I verified there are no NULL values in the table.



Here's the syslog output (partially truncated...i can provide the full syslog if necessary):

<code>Mar 11 17:39:35 did-oak /usr/sbin/kamailio[17309]: DEBUG: <core> [usr_avp.c:895]: parse_avp_ident(): Parsing 's:tdstid'
Mar 11 17:39:35 did-oak /usr/sbin/kamailio[17309]: DEBUG: <core> [usr_avp.c:895]: parse_avp_ident(): Parsing 's:tweight'
Mar 11 17:39:35 did-oak /usr/sbin/kamailio[17309]: DEBUG: <core> [usr_avp.c:895]: parse_avp_ident(): Parsing 's:tcount'
Mar 11 17:39:35 did-oak /usr/sbin/kamailio[17309]: DEBUG: mtree [mtree_mod.c:250]: mod_init(): mt_char_list=0123456789+ 
Mar 11 17:39:35 did-oak /usr/sbin/kamailio[17309]: DEBUG: <core> [sr_module.c:701]: find_mod_export_record(): find_export_record: found <db_bind_api> in module db_mysql [/usr/lib64/kamailio/modules/db_mysql.so]
Mar 11 17:39:35 did-oak /usr/sbin/kamailio[17309]: DEBUG: <core> [db.c:213]: db_bind_mod(): using db bind api for db_mysql
Mar 11 17:39:35 did-oak /usr/sbin/kamailio[17309]: DEBUG: <core> [db.c:318]: db_do_init2(): connection 0x7fb42014e810 not found in pool
Mar 11 17:39:35 did-oak /usr/sbin/kamailio[17309]: DEBUG: db_mysql [km_my_con.c:94]: db_mysql_new_connection(): opening connection: mysql://xxxx:xxxx@localhost/kamailio
Mar 11 17:39:35 did-oak /usr/sbin/kamailio[17309]: DEBUG: db_mysql [km_my_con.c:121]: db_mysql_new_connection(): connection type is Localhost via UNIX socket
Mar 11 17:39:35 did-oak /usr/sbin/kamailio[17309]: DEBUG: db_mysql [km_my_con.c:122]: db_mysql_new_connection(): protocol version is 10
Mar 11 17:39:35 did-oak /usr/sbin/kamailio[17309]: DEBUG: db_mysql [km_my_con.c:123]: db_mysql_new_connection(): server version is 5.5.32-log
Mar 11 17:39:35 did-oak /usr/sbin/kamailio[17309]: DEBUG: mtree [mtree_mod.c:275]: mod_init(): database connection opened successfully
Mar 11 17:39:35 did-oak /usr/sbin/kamailio[17309]: DEBUG: mtree [mtree_mod.c:288]: mod_init(): static trees defined
Mar 11 17:39:35 did-oak /usr/sbin/kamailio[17309]: DEBUG: mtree [mtree_mod.c:295]: mod_init(): loading from tree <localdids>
Mar 11 17:39:35 did-oak /usr/sbin/kamailio[17309]: DEBUG: <core> [db_res.c:118]: db_new_result(): allocate 56 bytes for result set at 0x7fb42014f050
Mar 11 17:39:35 did-oak /usr/sbin/kamailio[17309]: DEBUG: db_mysql [km_res.c:68]: db_mysql_get_columns(): 2 columns returned from the query
Mar 11 17:39:35 did-oak /usr/sbin/kamailio[17309]: DEBUG: <core> [db_res.c:155]: db_allocate_columns(): allocate 16 bytes for result names at 0x7fb42014f158
Mar 11 17:39:35 did-oak /usr/sbin/kamailio[17309]: DEBUG: <core> [db_res.c:165]: db_allocate_columns(): allocate 8 bytes for result types at 0x7fb42014f1c8
Mar 11 17:39:35 did-oak /usr/sbin/kamailio[17309]: DEBUG: db_mysql [km_res.c:85]: db_mysql_get_columns(): allocate 16 bytes for RES_NAMES[0] at 0x7fb42014f230
Mar 11 17:39:35 did-oak /usr/sbin/kamailio[17309]: DEBUG: db_mysql [km_res.c:92]: db_mysql_get_columns(): RES_NAMES(0x7fb42014f230)[0]=[phonenumber]
Mar 11 17:39:35 did-oak /usr/sbin/kamailio[17309]: DEBUG: db_mysql [km_res.c:105]: db_mysql_get_columns(): use DB1_BIGINT result type
Mar 11 17:39:35 did-oak /usr/sbin/kamailio[17309]: DEBUG: db_mysql [km_res.c:85]: db_mysql_get_columns(): allocate 16 bytes for RES_NAMES[1] at 0x7fb42014f2a0
Mar 11 17:39:35 did-oak /usr/sbin/kamailio[17309]: DEBUG: db_mysql [km_res.c:92]: db_mysql_get_columns(): RES_NAMES(0x7fb42014f2a0)[1]=[value]
Mar 11 17:39:35 did-oak /usr/sbin/kamailio[17309]: DEBUG: db_mysql [km_res.c:100]: db_mysql_get_columns(): use DB1_INT result type
Mar 11 17:39:35 did-oak /usr/sbin/kamailio[17309]: DEBUG: db_mysql [km_dbase.c:358]: db_mysql_fetch_result(): converting row 0 of 100 count 100
Mar 11 17:39:35 did-oak /usr/sbin/kamailio[17309]: DEBUG: <core> [db_row.c:119]: db_allocate_row(): allocate 64 bytes for row values at 0x7fb42014f9b0
Mar 11 17:39:35 did-oak /usr/sbin/kamailio[17309]: DEBUG: <core> [db_val.c:84]: db_str2val(): converting BIGINT [2267800202]
Mar 11 17:39:35 did-oak /usr/sbin/kamailio[17309]: DEBUG: <core> [db_val.c:73]: db_str2val(): converting INT [1]
Mar 11 17:39:35 did-oak /usr/sbin/kamailio[17309]: DEBUG: <core> [db_row.c:119]: db_allocate_row(): allocate 64 bytes for row values at 0x7fb42014fa50

... (the last 3 lines repeat until it's loaded all 100 entries and then the following line is printed) ...

Mar 11 17:39:55 did-oak kamailio: ERROR: <core> [daemonize.c:307]: daemonize(): Main process exited before writing to pipe


</code>

More information can be found at the following URL:
http://sip-router.org/tracker/index.php?do=details&task_id=412

You are receiving this message because you have requested it from the Flyspray bugtracking system.  If you did not expect this message or don't want to receive mails in future, you can change your notification settings at the URL shown above.



More information about the sr-dev mailing list