<p>Yes, the problem is happening for me because of pua_reginfo and I did <a href="https://github.com/linuxmaniac/kamailio/commit/2152b8c3ad4b1d61c4a456f7cb082ccfd10fe39c" class="commit-link">linuxmaniac@<tt>2152b8c</tt></a> in order to solve it. But even with that I still get ucontac at shared mem left.</p>
<p>I'm suspecting that the underlying problem is the combination of get_static_urecord() + ul_callbacks + get_static_urecord(). The urecord is the same and it gets freed twice so only the first ucontact is free and the other is leaked.</p>
<p>see <a href="https://github.com/kamailio/kamailio/issues/997#issuecomment-280377848" class="issue-link js-issue-link" data-url="https://github.com/kamailio/kamailio/issues/997" data-id="208099507" data-error-text="Failed to load issue title" data-permission-text="Issue title is private">#997 (comment)</a></p>
<p>REGISTER</p>
<pre><code>Feb 16 17:04:43 sp1 proxy[9687]: NOTICE: <script>: New request on proxy - M=REGISTER R=sip:192.168.1.71 F=sip:43993005@192.168.1.71 T=sip:43993005@192.168.1.71 IP=192.168.1.42:53152
 (127.0.0.1:5060) ID=8e40daa391b6e4d82b296c77eb0c6986@0.0.0.0 UA='Jitsi2.9.5521Linux'
Feb 16 17:04:43 sp1 proxy[9687]: DEBUG: usrloc [udomain.c:174]: get_static_urecord(): urecord static[0x7f7b41740200]
Feb 16 17:04:43 sp1 proxy[9687]: DEBUG: usrloc [ucontact.c:142]: new_ucontact(): new ucontact[0x7f7b315f1d08]
Feb 16 17:04:43 sp1 proxy[9687]: DEBUG: usrloc [udomain.c:1155]: get_urecord(): DB_ONLY urecord[0x7f7b41740200]
</code></pre>
<p><code>urecord static[0x7f7b41740200]</code> is called before ul_callbacks and <code>ucontact[0x7f7b315f1d08]</code> is created.</p>
<p>now pua_reginfo</p>
<pre><code>Feb 16 17:04:43 sp1 proxy[9687]: DEBUG: usrloc [udomain.c:174]: get_static_urecord(): urecord static[0x7f7b41740200]
Feb 16 17:04:43 sp1 proxy[9687]: DEBUG: usrloc [ucontact.c:142]: new_ucontact(): new ucontact[0x7f7b315f24f8]
Feb 16 17:04:43 sp1 proxy[9687]: DEBUG: usrloc [ucontact.c:142]: new_ucontact(): new ucontact[0x7f7b315f28f0]
Feb 16 17:04:43 sp1 proxy[9687]: DEBUG: usrloc [udomain.c:1155]: get_urecord(): DB_ONLY urecord[0x7f7b41740200]
</code></pre>
<p><code>get_urecord()</code> is called and the static <code>urecord[0x7f7b41740200]</code> is used and the new <code>ucontact[0x7f7b315f28f0]</code> and <code>ucontact[0x7f7b315f24f8]</code> are there.</p>
<p>This code has my fix so release_urecord() is called by pua_reginfo</p>
<pre><code>Feb 16 17:04:43 sp1 proxy[9687]: DEBUG: usrloc [urecord.c:553]: release_urecord(): free urecord[0x7f7b41740200]
Feb 16 17:04:43 sp1 proxy[9687]: DEBUG: usrloc [ucontact.c:179]: free_ucontact(): free ucontact[0x7f7b315f24f8]
Feb 16 17:04:43 sp1 proxy[9687]: DEBUG: usrloc [ucontact.c:179]: free_ucontact(): free ucontact[0x7f7b315f28f0]
</code></pre>
<p>and <code>ucontact[0x7f7b315f28f0]</code> and <code>ucontact[0x7f7b315f24f8]</code> are freed, perfect, but after the ul_callback now release_urecord() of the static <code>urecord[0x7f7b41740200]</code> has no efect</p>
<pre><code>Feb 16 17:04:43 sp1 proxy[9687]: DEBUG: usrloc [urecord.c:553]: release_urecord(): free urecord[0x7f7b41740200]
</code></pre>
<p>so the initial <code>ucontact[0x7f7b315f1d08]</code> is not freed and the leak is done.</p>

<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">—<br />You are receiving this because you are subscribed to this thread.<br />Reply to this email directly, <a href="https://github.com/kamailio/kamailio/issues/997#issuecomment-280596763">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe-auth/AF36ZSBROX-unooy6dt3nqFHw2b3aQ88ks5rdWSSgaJpZM4MC6n1">mute the thread</a>.<img alt="" height="1" src="https://github.com/notifications/beacon/AF36ZShS1BfZEHLFAYNUCyDWx3Hq1V4Iks5rdWSSgaJpZM4MC6n1.gif" width="1" /></p>
<div itemscope itemtype="http://schema.org/EmailMessage">
<div itemprop="action" itemscope itemtype="http://schema.org/ViewAction">
  <link itemprop="url" href="https://github.com/kamailio/kamailio/issues/997#issuecomment-280596763"></link>
  <meta itemprop="name" content="View Issue"></meta>
</div>
<meta itemprop="description" content="View this Issue on GitHub"></meta>
</div>

<script type="application/json" data-scope="inboxmarkup">{"api_version":"1.0","publisher":{"api_key":"05dde50f1d1a384dd78767c55493e4bb","name":"GitHub"},"entity":{"external_key":"github/kamailio/kamailio","title":"kamailio/kamailio","subtitle":"GitHub repository","main_image_url":"https://cloud.githubusercontent.com/assets/143418/17495839/a5054eac-5d88-11e6-95fc-7290892c7bb5.png","avatar_image_url":"https://cloud.githubusercontent.com/assets/143418/15842166/7c72db34-2c0b-11e6-9aed-b52498112777.png","action":{"name":"Open in GitHub","url":"https://github.com/kamailio/kamailio"}},"updates":{"snippets":[{"icon":"PERSON","message":"@linuxmaniac in #997: Yes, the problem is happening for me because of pua_reginfo and I did https://github.com/linuxmaniac/kamailio/commit/2152b8c3ad4b1d61c4a456f7cb082ccfd10fe39c in order to solve it. But even with that I still get ucontac at shared mem left.\r\n\r\nI'm suspecting that the underlying problem is the combination of get_static_urecord() + ul_callbacks + get_static_urecord(). The urecord is the same and it gets freed twice so only the first ucontact is free and the other is leaked.\r\n\r\nsee https://github.com/kamailio/kamailio/issues/997#issuecomment-280377848\r\n\r\nREGISTER\r\n```\r\nFeb 16 17:04:43 sp1 proxy[9687]: NOTICE: \u003cscript\u003e: New request on proxy - M=REGISTER R=sip:192.168.1.71 F=sip:43993005@192.168.1.71 T=sip:43993005@192.168.1.71 IP=192.168.1.42:53152\r\n (127.0.0.1:5060) ID=8e40daa391b6e4d82b296c77eb0c6986@0.0.0.0 UA='Jitsi2.9.5521Linux'\r\nFeb 16 17:04:43 sp1 proxy[9687]: DEBUG: usrloc [udomain.c:174]: get_static_urecord(): urecord static[0x7f7b41740200]\r\nFeb 16 17:04:43 sp1 proxy[9687]: DEBUG: usrloc [ucontact.c:142]: new_ucontact(): new ucontact[0x7f7b315f1d08]\r\nFeb 16 17:04:43 sp1 proxy[9687]: DEBUG: usrloc [udomain.c:1155]: get_urecord(): DB_ONLY urecord[0x7f7b41740200]\r\n```\r\n``urecord static[0x7f7b41740200]`` is called before ul_callbacks and ``ucontact[0x7f7b315f1d08]`` is created.\r\n\r\nnow pua_reginfo\r\n```\r\nFeb 16 17:04:43 sp1 proxy[9687]: DEBUG: usrloc [udomain.c:174]: get_static_urecord(): urecord static[0x7f7b41740200]\r\nFeb 16 17:04:43 sp1 proxy[9687]: DEBUG: usrloc [ucontact.c:142]: new_ucontact(): new ucontact[0x7f7b315f24f8]\r\nFeb 16 17:04:43 sp1 proxy[9687]: DEBUG: usrloc [ucontact.c:142]: new_ucontact(): new ucontact[0x7f7b315f28f0]\r\nFeb 16 17:04:43 sp1 proxy[9687]: DEBUG: usrloc [udomain.c:1155]: get_urecord(): DB_ONLY urecord[0x7f7b41740200]\r\n```\r\n \r\n``get_urecord()`` is called and the static ``urecord[0x7f7b41740200]`` is used and the new ``ucontact[0x7f7b315f28f0]`` and ``ucontact[0x7f7b315f24f8]`` are there.\r\n\r\nThis code has my fix so release_urecord() is called by pua_reginfo\r\n```\r\nFeb 16 17:04:43 sp1 proxy[9687]: DEBUG: usrloc [urecord.c:553]: release_urecord(): free urecord[0x7f7b41740200]\r\nFeb 16 17:04:43 sp1 proxy[9687]: DEBUG: usrloc [ucontact.c:179]: free_ucontact(): free ucontact[0x7f7b315f24f8]\r\nFeb 16 17:04:43 sp1 proxy[9687]: DEBUG: usrloc [ucontact.c:179]: free_ucontact(): free ucontact[0x7f7b315f28f0]\r\n```\r\nand ``ucontact[0x7f7b315f28f0]`` and ``ucontact[0x7f7b315f24f8]`` are freed, perfect, but after the ul_callback now release_urecord() of the static ``urecord[0x7f7b41740200]`` has no efect\r\n\r\n```\r\nFeb 16 17:04:43 sp1 proxy[9687]: DEBUG: usrloc [urecord.c:553]: release_urecord(): free urecord[0x7f7b41740200]\r\n```\r\n\r\nso the initial ``ucontact[0x7f7b315f1d08]`` is not freed and the leak is done."}],"action":{"name":"View Issue","url":"https://github.com/kamailio/kamailio/issues/997#issuecomment-280596763"}}}</script>