### Description -- Hello Team, We are using Kamailio 5.4.7 and we found there is a random crash. We have observed the core logs and we noticed it is due to some of the RPC events. We have noticed it has been crashed from the "ctl handler" process.
--
#### Debugging Data --
Core dump files are attached.
[core-7519.txt](https://github.com/kamailio/kamailio/files/9099633/core-7519.txt) [core-17582.txt](https://github.com/kamailio/kamailio/files/9099634/core-17582.txt) [core-7519.txt](https://github.com/kamailio/kamailio/files/9099638/core-7519.txt) [core-17582.txt](https://github.com/kamailio/kamailio/files/9099639/core-17582.txt) --
### Additional Information
* **Kamailio Version** - output of `kamailio -v`
``` version: kamailio 5.4.7 (x86_64/linux) a19fe1 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: a19fe1 compiled on 02:56:57 Feb 16 2022 with gcc 8.3.0 ```
I have updated the more information to review it. any help will be more appriciable.
It is crashing because current->mname is NULL. I dont know how it could be NULL but will try to figure it out.
Suggestion : I think we should check if current->mname is not NULL before strcmp for protection from crash
``` static int rpc_mod_is_printed_one(mem_counter *stats, mem_counter *current) { mem_counter *iter = stats;
while (iter && iter != current) { if (strcmp(iter->mname, current->mname) == 0) { return 1; } iter = iter->next; }
return 0; } ```
https://github.com/kamailio/kamailio/blob/c5d48f8ee3884934bd8b910a2dae1888fe...
@miconda Can you please help me with some direction to debug this issue ? And do you agree with my suggestion to add protection ?
@sagarmalam: you can make a PR to add the protection, but before the `while`, makes no sense to go in and only iterate. Eventually add a LM_ERR() to report that the field is null, which should not happen.
Safety checks added.
Closed #3186 as completed.