<p></p>

<h3>Description</h3>
<p>Kamailio crashes on launch with TLS enabled on both Ubuntu 20.04 and Debian Buster.</p>
<h3>Troubleshooting</h3>
<h4>Reproduction</h4>

<ol>
<li>cloned <code>https://github.com/kamailio/kamailio</code></li>
<li>checked out <code>5.4</code></li>
<li>make cfg</li>
<li>include_modules=app_python3 crypto db_mongodb<br>
db_postgres dialplan http_async_client<br>
http_client jansson json jsonrpcc log_systemd<br>
outbound regex tls utils xcap_client xhttp_pi<br>
uuid</li>
<li>make all</li>
<li>make install</li>
<li>make install-systemd-debian</li>
<li>turn on TLS (WITH_TLS), copy certs & keys.</li>
<li>sudo systemctl start kamailio</li>
</ol>
<h4>Log Messages</h4>
<pre><code>Nov 20 00:20:06 kamailio-stage-3 /usr/local/sbin/kamailio[12570]: INFO: tls [tls_mod.c:389]: mod_init(): With ECDH-Support!
Nov 20 00:20:06 kamailio-stage-3 /usr/local/sbin/kamailio[12570]: INFO: tls [tls_mod.c:392]: mod_init(): With Diffie Hellman
Nov 20 00:20:06 kamailio-stage-3 kamailio[12569]: DIGEST-MD5 common mech free
Nov 20 00:20:06 kamailio-stage-3 /usr/local/sbin/kamailio[12570]: INFO: auth [auth_mod.c:345]: mod_init(): qop set, but nonce-count (nonce_count) support disabled
Nov 20 00:20:06 kamailio-stage-3 /usr/local/sbin/kamailio[12570]: INFO: rr [../outbound/api.h:52]: ob_load_api(): unable to import bind_ob - maybe module is not loaded
Nov 20 00:20:06 kamailio-stage-3 /usr/local/sbin/kamailio[12570]: INFO: rr [rr_mod.c:185]: mod_init(): outbound module not available
Nov 20 00:20:06 kamailio-stage-3 kamailio[12568]: ERROR: <core> [core/daemonize.c:303]: daemonize(): Main process exited before writing to pipe
Nov 20 00:20:06 kamailio-stage-3 kamailio[12568]: CRITICAL: <core> [core/mem/q_malloc.c:519]: qm_free(): BUG: freeing already freed pointer (0x7f09fdb43de8), called from tls: tls_init.c: ser_free(323), first free tls: tls_init.c: ser_free(323) - ignoring
Nov 20 00:20:06 kamailio-stage-3 kamailio[12568]: CRITICAL: <core> [core/mem/q_malloc.c:519]: qm_free(): BUG: freeing already freed pointer (0x7f09fdb44098), called from tls: tls_init.c: ser_free(323), first free tls: tls_init.c: ser_malloc(293) - ignoring
Nov 20 00:20:06 kamailio-stage-3 kamailio[12568]: CRITICAL: <core> [core/mem/q_malloc.c:519]: qm_free(): BUG: freeing already freed pointer (0x7f09fdb94230), called from tls: tls_init.c: ser_free(323), first free tls: tls_init.c: ser_free(323) - ignoring
Nov 20 00:20:06 kamailio-stage-3 kamailio[12568]: CRITICAL: <core> [core/mem/q_malloc.c:519]: qm_free(): BUG: freeing already freed pointer (0x7f09fdb41890), called from tls: tls_init.c: ser_free(323), first free tls: tls_init.c: ser_free(323) - ignoring
Nov 20 00:20:06 kamailio-stage-3 kamailio[12568]: CRITICAL: <core> [core/mem/q_malloc.c:519]: qm_free(): BUG: freeing already freed pointer (0x7f09fdb34998), called from tls: tls_init.c: ser_free(323), first free tls: tls_init.c: ser_free(323) - ignoring
Nov 20 00:20:06 kamailio-stage-3 kamailio[12568]: CRITICAL: <core> [core/mem/q_malloc.c:519]: qm_free(): BUG: freeing already freed pointer (0x7f09fdb347b8), called from tls: tls_init.c: ser_free(323), first free tls: tls_init.c: ser_free(323) - ignoring
Nov 20 00:20:06 kamailio-stage-3 kamailio[12568]: CRITICAL: <core> [core/mem/q_malloc.c:519]: qm_free(): BUG: freeing already freed pointer (0x7f09fdb34858), called from tls: tls_init.c: ser_free(323), first free tls: tls_init.c: ser_malloc(293) - ignoring
Nov 20 00:20:06 kamailio-stage-3 kamailio[12568]: CRITICAL: <core> [core/mem/q_malloc.c:519]: qm_free(): BUG: freeing already freed pointer (0x7f09fdb348f8), called from tls: tls_init.c: ser_free(323), first free tls: tls_init.c: ser_malloc(293) - ignoring
Nov 20 00:20:06 kamailio-stage-3 systemd[1]: kamailio.service: Control process exited, code=killed, status=11/SEGV
Nov 20 00:20:06 kamailio-stage-3 systemd[1]: kamailio.service: Failed with result 'signal'.
Nov 20 00:20:06 kamailio-stage-3 systemd[1]: Failed to start kamailio (OpenSER) - the Open Source SIP Server.
Nov 20 00:20:06 kamailio-stage-3 systemd[1]: kamailio.service: Service RestartSec=100ms expired, scheduling restart.
Nov 20 00:20:06 kamailio-stage-3 systemd[1]: kamailio.service: Scheduled restart job, restart counter is at 57.
Nov 20 00:20:06 kamailio-stage-3 systemd[1]: Stopped kamailio (OpenSER) - the Open Source SIP Server.
Nov 20 00:20:06 kamailio-stage-3 systemd[1]: kamailio.service: Start request repeated too quickly.
Nov 20 00:20:06 kamailio-stage-3 systemd[1]: kamailio.service: Failed with result 'signal'.
Nov 20 00:20:06 kamailio-stage-3 systemd[1]: Failed to start kamailio (OpenSER) - the Open Source SIP Server.
</code></pre>
<h3>Possible Solutions</h3>
<p>As a hack, we manually downgraded to <a href="https://www.openssl.org/source/openssl-1.0.2r.tar.gz" rel="nofollow">https://www.openssl.org/source/openssl-1.0.2r.tar.gz</a> and that seemed to allow the system to launch, but this is obviously not a stable, long-term solution.</p>
<h3>Additional Information</h3>
<ul>
<li><strong>Kamailio Version</strong> - output of <code>kamailio -v</code></li>
</ul>
<pre><code>version: kamailio 5.4.2 (x86_64/linux) 2d733e
flags: USE_TCP, USE_TLS, USE_SCTP, TLS_HOOKS, USE_RAW_SOCKS, DISABLE_NAGLE, USE_MCAST, DNS_IP_HACK, 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, TLS_PTHREAD_MUTEX_SHARED
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: 2d733e 
compiled on 23:01:51 Nov 19 2020 with gcc 8.3.0
</code></pre>
<ul>
<li><strong>Operating System</strong>:</li>
</ul>

<pre><code>root@kamailio-stage-3:/home/admin# lsb_release -a
No LSB modules are available.
Distributor ID: Debian
Description:    Debian GNU/Linux 10 (buster)
Release:        10
Codename:       buster
root@kamailio-stage-3:/home/admin# uname -a
Linux kamailio-stage-3 4.19.0-12-cloud-amd64 #1 SMP Debian 4.19.152-1 (2020-10-18) x86_64 GNU/Linux

ubuntu@kamailio-stage-2:~$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 20.04.1 LTS
Release:        20.04
Codename:       focal
ubuntu@kamailio-stage-2:~$ uname -a
Linux kamailio-stage-2 5.4.0-1029-aws #30-Ubuntu SMP Tue Oct 20 10:06:38 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
</code></pre>

<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">—<br />You are receiving this because you are subscribed to this thread.<br />Reply to this email directly, <a href="https://github.com/kamailio/kamailio/issues/2560">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe-auth/ABO7UZJQZJNNGOA7WK47HGTSRQHP5ANCNFSM4UBLKL6A">unsubscribe</a>.<img src="https://github.com/notifications/beacon/ABO7UZL5LKKQS3VRD7RQGBLSRQHP5A5CNFSM4UBLKL6KYY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4LFUIKCQ.gif" height="1" width="1" alt="" /></p>
<script type="application/ld+json">[
{
"@context": "http://schema.org",
"@type": "EmailMessage",
"potentialAction": {
"@type": "ViewAction",
"target": "https://github.com/kamailio/kamailio/issues/2560",
"url": "https://github.com/kamailio/kamailio/issues/2560",
"name": "View Issue"
},
"description": "View this Issue on GitHub",
"publisher": {
"@type": "Organization",
"name": "GitHub",
"url": "https://github.com"
}
}
]</script>