Mercury109 created an issue (kamailio/kamailio#4386)

### Description

I have KEMI python script that gets dialog variables inside the dialog event 
route for some processing, and it's been working fine for a very long time. 
Recently I changed timer_procs from 0 to 4 in the **HTable** module and now 
Kamailio sometimes crashes (rare) while trying to access a dialog variable 
inside of event_route[dialog:failed] due to a race condition where it's already 
freed.

modparam("htable", "timer_procs", 4) # The param that was changed from 0 to 4

My guess is that dlg_timer_routine() is being called by these timer processes 
that were intended for htable and dialog module isn't concurrency-safe. 

### Logs

[3024293]: ALERT: <core> [main.c:792]: handle_sigs(): child process 3024324 
exited by a signal 11

[3024327]: CRITICAL: <core> [core/pass_fd.c:281]: receive_fd(): EOF on 43

[3024303]: CRITICAL: <core> [core/mem/q_malloc.c:535]: qm_free(): BUG: freeing 
already freed pointer (0x7fa08f3d43a0), called from dialog: dlg_hash.c: 
destroy_dlg(408), first free dialog: dlg_hash.c: destroy_dlg(410) - ignoring

[3024303]: CRITICAL: <core> [core/mem/q_malloc.c:515]: qm_free(): BUG: bad 
pointer 0xc0c0c0c0 (out of memory block!) called from dialog: dlg_hash.c: 
destroy_dlg(409) - ignoring

[3024303]: CRITICAL: <core> [core/mem/q_malloc.c:515]: qm_free(): BUG: bad 
pointer 0x646f635f30353871 (out of memory block!) called from dialog: 
dlg_hash.c: destroy_dlg(408) - ignoring

--------------- Core Dump -------

#0  get_dlg_variable_unsafe (dlg=dlg@entry=0x7fa0916208c0, 
key=key@entry=0x7ffeb70d1f68) at ./src/modules/dialog/dlg_var.c:246
        var = 0x8
        var_list = <optimized out>
#1  0x00007fa0bd808b83 in get_dlg_varref (dlg=dlg@entry=0x7fa0916208c0, 
key=key@entry=0x7ffeb70d1f68) at ./src/modules/dialog/dlg_var.c:304
        var = 0x0
        __func__ = "get_dlg_varref"
#2  0x00007fa0bd78c624 in ki_dlg_var_get_mode (msg=<optimized out>, 
name=0x7ffeb70d1f68, rmode=0) at ./src/modules/dialog/dialog.c:2446
        dlg = 0x7fa0916208c0
        pval = <optimized out>


### Additional Information

version: kamailio 5.7.6 (x86_64/linux) 
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_URI_SIZE 1024, 
BUF_SIZE 65535, DEFAULT PKG_SIZE 8MB
poll method support: poll, epoll_lt, epoll_et, sigio_rt, select.
id: unknown 
compiled with gcc 12.2.0


* **Operating System**:*

Debain 12



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

Message ID: <kamailio/kamailio/issues/[email protected]>
_______________________________________________
Kamailio - Development Mailing List -- [email protected]
To unsubscribe send an email to [email protected]
Important: keep the mailing list in the recipients, do not reply only to the 
sender!

Reply via email to