<h4 dir="auto">Pre-Submission Checklist</h4>



<ul class="contains-task-list">
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> Commit message has the format required by CONTRIBUTING guide</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> Commits are split per component (core, individual modules, libs, utils, ...)</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> Each component has a single commit (if not, squash them into one commit)</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> No commits to README files for modules (changes must be done to docbook files<br>
in <code>doc/</code> subfolder, the README file is autogenerated)</li>
</ul>
<h4 dir="auto">Type Of Change</h4>
<ul class="contains-task-list">
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> Small bug fix (non-breaking change which fixes an issue)</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox"> New feature (non-breaking change which adds new functionality)</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox"> Breaking change (fix or feature that would change existing functionality)</li>
</ul>
<h4 dir="auto">Checklist:</h4>

<ul class="contains-task-list">
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox"> PR should be backported to stable branches</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox"> Tested changes locally</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox"> Related to issue #XXXX (replace XXXX with an open issue number)</li>
</ul>
<h4 dir="auto">Description</h4>

<p dir="auto">Setup: uac_req_send() with evroute=2 and tm module enable_uac_fr=1</p>
<p dir="auto">Noticed following shm errors while intensively testing uac_req_send(), happening quite soon after a fresh restart (e.g. 10 min):</p>
<div class="snippet-clipboard-content position-relative overflow-auto" data-snippet-clipboard-copy-content="kamailio[5384]: ERROR: <core> [core/mem/q_malloc.c:297]: qm_find_free(): qm_find_free(0x7fe8943bc000, 40632); Free fragment not found!
kamailio[5384]: ERROR: <core> [core/mem/q_malloc.c:430]: qm_malloc(): qm_malloc(0x7fe8943bc000, 40632) called from uac: uac_send.c: uac_send_info_clone(105), module: uac; Free fragment not found!
kamailio[5384]: ERROR: uac [uac_send.c:108]: uac_send_info_clone(): no more shm memory
kamailio[5384]: ERROR: uac [uac_send.c:837]: uac_req_send(): cannot clone the uac structure"><pre><code>kamailio[5384]: ERROR: <core> [core/mem/q_malloc.c:297]: qm_find_free(): qm_find_free(0x7fe8943bc000, 40632); Free fragment not found!
kamailio[5384]: ERROR: <core> [core/mem/q_malloc.c:430]: qm_malloc(): qm_malloc(0x7fe8943bc000, 40632) called from uac: uac_send.c: uac_send_info_clone(105), module: uac; Free fragment not found!
kamailio[5384]: ERROR: uac [uac_send.c:108]: uac_send_info_clone(): no more shm memory
kamailio[5384]: ERROR: uac [uac_send.c:837]: uac_req_send(): cannot clone the uac structure
</code></pre></div>
<p dir="auto">I tried monitoring system memory using <code>free</code> tool and noticed that the "used" memory didn't grow alot. However, I noticed the "buff/cached" memory had a steep growth when 200OK(s) started to come, for my setup.</p>
<p dir="auto">Noticed that, for my setup, when 200OK come, event_route[uac:reply] is not called, so the tm callback set by UAC module is not called. => the "tp" callback parameter shm allocated by UAC module is not freed.</p>
<p dir="auto">By analogy, when using uac_req_send() with evroute=1 and timeout happens (e.g. no reply comes), event_route[uac:reply] won't be called and same leak should happen => <em>i didn;t tested that</em>, was just an analogy.</p>
<p dir="auto">I updated the code to call the callback on TMCB_DESTROY, and make sure tp parameter is freed, <em>one time</em>.</p>
<p dir="auto">Let me know what you think of this... in my setup/tests I got no kamailio shm logs anymore. Also "buff/cached" memory didn't have that steep growth anymore.</p>
<p dir="auto">Thank you,<br>
Stefan</p>

<hr>

<h4>You can view, comment on, or merge this pull request online at:</h4>
<p>  <a href='https://github.com/kamailio/kamailio/pull/3065'>https://github.com/kamailio/kamailio/pull/3065</a></p>

<h4>Commit Summary</h4>
<ul>
  <li><a href="https://github.com/kamailio/kamailio/pull/3065/commits/26aaa6d5874124151b96198c5f52912764ff13fb" class="commit-link">26aaa6d</a>  uac: fix shm leak</li>
</ul>

<h4 style="display: inline-block">File Changes </h4> <p style="display: inline-block">(<a href="https://github.com/kamailio/kamailio/pull/3065/files">1 file</a>)</p>
<ul>
  <li>
    <strong>M</strong>
    <a href="https://github.com/kamailio/kamailio/pull/3065/files#diff-987b7b19405f750ebdfcec5e8fa6e5b557c8f2a1e1935e7f5b500d1a0717304b">src/modules/uac/uac_send.c</a>
    (14)
  </li>
</ul>

<h4>Patch Links:</h4>
<ul>
  <li><a href='https://github.com/kamailio/kamailio/pull/3065.patch'>https://github.com/kamailio/kamailio/pull/3065.patch</a></li>
  <li><a href='https://github.com/kamailio/kamailio/pull/3065.diff'>https://github.com/kamailio/kamailio/pull/3065.diff</a></li>
</ul>

<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">—<br />Reply to this email directly, <a href="https://github.com/kamailio/kamailio/pull/3065">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe-auth/ABO7UZMHFJZFMLQOBTSF5O3VBVS75ANCNFSM5RTK3O6A">unsubscribe</a>.<br />You are receiving this because you are subscribed to this thread.<img src="https://github.com/notifications/beacon/ABO7UZM2GWVEJK3IYPCSEXLVBVS75A5CNFSM5RTK3O6KYY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4RS4BRVQ.gif" height="1" width="1" alt="" /><span style="color: transparent; font-size: 0; display: none; visibility: hidden; overflow: hidden; opacity: 0; width: 0; height: 0; max-width: 0; max-height: 0; mso-hide: all">Message ID: <span><kamailio/kamailio/pull/3065</span><span>@</span><span>github</span><span>.</span><span>com></span></span></p>
<script type="application/ld+json">[
{
"@context": "http://schema.org",
"@type": "EmailMessage",
"potentialAction": {
"@type": "ViewAction",
"target": "https://github.com/kamailio/kamailio/pull/3065",
"url": "https://github.com/kamailio/kamailio/pull/3065",
"name": "View Pull Request"
},
"description": "View this Pull Request on GitHub",
"publisher": {
"@type": "Organization",
"name": "GitHub",
"url": "https://github.com"
}
}
]</script>