### Description
Calling functions from the `dialplan` module in 5.8 (`dp_translate()`, `dp_match()`) results in the following line being logged:
``` WARNING: <core> [core/mem/q_malloc.c:520]: qm_free(): WARNING: free(0) called from dialplan: dp_db.c: pcre2_free(206) ```
Is this a functional problem, or just a case of overly aggressive logging?
### Troubleshooting
#### Reproduction Reproducible with the following kamailio config:
``` #!KAMAILIO
loadmodule "pv" loadmodule "db_sqlite" loadmodule "xlog" loadmodule "dialplan"
disable_tcp = true force_rport = true
!!define DBFILE /etc/kamailio/kamailio.sqlite
modparamx("db_sqlite","db_set_readonly", "$def(DBFILE)")
modparamx("dialplan","db_url", "sqlite:///$def(DBFILE)") modparam("dialplan", "attrs_pvar", "$avp(dp_attrs)")
request_route { if ( $rm == "ACK" ) { exit; }
xinfo("$ci New request\n");
dp_match("1", "$rU"); exit; } ```
The warning log is issued in 5.8 but not 5.7. Reproduced by sending a request with SIPp:
``` sipp -sn uac -m 1 -s 15554445555 localhost ```
### Possible Solutions
Not sure if this is just a case of logging being overly aggressive, or an issue with the module's memory management.
### Additional Information
* **Kamailio Version** - output of `kamailio -v`
``` version: kamailio 5.8.1 (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_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: unknown compiled with gcc 12.2.0 ```
Tested using docker `debian:12-slim` using the official packages from `http://deb.kamailio.org/kamailio58%60
* **Operating System**:
Docker debian:12-slim, but also observed in Alpine Linux/
Is there any indication if this is a functional problem, or just a case of logging that should be reduced - I'm trying to gauge if I should hold off before upgrading.
It is a warning, which should not be reduced or silenced. The memory manager emits this warning because its not used correctly, e.g. in the example above a free(0) was called. It should be investigated in the module. Its only warning level, so it might be not a serious issue.
I was able to "get around" that warning by changing the memory manager.
Not sure if this is the correct solution/workaround, but having the constant warnings in the logs seems wrong.
I added `-x fm -X fm` to the kamailio run command.
Any downside to this change?
I was able to "get around" that warning by changing the memory manager.
Not sure if this is the correct solution/workaround, but having the constant warnings in the logs seems wrong.
I added `-x fm -X fm` to the kamailio run command.
Any downside to this change?
Well, the issue is still there, the other memory manager just did not log a warning message for it. I personally would not recommend to switch to a much less used memory manager which might cause unknown issues for your workload just for getting rid of a few warnings. As said already, the issue needs to be analyzed in the dialplan module and fixed there. If you are annoyed from the warnings, just increase the log level to ERROR level for now.
Closed #3851 as completed via 630a6f2c11c10c4f3be3570553d86486942d60fe.
Hi @linuxmaniac , I was just trying out 5.8.2, which I should include this, and I am still getting the warning. May I be missing something, or could it be that the issue has a deeper root and the NULL check could be extended to `pcre2_free()` from `dp_db.c`? I am not familiar with libpcre2, so I am reluctant to propose a fix myself!
Problem still exists in 5.8.2. Can this issue be re-opened?
Reopened #3851.
Just want to add in that I have the same issue with 5.8.2 but with regex module itself.
WARNING: <core> [core/mem/q_malloc.c:520]: qm_free(): WARNING: free(0) called from regex: regex_mod.c: pcre2_free(173)
version: kamailio 5.8.2 (x86_64/linux) 3fa5f4
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: 3fa5f4 compiled on 16:16:53 Jun 18 2024 with gcc 12.2.0 $> lsb_release -a No LSB modules are available. Distributor ID: Debian Description: Debian GNU/Linux 12 (bookworm) Release: 12 Codename: bookworm
@giangi @whosgonna fixes pushed to master and 5.8. Can you please confirm fix works for you? tomorrow's nightly debs should contain the fixes
Thank you! I rerun my scenarios on the nightly deb `5.8.3~bpo12.20240719013235.39`, and I can confirm that the warnings are gone.
Thanks!
Closed #3851 as completed.