<h3>Description</h3>
<p>When using cfg_get in async_workers, the values cannot be retrieved.  You either get a 'soft' fail with kamailio failing to assign the value, or you get a 'hard' fail and kamailio core dumps.  The difference in behaviour appears to be determined by where the cfg variable is defined.  If its defined in kamailio.cfg, you get a soft failure.  If its defined in a cfg file which you included, you get a hard failure.</p>
<h3>Troubleshooting</h3>
<p>Tried MANY combinations of setting the variable in different places, different length of variable names, including different characters.</p>
<h4>Reproduction</h4>
<p>test_crash.cfg</p>
<pre><code>#!KAMAILIO

debug=8
fork=yes
children=1
async_workers=1

listen=udp:127.0.0.1:12345

loadmodule "kex.so"
loadmodule "mi_fifo.so"
loadmodule "tm.so"
loadmodule "tmx.so"
loadmodule "sl.so"
loadmodule "uac.so"
loadmodule "rr.so"
loadmodule "pv.so"
loadmodule "async.so"
loadmodule "xlog.so"

modparam("mi_fifo", "fifo_name", "./kamailio.fifo")

include_file "test_crash_included.cfg"

info.var = 1 desc "Info Variable"

request_route {
    if(@cfg_get.info.var == 1) {
        # This gets printed
        xlog("Variable is 1 in request route\n");
    }
    if(@cfg_get.info.var_from_other_file == 1) {
        # This gets printed
        xlog("Variable from other file is 1 in request route\n");
    }

    if(t_newtran()) {
        async_task_route("ASYNC_REQUEST_ROUTE");
    }
    exit;
}

route[ASYNC_REQUEST_ROUTE] {
    if(@cfg_get.info.var == 1) {
        # This doesn't get printed
        xlog("Variable is 1 in async route\n");
    } else {
        # This assignment fails with error:
        # 5(19705) ERROR: <core> [lvalue.c:405]: lval_assign(): assignment failed at pos: (48,39-48,39)
        $var(test) = @cfg_get.info.var;
        xlog("Variable is $var(test)\n");
    }
    # Crash occurs on this line
    if(@cfg_get.info.var_from_other_file == 1) {
        xlog("Variable from other file is 1 in async route\n");
    }

    t_reply("200", "OK");
}
</code></pre>
<p>test_crash_included.cfg</p>
<pre><code>#!KAMAILIO

info.var_from_other_file = 1 desc "Var from other file"

</code></pre>
<h4>Debugging Data</h4>

<pre><code>(paste your debugging data here)
</code></pre>
<h4>Log Messages</h4>

<pre><code>(paste your log messages here)
</code></pre>
<h4>SIP Traffic</h4>

<pre><code>(paste your sip traffic here)
</code></pre>
<h3>Possible Solutions</h3>

<h3>Additional Information</h3>
<ul>
<li><strong>Kamailio Version</strong> - output of <code>kamailio -v</code></li>
</ul>
<pre><code>version: kamailio 4.4.2 (x86_64/linux) 892ad6
flags: STATS: Off, USE_TCP, USE_TLS, USE_SCTP, TLS_HOOKS, USE_RAW_SOCKS, DISABLE_NAGLE, USE_MCAST, DNS_IP_HACK, SHM_MEM, SHM_MMAP, PKG_MALLOC, 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_BLACKLIST, HAVE_RESOLV_RES
ADAPTIVE_WAIT_LOOPS=1024, MAX_RECV_BUFFER_SIZE 262144, MAX_LISTEN 16, MAX_URI_SIZE 1024, BUF_SIZE 65535, DEFAULT PKG_SIZE 8MB
poll method support: poll, epoll_lt, epoll_et, sigio_rt, select.
id: 892ad6
compiled on 18:41:47 Dec  4 2017 with x86_64-unknown-linux-gnu-gcc 4.9.4
</code></pre>
<ul>
<li><strong>Operating System</strong>:</li>
</ul>

<pre><code>Linux ip-172-31-126-249 4.4.23-31.54.amzn1.x86_64 #1 SMP Tue Oct 18 22:02:09 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
</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/1362">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe-auth/AF36ZZMA2igbarTXHP6Xp5auN2KPMW2Gks5s_aBIgaJpZM4Q-EXd">mute the thread</a>.<img alt="" height="1" src="https://github.com/notifications/beacon/AF36ZVkjo518LmarrxXWQFiN5ep2m6-Cks5s_aBIgaJpZM4Q-EXd.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/1362"></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":"DESCRIPTION","message":"cfg_get variables broken in async workers. (#1362)"}],"action":{"name":"View Issue","url":"https://github.com/kamailio/kamailio/issues/1362"}}}</script>