### Description
crash happens if `lcr_id` passed to any of the functions ``KSR.lcr.load_gws*()`` is not defined in the lcr_gw table.
### Debugging Data
``` Core was generated by `/usr/sbin/kamailio -P /run/kamailio/kamailio.pid -f /etc/kamailio/kamailio.cfg'. Program terminated with signal SIGSEGV, Segmentation fault. (gdb) bt #0 ki_load_gws_furi (_m=0x7f1e66521100, lcr_id=3, ruri_user=0x7ffe1f856360, from_uri=0x7ffe1f856370) at lcr_mod.c:2312 #1 0x00007f1e65d8ca35 in sr_apy_kemi_exec_func_ex (ket=0x7f1e655c27f0 <sr_kemi_lcr_exports+144>, self=0x7f1e60ecd090, args=0x7f1e60dd07c0, idx=544) at apy_kemi.c:1354 #2 0x00007f1e65d90477 in sr_apy_kemi_exec_func (self=0x7f1e60ecd090, args=0x7f1e60dd07c0, idx=544) at apy_kemi.c:1829 #3 0x00007f1e65d9b6ff in sr_apy_kemi_exec_func_544 (self=0x7f1e60ecd090, args=0x7f1e60dd07c0) at apy_kemi_export.c:4395 #4 0x00007f1e658d4c74 in ?? () from /lib/x86_64-linux-gnu/libpython3.9.so.1.0 #5 0x00007f1e6588ea50 in _PyObject_MakeTpCall () from /lib/x86_64-linux-gnu/libpython3.9.so.1.0 #6 0x00007f1e658402f2 in _PyEval_EvalFrameDefault () from /lib/x86_64-linux-gnu/libpython3.9.so.1.0 #7 0x00007f1e65837033 in ?? () from /lib/x86_64-linux-gnu/libpython3.9.so.1.0 #8 0x00007f1e6583f4b7 in _PyEval_EvalFrameDefault () from /lib/x86_64-linux-gnu/libpython3.9.so.1.0 #9 0x00007f1e65837033 in ?? () from /lib/x86_64-linux-gnu/libpython3.9.so.1.0 #10 0x00007f1e6583f4b7 in _PyEval_EvalFrameDefault () from /lib/x86_64-linux-gnu/libpython3.9.so.1.0 #11 0x00007f1e65837033 in ?? () from /lib/x86_64-linux-gnu/libpython3.9.so.1.0 #12 0x00007f1e658916a4 in ?? () from /lib/x86_64-linux-gnu/libpython3.9.so.1.0 #13 0x00007f1e65da52fc in apy_exec (_msg=0x7f1e66521100, fname=0x7f1e65dae11d "ksr_request_route", fparam=0x0, emode=1) at python_exec.c:139 #14 0x00007f1e65d62cae in sr_kemi_config_engine_python (msg=0x7f1e66521100, rtype=1, rname=0x0, rparam=0x0) at apy_kemi.c:66 #15 0x000056247fc0a6e4 in sr_kemi_route (keng=0x562480066420 <_sr_kemi_eng_list>, msg=0x7f1e66521100, rtype=1, ename=0x0, edata=0x0) at core/kemi.c:3784 #16 0x000056247fc9da66 in receive_msg (buf=0x562480105280 <buf> "INVITE sip:0031686807515@34.91.122.173 SIP/2.0\r\nRecord-Route: sip:94.247.7.211;lr;ftag=tj0p4Q1r8H5ap\r\nVia: SIP/2.0/UDP 94.247.7.211;TH=div;branch=z9hG4bKdc26.e6a724746d6ff0bf5231906a5f1c8734.0\r\nVia:"..., len=1202, rcv_info=0x7ffe1f857090) at core/receive.c:502 #17 0x000056247fe01a5d in udp_rcv_loop () at core/udp_server.c:544 #18 0x000056247fb1a09b in main_loop () at main.c:1722 #19 0x000056247fb2720c in main (argc=10, argv=0x7ffe1f857ab8) at main.c:3078 (gdb) p lcr_count_param $1 = 1 (gdb) p lcr_id $2 = 3 ```
Victor Seva writes:
Assigned #3435 to @juha-h.
Victor,
Anything related to KEMI is not written me and I don't know anything about it.
-- Juha
@juha-h sorry for the noise then
KEMI was introduced to lcr module by this commit: https://github.com/kamailio/kamailio/commit/8fbf7d83b1dbeedf1ee53895aadbf6e9....
I will check it, but in general the kemi function is executed by the native kamailio.cfg function, after it evaluates its parameters with kamailio pseudo-variables. It is nothing specific for the kemi function than just needing the string/int values of the parameters.
Daniel-Constantin Mierla writes:
I will check it, but in general the kemi function is executed by the native kamailio.cfg function, after it evaluates its parameters with kamailio pseudo-variables. It is nothing specific for the kemi function than just needing the string/int values of the parameters.
For example in 5.0, the test was in correct order:
https://github.com/kamailio/kamailio/blob/5.0/src/modules/lcr/lcr_mod.c
I don't know what has happened since then.
-- Juha
The patch looks ok, it is moving above the safety check on lcr id. It can be merged IMO.
Just note that the branch 5.7 was also created, mailing list announcement is just about to follow.
Closed #3435 as completed via c88e506fe6a1ba0f588c5866a63ffb18fa25478a.