<p></p>
<h3>Description</h3>
<p>We are having several customers with crashes during calls to RPC <code>permissions.trustedReload</code> even after introducing the basic safety for concurrent RPC reload <a class="commit-link" data-hovercard-type="commit" data-hovercard-url="https://github.com/kamailio/kamailio/commit/c87f5202d778cf110ce0fbbc554310c148e997cb/hovercard" href="https://github.com/kamailio/kamailio/commit/c87f5202d778cf110ce0fbbc554310c148e997cb"><tt>c87f520</tt></a></p>
<h3>Possible solution</h3>
<p>It seems that we need to implement locking in order to be sure the memory is not gone in the middle of a read.</p>
<h4>Reproduction</h4>
<p>It's quite difficult to reproduce since <code>match_hash_table</code> call has to happen during a RPC reload</p>
<h4>Debugging Data</h4>
<pre><code>(gdb) bt full
#0 match_hash_table (table=<optimized out>, msg=msg@entry=0x7fc3d800a808, src_ip_c_str=src_ip_c_str@entry=0x7fc3d7f217b8 "A.A.A.A", proto=proto@entry=1,
from_uri=from_uri@entry=0x7fc3d7f1b750 "sip:fake@B.B.B.B") at hash.c:280
__func__ = "match_hash_table"
ruri = <optimized out>
ruri_string = "sip:41584006001@B.B.B.B:5060\000\264{\224\377\177\000\000\000\240\200\331\302\177\000\000\300\000\000\000\000\000\000\000\332\003\000\000\000\000\000\000\300\067~\372PV\000\000\000\220
\324m,\233߁\260\341D\334\302\177\000\000\260go\372PV\000\000P\343!\332\302\177\000\000\004\340{\372PV\000\000`;~\372PV\000\000\300\067~\372PV\000\000@\024\000\000\000\000\000\000`\342!\332\302\177\000\000\001\00
0\000\000\000\000\000\000\310\066\204\331\302\177\000\000\000\240\200\331\302\177\000\000\300\000\000\000\000\000\000\000\300\067~\372PV\000\000`;~\372PV\000\000\332\003\000\000\000\000\000\000\000"...
preg = {__buffer = 0x0, __allocated = 0, __used = 224, __syntax = 16843462, __fastmap = 0x0, __translate = 0x0, re_nsub = 0, __can_be_null = 0, __regs_allocated = 0, __fastmap_accurate = 1,
__no_sub = 1, __not_bol = 0, __not_eol = 0, __newline_anchor = 0}
np = 0x455449564e492035
src_ip = {s = 0x7fc3d7f217b8 "A.A.A.A", len = <optimized out>}
val = <optimized out>
count = 0
#1 0x00007fc3d2362765 in allow_trusted (msg=msg@entry=0x7fc3d800a808, src_ip=0x7fc3d7f217b8 "A.A.A.A", proto=proto@entry=1, from_uri=from_uri@entry=0x7fc3d7f1b750 "sip:fake@B.B.B.B")
at trusted.c:499
__func__ = "allow_trusted"
result = <optimized out>
res = 0x0
keys = {0x7fc3d7f1b750}
vals = {{type = 3595139888, nul = 32707, free = -671045624, val = {int_val = -1803829520, ll_val = 140735684525808, double_val = 6.9532666868153257e-310, time_val = 140735684525808,
string_val = 0x7fff947bbef0 "\001", str_val = {s = 0x7fff947bbef0 "\001", len = -94468017}, blob_val = {s = 0x7fff947bbef0 "\001", len = -94468017}, bitmap_val = 2491137776,
uint_val = 2491137776, ull_val = 140735684525808}}}
cols = {0x0, 0x5650fa650c25 <pv_printf+229>, 0x7fff947bb670, 0x0}
#2 0x00007fc3d2363ef3 in allow_trusted_furi (_msg=_msg@entry=0x7fc3d800a808, _src_ip_sp=_src_ip_sp@entry=0x7fc3d6494340 "xEI\326\303\177", _proto_sp=_proto_sp@entry=0x7fc3d64925e0 "\330\375H\326\303\177",
from_uri=0x7fc3d7f1b750 "sip:fake@B.B.B.B") at trusted.c:590
src_ip = {s = 0x7fc3d7f217b8 "A.A.A.A", len = 11}
proto = {s = 0x7fc3d7f27820 "udp", len = 3}
proto_int = 1
__func__ = "allow_trusted_furi"
#3 0x00007fc3d23647d0 in allow_trusted_3 (_msg=0x7fc3d800a808, _src_ip_sp=0x7fc3d6494340 "xEI\326\303\177", _proto_sp=0x7fc3d64925e0 "\330\375H\326\303\177", _from_uri=<optimized out>) at trusted.c:634
from_uri = {s = 0x7fc3d7f1b750 "sip:fake@B.B.B.B", len = 34}
__func__ = "allow_trusted_3"
#4 0x00005650fa513319 in do_action (h=h@entry=0x7fff947bbef0, a=a@entry=0x7fc3d6497b30, msg=msg@entry=0x7fc3d800a808) at core/action.c:1085
</code></pre>
<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/2909">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe-auth/ABO7UZPEMTUABSSIRX3PK73UJJ4EPANCNFSM5G65OIMA">unsubscribe</a>.<br />Triage notifications on the go with GitHub Mobile for <a href="https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675">iOS</a> or <a href="https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub">Android</a>.
<img src="https://github.com/notifications/beacon/ABO7UZLG7Y6SYWCEGWWIMQDUJJ4EPA5CNFSM5G65OIMKYY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4PPTZ24Q.gif" height="1" width="1" alt="" /></p>
<script type="application/ld+json">[
{
"@context": "http://schema.org",
"@type": "EmailMessage",
"potentialAction": {
"@type": "ViewAction",
"target": "https://github.com/kamailio/kamailio/issues/2909",
"url": "https://github.com/kamailio/kamailio/issues/2909",
"name": "View Issue"
},
"description": "View this Issue on GitHub",
"publisher": {
"@type": "Organization",
"name": "GitHub",
"url": "https://github.com"
}
}
]</script>