### Description

Build kamailio master branch and define `TLS_MALLOC_DBG` in the `tls` module.
There is an immediate segfault on startup.

### Troubleshooting

Build kamailio master branch without `TLS_MALLOC_DBG` in the `tls` module.
kamailio can start normally.

#### Reproduction

* use a distro with OpenSSL 3, e.g., AlmaLinux 9, Debian 12
* checkout kamailio master branch
* in `src/modules/tls/tls_init.c` define `TLS_MALLOC_DBG`
* build and run kamailio


#### Debugging Data

```
Program terminated with signal SIGSEGV, Segmentation fault.
#0  0x0000000000000000 in ?? ()
(gdb) bt
#0  0x0000000000000000 in ?? ()
#1  0x00007efcca8f59ac in ser_malloc (size=56, file=0x7efc8a3399e3 
"crypto/threads_pthread.c", line=50) at tls_init.c:269
#2  0x00007efc8a1b0b6e in CRYPTO_zalloc (num=56, file=<optimized out>, 
line=<optimized out>) at crypto/mem.c:197
#3  0x00007efc8a1bd7b4 in CRYPTO_THREAD_lock_new () at 
crypto/threads_pthread.c:50
#4  0x00007efc8a1b38cd in ossl_init_base () at crypto/init.c:64
#5  ossl_init_base_ossl_ () at crypto/init.c:55
#6  0x00007efcca6a4a48 in __pthread_once_slow (once_control=0x7efc8a42db84 
<base>, init_routine=0x7efc8a1b38c0 <ossl_init_base_ossl_>)
    at pthread_once.c:117
#7  0x00007efc8a1bd92d in CRYPTO_THREAD_run_once (once=<optimized out>, 
init=<optimized out>) at crypto/threads_pthread.c:156
#8  0x00007efc8a1b823a in OPENSSL_init_crypto (settings=0x0, opts=131148) at 
crypto/init.c:507
#9  OPENSSL_init_crypto (opts=opts@entry=131148, settings=0x0) at 
crypto/init.c:462
#10 0x00007efcca84edf7 in OPENSSL_init_ssl (settings=<optimized out>, 
opts=131148) at ssl/ssl_init.c:115
#11 OPENSSL_init_ssl (opts=<optimized out>, settings=<optimized out>) at 
ssl/ssl_init.c:91
#12 0x00007efcca8f88ec in tls_h_mod_pre_init_f () at tls_init.c:767
#13 0x00000000006e5524 in pre_init_tls () at core/tls_hooks.c:68
#14 0x00000000004389d4 in main (argc=11, argv=0x7ffcb25aae08) at main.c:3141
```

### Additional Information

  * **Kamailio Version** - output of `kamailio -v`

```
version: kamailio 5.8.0-dev1 (x86_64/linux) cd6d03
flags: USE_TCP, USE_TLS, USE_SCTP, TLS_HOOKS, USE_RAW_SOCKS, DISABLE_NAGLE, 
USE_MCAST, DNS_IP_HACK, SHM_MMAP, PKG_MALLOC, MEM_JOIN_FREE, 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_BLOCKLIST, HAVE_RESOLV_RES, 
TLS_PTHREAD_MUTEX_SHARED
ADAPTIVE_WAIT_LOOPS 1024, MAX_RECV_BUFFER_SIZE 262144, MAX_SEND_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: cd6d03 
compiled on 08:53:04 Oct  7 2023 with gcc 11.3.1
```

* **Operating System**:

```
NAME="AlmaLinux"
VERSION="9.2 (Turquoise Kodkod)"
ID="almalinux"
ID_LIKE="rhel centos fedora"
VERSION_ID="9.2"
PLATFORM_ID="platform:el9"
PRETTY_NAME="AlmaLinux 9.2 (Turquoise Kodkod)"
ANSI_COLOR="0;34"
LOGO="fedora-logo-icon"
CPE_NAME="cpe:/o:almalinux:almalinux:9::baseos"
HOME_URL="https://almalinux.org/";
DOCUMENTATION_URL="https://wiki.almalinux.org/";
BUG_REPORT_URL="https://bugs.almalinux.org/";

ALMALINUX_MANTISBT_PROJECT="AlmaLinux-9"
ALMALINUX_MANTISBT_PROJECT_VERSION="9.2"
REDHAT_SUPPORT_PRODUCT="AlmaLinux"
REDHAT_SUPPORT_PRODUCT_VERSION="9.2"

5.14.0-284.30.1.el9_2.x86_64 #1 SMP PREEMPT_DYNAMIC Tue Sep 12 09:28:32 EDT 
2023 x86_64 x86_64 x86_64 GNU/Linux
```


-- 
Reply to this email directly or view it on GitHub:
https://github.com/kamailio/kamailio/issues/3595
You are receiving this because you are subscribed to this thread.

Message ID: <kamailio/kamailio/issues/3...@github.com>
_______________________________________________
Kamailio (SER) - Development Mailing List
To unsubscribe send an email to sr-dev-le...@lists.kamailio.org

Reply via email to