<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body dir="ltr">
<div style="font-family: Calibri,Helvetica,sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
So what actually happens when you do kamcmd cfg.set ? I assumed the variable is set in shared memory somewhere and all the processes reference the same shared memory variable.<br>
</div>
<div style="font-family: Calibri,Helvetica,sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri,Helvetica,sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
What I'm seeing is that I set the value to 1 using cfg.set and then some time later I do </div>
<div style="font-family: Calibri,Helvetica,sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri,Helvetica,sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<div>sbin/kamctl kamcmd cfg.get features with_dynamodb_user_data</div>
<div><br>
</div>
and I see the value being some rather large integer, which is not equal to 1. Inside my kamailio.cfg code, I only ever use that value in if statements so it should never be changed.</div>
<div style="font-family: Calibri,Helvetica,sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri,Helvetica,sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
example:</div>
<div style="font-family: Calibri,Helvetica,sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri,Helvetica,sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
if (@cfg_get.features.with_dynamodb_user_data == 1)<br>
</div>
<div style="font-family: Calibri,Helvetica,sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri,Helvetica,sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
When I attach gdb to the kamailio process that handles kamctl, and break inside the set_cfg_now function, I can see that the actual address where the variable is being saved to changes, so it makes me wonder if there is some race condition where a process could
try and read the value of the variable while its memory location is being changed?</div>
<div style="font-family: Calibri,Helvetica,sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Otherwise the only thing I can think of is that there is some sort of buffer overflow happening when writing and its changing the value of this variable as a consequence.</div>
<div style="font-family: Calibri,Helvetica,sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri,Helvetica,sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Thoughts?</div>
<div style="font-family: Calibri,Helvetica,sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri,Helvetica,sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" style="font-size:11pt" color="#000000"><b>From:</b> Daniel-Constantin Mierla <miconda@gmail.com><br>
<b>Sent:</b> Friday, May 18, 2018 8:59 AM<br>
<b>To:</b> Kamailio (SER) - Users Mailing List; Malcolm O'Hare<br>
<b>Subject:</b> Re: [SR-Users] Help on how to debug cfg_get variable having unexpected value?</font>
<div> </div>
</div>
<meta content="text/html; charset=Windows-1252">
<div style="background-color:#FFFFFF">
<p style="margin-top: 0px; margin-bottom: 0px;margin-top: 0px; margin-bottom: 0px;margin-top: 0px; margin-bottom: 0px;">
Hello,</p>
<p style="margin-top: 0px; margin-bottom: 0px;margin-top: 0px; margin-bottom: 0px;margin-top: 0px; margin-bottom: 0px;">
<br>
</p>
<p style="margin-top: 0px; margin-bottom: 0px;margin-top: 0px; margin-bottom: 0px;margin-top: 0px; margin-bottom: 0px;">
can you provide more details about what you think is going wrong?</p>
<p style="margin-top: 0px; margin-bottom: 0px;margin-top: 0px; margin-bottom: 0px;margin-top: 0px; margin-bottom: 0px;">
<br>
</p>
<p style="margin-top: 0px; margin-bottom: 0px;margin-top: 0px; margin-bottom: 0px;margin-top: 0px; margin-bottom: 0px;">
The value of this variable is updated by each process when that process does some particular operations (e.g., receiving a sip message), it is not propagated automatically to every kamailio process when you do the update via kamcmd.</p>
<p style="margin-top: 0px; margin-bottom: 0px;margin-top: 0px; margin-bottom: 0px;margin-top: 0px; margin-bottom: 0px;">
<br>
</p>
Cheers,<br>
Daniel<br>
<br>
<div class="x_moz-cite-prefix">On 14.05.18 19:43, Malcolm O'Hare wrote:<br>
</div>
<blockquote type="cite"><style type="text/css" style="display:none">
<!--
p
{margin-top:0;
margin-bottom:0}
-->
</style>
<div style="font-family:Calibri,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
I'm trying to debug an issue I've encountered where a variable that I've set using kamcmd cfg.set has an unexpected value when used in kamailio. The variable should be 0 or 1, but it looks like its getting set accidently somehow.</div>
<div style="font-family:Calibri,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
<br>
</div>
<div style="font-family:Calibri,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
<style type="text/css">
<!--
p.x_p1
{margin:0.0px 0.0px 0.0px 0.0px;
font:11.0px Helvetica}
span.x_s1
{}
-->
</style>
<p class="x_p1" style="margin-top: 0px; margin-bottom: 0px;margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Helvetica;margin-top: 0px; margin-bottom: 0px;margin-top: 0px; margin-bottom: 0px;margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Helvetica;">
<span class="x_s1"><span style="font-size:12pt">2018-05-11T22:02:58.344260+00:00 ip-172-31-129-45
</span><span style="font-size:12pt">kamailio[5253]: DEBUG: <core> [select.c:263]: resolve_select(): 'with_dynamodb_user_data'</span></span></p>
<p class="x_p1" style="margin-top: 0px; margin-bottom: 0px;margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Helvetica;margin-top: 0px; margin-bottom: 0px;margin-top: 0px; margin-bottom: 0px;margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Helvetica;">
<span class="x_s1"><span style="font-size:12pt">2018-05-11T22:02:58.344264+00:00 ip-172-31-129-45
</span><span style="font-size:12pt">kamailio[5253]: DEBUG: <core> [cfg/cfg_select.c:174]: select_cfg_var(): DEBUG: select_cfg_var(): select fixup is postponed: features.with_dynamodb_user_data</span></span></p>
<p class="x_p1" style="margin-top: 0px; margin-bottom: 0px;margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Helvetica;margin-top: 0px; margin-bottom: 0px;margin-top: 0px; margin-bottom: 0px;margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Helvetica;">
<span class="x_s1"><span style="font-size:12pt">2018-05-11T22:05:03.467110+00:00 ip-172-31-129-45
</span><span style="font-size:12pt">kamailio[5551]: INFO: <core> [cfg/cfg_ctx.c:608]: cfg_set_now(): INFO: cfg_set_now(): features.with_dynamodb_user_data has been changed to 1</span></span></p>
<p class="x_p1" style="margin-top: 0px; margin-bottom: 0px;margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Helvetica;margin-top: 0px; margin-bottom: 0px;margin-top: 0px; margin-bottom: 0px;margin: 0px; font-style: normal; font-variant: normal; font-weight: normal; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Helvetica;">
<span class="x_s1"><span style="font-size:12pt">2018-05-11T22:15:51.695118+00:00 ip-172-31-129-45
</span><span style="font-size:12pt">kamailio[5574]: [2c03c333-1705-41b1-aa26-6f10492a5a6f] DEBUG: with_dynamodb_user_data is 1157627905</span></span></p>
<br>
</div>
<div style="font-family:Calibri,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
I've tried to debug using gdb using breaks and set a watch on the memory address of the var, but it looks like it keeps using different memory locations. The value in the address pointed at by group.handle seems to change for each invocation of set_cfg_now,
so when I try and put a watch on the address of *group.handle + var.offset it never gets hit.</div>
<div style="font-family:Calibri,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
<br>
</div>
<div style="font-family:Calibri,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
<div>(gdb) print *group</div>
<div>$36 = {num = 25, mapping = 0x7f56ee4474f0, vars = 0x0, add_var = 0x0, size = 164, meta_offset = 968, var_offset = 984, handle = 0x7f56edf92fd0, orig_handle = 0x0,</div>
<div> dynamic = 1 '\001', next = 0x0, name_len = 8, name = "f"}</div>
<div><br>
</div>
<div>
<div>(gdb) print *var</div>
<div>$62 = {def = 0x7f56ee471668, name_len = 23, pos = 24, offset = 164, flag = 0}</div>
<br>
</div>
<div>Any ideas?</div>
<div><br>
</div>
<div>Malcolm</div>
<br>
</div>
<br>
<fieldset class="x_mimeAttachmentHeader"></fieldset> <br>
<pre>_______________________________________________
Kamailio (SER) - Users Mailing List
<a class="x_moz-txt-link-abbreviated" href="mailto:sr-users@lists.kamailio.org">sr-users@lists.kamailio.org</a>
<a class="x_moz-txt-link-freetext" href="https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users">https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users</a>
</pre>
</blockquote>
<br>
<pre class="x_moz-signature" cols="72">--
Daniel-Constantin Mierla
<a class="x_moz-txt-link-abbreviated" href="http://www.twitter.com/miconda">www.twitter.com/miconda</a> -- <a class="x_moz-txt-link-abbreviated" href="http://www.linkedin.com/in/miconda">www.linkedin.com/in/miconda</a>
Kamailio World Conference - May 14-16, 2018 - <a class="x_moz-txt-link-abbreviated" href="http://www.kamailioworld.com">www.kamailioworld.com</a></pre>
</div>
</body>
</html>