### Description
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.
### Troubleshooting
Tried MANY combinations of setting the variable in different places, different length of variable names, including different characters.
#### Reproduction
test_crash.cfg
``` #!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"); } ```
test_crash_included.cfg
``` #!KAMAILIO
info.var_from_other_file = 1 desc "Var from other file"
```
#### Debugging Data
<!-- If you got a core dump, use gdb to extract troubleshooting data - full backtrace, local variables and the list of the code at the issue location.
gdb /path/to/kamailio /path/to/corefile bt full info locals list
If you are familiar with gdb, feel free to attach more of what you consider to be relevant. -->
``` (paste your debugging data here) ```
#### Log Messages
<!-- Check the syslog file and if there are relevant log messages printed by Kamailio, add them next, or attach to issue, or provide a link to download them (e.g., to a pastebin site). -->
``` (paste your log messages here) ```
#### SIP Traffic
<!-- If the issue is exposed by processing specific SIP messages, grab them with ngrep or save in a pcap file, then add them next, or attach to issue, or provide a link to download them (e.g., to a pastebin site). -->
``` (paste your sip traffic here) ```
### Possible Solutions
<!-- If you found a solution or workaround for the issue, describe it. Ideally, provide a pull request with a fix. -->
### Additional Information
* **Kamailio Version** - output of `kamailio -v`
``` 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 ```
* **Operating System**:
<!-- Details about the operating system, the type: Linux (e.g.,: Debian 8.4, Ubuntu 16.04, CentOS 7.1, ...), MacOS, xBSD, Solaris, ...; Kernel details (output of `uname -a`) -->
``` 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 ```
Attach here the output of `bt full` taken from the core file with `gdb`, it is very useful for troubleshooting.
bt full added to original post
I tested with latest 4.4 branch and master branch, both work ok, I get in the logs:
``` 5(2974) DEBUG: <core> [select.c:412]: run_select(): Calling SELECT 0x10e6ff5b8 5(2974) ERROR: <script>: Variable is 1 in async route 5(2974) DEBUG: <core> [select.c:412]: run_select(): Calling SELECT 0x10e7021a0 5(2974) ERROR: <script>: Variable from other file is 1 in async route ```
Can you update to latest version in 4.4 series, it could be something that was already fixed. If still an issue, reopen.
Closed #1362.