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

(paste your debugging data here)

Log Messages

(paste your log messages here)

SIP Traffic

(paste your sip traffic here)

Possible Solutions

Additional Information

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
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


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or mute the thread.