<!--
Kamailio Project uses GitHub Issues only for bugs in the code or feature 
requests. Please use this template only for bug reports.

If you have questions about using Kamailio or related to its configuration 
file, ask on sr-users mailing list:

  * 
https://lists.kamailio.org/mailman3/postorius/lists/sr-users.lists.kamailio.org/

If you have questions about developing extensions to Kamailio or its existing C 
code, ask on sr-dev mailing list:

  * 
https://lists.kamailio.org/mailman3/postorius/lists/sr-dev.lists.kamailio.org/

Please try to fill this template as much as possible for any issue. It helps 
the developers to troubleshoot the issue.

Note that an issue report may be closed automatically after about 2 months
if there is no interest from developers or community users on pursuing it, being
considered expired. In such case, it can be reopened by writing a comment that 
includes
the token `/notexpired`. About two weeks before considered expired, the issue is
marked with the label `stale`, trying to notify the submitter and everyone else
that might be interested in it. To remove the label `stale`, write a comment 
that
includes the token `/notstale`. Also, any comment postpone the `expire` 
timeline,
being considered that there is interest in pursuing the issue.

If there is no content to be filled in a section, the entire section can be 
removed.

You can delete the comments from the template sections when filling.

You can delete next line and everything above before submitting (it is a 
comment).
-->

### Description
It seems that the fixup_free_* functions are not getting called when used with:

```
static cmd_export_t cmds[] = {
    {"acc_log_request", (cmd_function)w_acc_log_request, 1,
        acc_fixup, free_acc_fixup,
        ANY_ROUTE},
       // ...
{0, 0, 0, 0, 0, 0}
};

static int free_acc_fixup(void **param, int param_no)
{
    LM_CRIT("acc free fixup = %d\n", param_no);
   
    if(*param) {
        pkg_free(*param);
        *param = 0;
    }
    return 0;
}
```

Nothing is getting logged from the function.  Is this expected not to print in 
free_fixup due to the destruction of kamailio and the logging is not reliable? 

I also used gdb and added some breakpoints in `fixup` and  `free_fixup` 
functions in some other modules (file_out) and the breakpoint was only found in 
`fixup` but not in `free_fixup`.

When is the `free_fixup` supposed to be called, at kamailio destruction or 
after fixing it and before the main loop starts?

<!--
Explain what you did, what you expected to happen, and what actually happened.
-->

### Troubleshooting

#### Reproduction

<!--
If the issue can be reproduced, describe how it can be done.
-->
Use any module that has a custom (maybe also provided from core) `free_fixup` 
function, and monitor if  `free_fixup` is called using debug mode.

#### Log Messages

<!--
Check the syslog file and if there are relevant log messages printed by 
Kamailio, add them next, or attach to issue, or provide a link to download them 
(e.g., to a pastebin site).
-->

```
Apr 15 15:52:03 app01 kamailio[812169]: INFO: <core> [core/mem/q_malloc.c:402]: 
qm_malloc(): qm_malloc(0x7fcdcab18010, 56) called from file_out: file_out.c: 
fo_fixup_str_index(287)
Apr 15 15:52:03 app01 kamailio[812169]: INFO: <core> [core/mem/q_malloc.c:449]: 
qm_malloc(): qm_malloc(0x7fcdcab18010, 64) returns address 0x7fcdcacc4280 frag. 
0x7fcdcacc4240 (size=64) on 1 -th hit```

`0x7fcdcacc4240` fragment is not found anywhere in the logs reported that it 
was freed unlike other malloced resources.
```

### Additional Information

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

```
version: kamailio 5.9.0-dev0 (x86_64/linux) 8bc64a
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: 8bc64a 
compiled on 15:32:09 Apr 15 2024 with gcc 10.5.0
```

* **Operating System**:

<!--
Details about the operating system, the type: Linux (e.g.,: Debian 8.4, Ubuntu 
16.04, CentOS 7.1, ...), MacOS, xBSD, Solaris, ...;
Kernel details (output of `lsb_release -a` and `uname -a`)
-->

```
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 20.04.6 LTS
Release:        20.04
Codename:       focal

5.4.0-176-generic #196-Ubuntu SMP Fri Mar 22 16:46:39 UTC 2024 x86_64 x86_64 
x86_64 GNU/Linux

```


-- 
Reply to this email directly or view it on GitHub:
https://github.com/kamailio/kamailio/issues/3814
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