<p>There seems to be an intermittent issue with kamailio db_postgres module creating new TLS connection with postgresql 9.4 server. Every now and then, kamailio would crash when initiation db connection.</p>

<p>Here is the gdb core dump output. Thanks,</p>

<p>Thread 1 (Thread 0x7f02f2dab7c0 (LWP 1502)):<br>
#0  0x00007f02f261de84 in RSA_free () from /usr/local/ssl/lib/libcrypto.so.1.0.0<br>
No symbol table info available.<br>
<a href="https://github.com/kamailio/kamailio/issues/1" class="issue-link" title="API for ruby">#1</a>  0x00007f02f264810a in EVP_PKEY_free () from /usr/local/ssl/lib/libcrypto.so.1.0.0<br>
No symbol table info available.<br>
<a href="https://github.com/kamailio/kamailio/pull/2" class="issue-link" title="Fix some typos and capitalisation in INSTALL">#2</a>  0x00007f02f2657a24 in pubkey_cb () from /usr/local/ssl/lib/libcrypto.so.1.0.0<br>
No symbol table info available.<br>
<a href="https://github.com/kamailio/kamailio/pull/3" class="issue-link" title="usrloc_dmq: add module for usrloc sync via dmq">#3</a>  0x00007f02f265d8ee in asn1_item_combine_free () from /usr/local/ssl/lib/libcrypto.so.1.0.0<br>
No symbol table info available.<br>
<a href="https://github.com/kamailio/kamailio/pull/4" class="issue-link" title="Update pcscf.cfg">#4</a>  0x00007f02f265dabf in ASN1_template_free () from /usr/local/ssl/lib/libcrypto.so.1.0.0<br>
No symbol table info available.<br>
<a href="https://github.com/kamailio/kamailio/issues/5" class="issue-link" title='dialplan: using $(avp("key")[*]) on match/subst rules'>#5</a>  0x00007f02f265d9a6 in asn1_item_combine_free () from /usr/local/ssl/lib/libcrypto.so.1.0.0<br>
No symbol table info available.<br>
<a href="https://github.com/kamailio/kamailio/issues/6" class="issue-link" title="usrloc: REGISTER with new callid gets updated on memory but not on DB">#6</a>  0x00007f02f265dabf in ASN1_template_free () from /usr/local/ssl/lib/libcrypto.so.1.0.0<br>
No symbol table info available.<br>
<a href="https://github.com/kamailio/kamailio/issues/7" class="issue-link" title="avpops: avp_copy add xavp">#7</a>  0x00007f02f265d9a6 in asn1_item_combine_free () from /usr/local/ssl/lib/libcrypto.so.1.0.0<br>
No symbol table info available.<br>
<a href="https://github.com/kamailio/kamailio/issues/8" class="issue-link" title="debugger: config test report">#8</a>  0x00007f02f265daf5 in ASN1_item_free () from /usr/local/ssl/lib/libcrypto.so.1.0.0<br>
No symbol table info available.<br>
<a href="https://github.com/kamailio/kamailio/issues/9" class="issue-link" title='sipcapture: "core parsing of SIP message failed" with tcp defragmented message '>#9</a>  0x00007f02f2980b89 in ssl_set_pkey () from /usr/local/ssl/lib/libssl.so.1.0.0<br>
No symbol table info available.<br>
<a href="https://github.com/kamailio/kamailio/pull/10" class="issue-link" title="pkg/kamailio: Initial Travis CI configuration">#10</a> 0x00007f02f2981076 in SSL_use_PrivateKey_file () from /usr/local/ssl/lib/libssl.so.1.0.0<br>
No symbol table info available.<br>
<a href="https://github.com/kamailio/kamailio/issues/11" class="issue-link" title="issue notifying subscribers with transport tcp/tls">#11</a> 0x00007f02f2304f8a in initialize_SSL (conn=0xfe1150) at fe-secure.c:1310<br>
        buf = {st_dev = 64772, st_ino = 1331, st_nlink = 1, st_mode = 33152, st_uid = 498, st_gid = 498, <strong>pad0 = 0, st_rdev = 0, st_size = 1704, st_blksize = 4096, st_blocks = 8, <br>
          st_atim = {tv_sec = 1439918487, tv_nsec = 915125877}, st_mtim = {tv_sec = 1439918474, tv_nsec = 632125886}, st_ctim = {tv_sec = 1439918479, tv_nsec = 551125884}, <br>
          __unused = {0, 0, 0}}<br>
        homedir = "/var/run/kamailio\000r\000\000\000\000\000\334-r\000\000\000\000\000\200-)\357\002\177\000\000\020\320\022\357\002\177\000\000H-)\357\002\177\000\000e&T", '\000' "\200, -)\357\002\177\000\000\000\000\000\000\000\000\000\000\200-)\357\002\177\000\000\260]A\000\000\000\000\000@\245\064\214\377\177", '\000' "\340, g4\214\377\177\000\000\302\033T\000\000\000\000\000\260]A\000\000\000\000\000 \b&\357\002\177\000\000\260]A\000\000\000\000\000@\245\064\214\377\177\000\000\340g4\214\377\177\000\000\200-)\357\002\177\000\000\200h4\214\000\000\000\000\340\000&\357\002\177\000\000\000\000\000\000\000\000\000\000 \b&\357\002\177\000\000\260]A\000\000\000\000\000@\245\064\214\377\177\000\000\360j4\214\377\177\000\000\001\225U\000\000\000\000\000\300"...<br>
        fnbuf = "/var/run/kamailio/.postgresql/postgresql.key\000\177\000\000\360c4\214\377\177\000\000\212\332a\000\000\000\000\000(\000\000\000\004\000\000\000\250\324\335\252\002\177\000\000\000<code>\255\252\002\177\000\000\340\000&\357\002\177\000\000\001\000\000\000\000\000\000\000\340\324\335\252\002\177\000\000\000\000\000\000\000\000\000\000\260c4\214\002\000\000\000\064\253a\000\022\001\000\000\340\000&\357\002\177", '\000' <repeats 18 times>, "\020\000\000\000\000\000\000\000\000</code>\255\252\003\000\000\000\004\000\000\000\000\000\000\000\360c4\214\377\177\000\000g\002\000\000\000\000\000\000\030d\324\352\002\177\000\000\000\000\000\000\000\000\000\000\020d4\214\377\177\000\000\352\252a\000\022\001\000\000\030d\324\352\002\177\000\000\340\065\324\352\004\000\000\000"...<br>
        sebuf = "|Ak\362\002\177\000\000\002\000\000\000\n\000\000\000@k4\214\377\177\000\000\020\" \253\002\177\000\000\000\000\000\000\000\000\000\000\240r\333\252\002\177\000\000p\" \253\002\177\000\000p\" \253\264\001\000\000|Ak\362\002\177\000\000\002\000\000\000\006\000\000\000\000\000\000\000\377\177\000\000w\271\320\352\002\177\000\000\340\065\324\352\022\001\000\000\240r\333\252\002\177\000\000\000\000\000\000\000\000\000\000p\" \253\002\177\000\000\240}\222\362\002\177\000\000\063\364\\362\002\177\000\000\240k4\214\377\177\000\000p\000\000\000\000\000\000\000\260k4\214\377\177\000\000\020\" \253\002\177\000\000\240}\222\362\002\177\000\000p\" \253\002\177\000\000p\024\376\000\000\000\000\000\360m4\214\377\177\000\000\020\" \253\002\177\000\000\300\005 \253\002\177\000\000\006\000\000\000\000\000\000\000p\024\376\000\000\000\000\000\020\" \253\002\177\000\000\202"...<br>
        have_homedir = <br>
        have_cert = <br>
        pkey = 0x0<br>
<a href="https://github.com/kamailio/kamailio/pull/12" class="issue-link" title="Support for custom number of successful probing requests before moving a destination from 'inactive' to 'active' state">#12</a> 0x00007f02f2305996 in pqsecure_open_client (conn=0xfe1150) at fe-secure.c:299<br>
        rc = <br>
<a href="https://github.com/kamailio/kamailio/pull/13" class="issue-link" title="dispatcher: fixing some misspelled words and adding support for custom number of successful probing requests">#13</a> 0x00007f02f22f5566 in PQconnectPoll (conn=0xfe1150) at fe-connect.c:2203<br>
        pollres = <br>
        res = <br>
        sebuf = "\000\000\000\000\000\000\000\000@", '\000' , "\002\000\000\000\060\000\000\000[\000\000\000|\000\000\000w\000\000\000n\000\000\000[\000\000\000|\000\000\000\360\024\376\000\000\000\000\000\002\000\000\000\000\000\000\000\200n\354\361\002\177\000\000\350\021\376\000\000\000\000\000\020\251\376\000\000\000\000\000P\021\376\000\000\000\000\000\261\026\273\361\002\177\000\000\360\024\376\000\000\000\000\000\002\000\000\000\000\000\000\000\000%Q\362\002\177\000\000\222~\273\361\002\177\000\000p\024\376\000\000\000\000\000\070\255\376\000\000\000\000\000\020\251\376\000\000\000\000\000\320\217\064\214\377\177\000\000\270\251\376\000\000\000\000\000h8f/\220;\241g\020\251\376\000\000\000\000\000\004\000\000\000\000\000\000\000\320\217\064\214\377\177\000\000\270\251\376", '\000' , "h8f/\220;\241g"<br>
        optval = 0<br>
<a href="https://github.com/kamailio/kamailio/pull/14" class="issue-link" title="Improve for correct working with all RADIUS AV pairs">#14</a> 0x00007f02f22f657e in connectDBComplete (conn=0xfe1150) at fe-connect.c:1596<br>
        flag = <br>
        finish_time = -1<br>
<a href="https://github.com/kamailio/kamailio/issues/15" class="issue-link" title='ERROR: topoh  th_mask_decode(): invalid input  string"1-4289383-6930886-1692777-3284@127.0.1.1" '>#15</a> 0x00007f02f22f72bf in PQconnectdbParams (keywords=, values=, expand_dbname=) at fe-connect.c:462<br>
        conn = 0xfe1150<br>
<a href="https://github.com/kamailio/kamailio/pull/16" class="issue-link" title="modules/cdp: added src_addr parameter in peer definition">#16</a> 0x00007f02eeefe8e7 in db_postgres_new_connection (id=0x7f02ef203850) at km_pg_con.c:105<br>
        ptr = 0x7f02ef26fd10<br>
        ports = 0x0<br>
        i = 4<br>
        keywords = {0x7f02eef21e24 "host", 0x7f02eef21e29 "dbname", 0x7f02eef21e30 "user", 0x7f02eef21e35 "password", 0x0, <br>
          0x7f02eeabc844 "H\213E\310H\213\020H\213E\270\213@\bH\230H\215\004\002\306", 0x7f02ef1e2a28 "postgres", 0x7f02ef1e2a28 "postgres", <br>
          0x415db0 "1\355I\211\321^H\211\342H\203\344\360PTI\307\300\060Tn", 0x1268c34a540 </strong></p><strong>}<br>
        values = {0x7f02ef150788 "localhost", 0x7f02ef151338 "asterisk", 0x7f02ef2009b8 "asterisk", 0x7f02ef14fa48 "password", 0x0, 0x7f02ef203850 "\230\070 \357\002\177", <br>
          0x7f02ef12d268 "", 0x0, 0x500000011 </strong><strong>, 0x260000002f </strong><strong>}<br>
        to = "\343S\026\357\002\177\000\000\210\070 \357\002\177\000"<br>
        __FUNCTION</strong> = "db_postgres_new_connection"<br>
#17 0x00007f02eeab7927 in db_do_init2 (url=0x7f02ef165488, new_connection=0x7f02eeefd272 , pooling=DB_POOLING_PERMITTED) at db.c:312<br>
        id = 0x7f02ef203850<br>
        con = 0x0<br>
        res = 0x7f02ef1723b0<br>
        con_size = 32<br>
        <strong>FUNCTION</strong> = "db_do_init2"<br>
#18 0x00007f02eeab69b4 in db_do_init (url=0x7f02ef165488, new_connection=0x7f02eeefd272 ) at db.c:265<br>
No locals.<br>
#19 0x00007f02eeeef4f2 in db_postgres_init (<em>url=0x7f02ef165488) at km_dbase.c:137<br>
No locals.<br>
<a href="https://github.com/kamailio/kamailio/pull/20" class="issue-link" title="test/travis: move travis scripts to tests/travis">#20</a> 0x00007f02ee89ab3b in sql_connect () at sql_api.c:160<br>
        sc = 0x7f02ef165470<br>
        __FUNCTION_</em> = "sql_connect"<br>
#21 0x00007f02ee8a966a in child_init (rank=6) at sqlops.c:146<br>
No locals.<br>
#22 0x0000000000594061 in init_mod_child (m=0x7f02ef151ff8, rank=6) at sr_module.c:898<br>
        <strong>FUNCTION</strong> = "init_mod_child"<br>
#23 0x0000000000593d9c in init_mod_child (m=0x7f02ef152538, rank=6) at sr_module.c:895<br>
        <strong>FUNCTION</strong> = "init_mod_child"<br>
#24 0x0000000000593d9c in init_mod_child (m=0x7f02ef152760, rank=6) at sr_module.c:895<br>
        <strong>FUNCTION</strong> = "init_mod_child"<br>
#25 0x0000000000593d9c in init_mod_child (m=0x7f02ef152e38, rank=6) at sr_module.c:895<br>
        <strong>FUNCTION</strong> = "init_mod_child"<br>
#26 0x0000000000593d9c in init_mod_child (m=0x7f02ef153400, rank=6) at sr_module.c:895<br>
        <strong>FUNCTION</strong> = "init_mod_child"<br>
#27 0x0000000000593d9c in init_mod_child (m=0x7f02ef154ce0, rank=6) at sr_module.c:895<br>
        <strong>FUNCTION</strong> = "init_mod_child"<br>
#28 0x0000000000593d9c in init_mod_child (m=0x7f02ef1557e8, rank=6) at sr_module.c:895<br>
        <strong>FUNCTION</strong> = "init_mod_child"<br>
#29 0x0000000000593d9c in init_mod_child (m=0x7f02ef155cf8, rank=6) at sr_module.c:895<br>
        <strong>FUNCTION</strong> = "init_mod_child"<br>
#30 0x0000000000593d9c in init_mod_child (m=0x7f02ef156670, rank=6) at sr_module.c:895<br>
        <strong>FUNCTION</strong> = "init_mod_child"<br>
#31 0x0000000000593d9c in init_mod_child (m=0x7f02ef15b600, rank=6) at sr_module.c:895<br>
        <strong>FUNCTION</strong> = "init_mod_child"<br>
#32 0x0000000000593d9c in init_mod_child (m=0x7f02ef15ba20, rank=6) at sr_module.c:895<br>
        <strong>FUNCTION</strong> = "init_mod_child"<br>
#33 0x0000000000593d9c in init_mod_child (m=0x7f02ef15bcf8, rank=6) at sr_module.c:895<br>
        <strong>FUNCTION</strong> = "init_mod_child"<br>
#34 0x0000000000593d9c in init_mod_child (m=0x7f02ef15c438, rank=6) at sr_module.c:895<br>
        <strong>FUNCTION</strong> = "init_mod_child"<br>
#35 0x0000000000593d9c in init_mod_child (m=0x7f02ef15d120, rank=6) at sr_module.c:895<br>
        <strong>FUNCTION</strong> = "init_mod_child"<br>
#36 0x0000000000593d9c in init_mod_child (m=0x7f02ef15da48, rank=6) at sr_module.c:895<br>
        <strong>FUNCTION</strong> = "init_mod_child"<br>
#37 0x0000000000593d9c in init_mod_child (m=0x7f02ef15df68, rank=6) at sr_module.c:895<br>
        <strong>FUNCTION</strong> = "init_mod_child"<br>
#38 0x0000000000593d9c in init_mod_child (m=0x7f02ef15e2e0, rank=6) at sr_module.c:895<br>
        <strong>FUNCTION</strong> = "init_mod_child"<br>
#39 0x0000000000593d9c in init_mod_child (m=0x7f02ef15e7b8, rank=6) at sr_module.c:895<br>
        <strong>FUNCTION</strong> = "init_mod_child"<br>
#40 0x0000000000593d9c in init_mod_child (m=0x7f02ef15fd30, rank=6) at sr_module.c:895<br>
        <strong>FUNCTION</strong> = "init_mod_child"<br>
#41 0x0000000000593d9c in init_mod_child (m=0x7f02ef160230, rank=6) at sr_module.c:895<br>
        <strong>FUNCTION</strong> = "init_mod_child"<br>
#42 0x0000000000593d9c in init_mod_child (m=0x7f02ef160568, rank=6) at sr_module.c:895<br>
        <strong>FUNCTION</strong> = "init_mod_child"<br>
#43 0x0000000000593d9c in init_mod_child (m=0x7f02ef160ad8, rank=6) at sr_module.c:895<br>
        <strong>FUNCTION</strong> = "init_mod_child"<br>
#44 0x0000000000593d9c in init_mod_child (m=0x7f02ef160f30, rank=6) at sr_module.c:895<br>
        <strong>FUNCTION</strong> = "init_mod_child"<br>
#45 0x0000000000593d9c in init_mod_child (m=0x7f02ef162eb0, rank=6) at sr_module.c:895<br>
        <strong>FUNCTION</strong> = "init_mod_child"<br>
#46 0x0000000000593d9c in init_mod_child (m=0x7f02ef163228, rank=6) at sr_module.c:895<br>
        <strong>FUNCTION</strong> = "init_mod_child"<br>
#47 0x0000000000593d9c in init_mod_child (m=0x7f02ef1637b0, rank=6) at sr_module.c:895<br>
        <strong>FUNCTION</strong> = "init_mod_child"<br>
#48 0x0000000000593d9c in init_mod_child (m=0x7f02ef163af0, rank=6) at sr_module.c:895<br>
        <strong>FUNCTION</strong> = "init_mod_child"<br>
#49 0x0000000000593d9c in init_mod_child (m=0x7f02ef164628, rank=6) at sr_module.c:895<br>
        <strong>FUNCTION</strong> = "init_mod_child"<br>
#50 0x0000000000593d9c in init_mod_child (m=0x7f02ef1649e0, rank=6) at sr_module.c:895<br>
        <strong>FUNCTION</strong> = "init_mod_child"<br>
#51 0x000000000059436b in init_child (rank=6) at sr_module.c:924<br>
No locals.<br>
#52 0x00000000004ea7d4 in fork_process (child_id=6, desc=0x7fff8c34a210 "udp receiver child=1 sock=127.0.0.1:5060", make_sock=1) at pt.c:327<br>
        pid = 0<br>
        child_process_no = 6<br>
        ret = -1<br>
        new_seed1 = 436139511<br>
        new_seed2 = 2008969640<br>
        sockfd = {19, 20}<br>
        <strong>FUNCTION</strong> = "fork_process"<br>
#53 0x00000000004a7cae in main_loop () at main.c:1563<br>
        i = 1<br>
        pid = 1500<br>
        si = 0x7f02ef14f4d0<br>
        si_desc = "udp receiver child=1 sock=127.0.0.1:5060\000\344\255\252\002\177\000\000\200\242\064\214\377\177\000\000+\216N\000\000\000\000\000\001\000\000\000\377\177\000\000\260\062\335\252\002\177\000\000\220a\324\352\002\177\000\000\022\000\000\000\002\177\000\000\360\065\324\352\002\177\000\000\003\000\000\000\001\000\000\000\320\242\064\214\377\177\000\000\340\020\000\020\000\000\000"<br>
        nrprocs = 4<br>
        <strong>FUNCTION</strong> = "main_loop"<br>
#54 0x00000000004ae302 in main (argc=11, argv=0x7fff8c34a548) at main.c:2533<br>
        cfg_stream = 0xf6b010<br>
        c = -1<br>
        r = 0<br>
        tmp = 0x7fff8c34af10 ""<br>
        tmp_len = 0<br>
        port = -1<br>
        proto = 0<br>
        options = 0x704fe8 ":f:cm:M:dVIhEeb:l:L:n:vKrRDTN:W:w:t:u:g:P:G:SQ:O:a:A:"<br>
        ret = -1<br>
        seed = 3091819154<br>
        rfd = 4<br>
        debug_save = 0<br>
        debug_flag = 0<br>
        dont_fork_cnt = 0<br>
        n_lst = 0x40d892<br>
        p = 0x1 <br>
        <strong>FUNCTION</strong> = "main"<p></p>

<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">—<br>Reply to this email directly or <a href="https://github.com/kamailio/kamailio/issues/292">view it on GitHub</a>.<img alt="" height="1" src="https://github.com/notifications/beacon/AF36ZahrZiw98zySJZZj98cSLwAhz-yMks5oo4wpgaJpZM4Ft36B.gif" width="1" /></p>
<div itemscope itemtype="http://schema.org/EmailMessage">
<div itemprop="action" itemscope itemtype="http://schema.org/ViewAction">
  <link itemprop="url" href="https://github.com/kamailio/kamailio/issues/292"></link>
  <meta itemprop="name" content="View Issue"></meta>
</div>
<meta itemprop="description" content="View this Issue on GitHub"></meta>
</div>