sznoname created an issue (kamailio/kamailio#4669)
Segmentation Fault on Ctrl-C with No Fork Mode
Environment
- OS: Debian 13.3
- Kamailio Version: 6.1.1 (x86_64/Linux)
Relevant Configuration (/etc/kamailio/kamailio.cfg)
log_stderror=yes fork=no
auto_aliases=no tcp_accept_no_cl=yes
loadmodule "jsonrpcs.so" loadmodule "kex.so" loadmodule "corex.so" loadmodule "tm.so" loadmodule "tmx.so" loadmodule "sl.so" loadmodule "rr.so" loadmodule "pv.so" loadmodule "maxfwd.so" loadmodule "siputils.so" loadmodule "xlog.so" loadmodule "sanity.so" loadmodule "ctl.so" loadmodule "nats.so"
modparam("nats", "nats_url", "nats://127.0.0.1:4222") modparam("nats", "subject_queue_group", "Kamailio-World:2026")
request_route { sl_send_reply("403", "Not relaying"); exit; }
Steps to Reproduce
1. Start Kamailio in foreground mode with the given configuration: kamailio
2. Stop the running process using Ctrl-C
Observed Output and Crash
WARNING: no fork mode and more than one listen address found (will use only the first one) 0(9286) WARNING: <core> [main.c:1460]: main_loop(): using only the first listen address (no fork) ^CSegmentation fault (core dumped)
henningw left a comment (kamailio/kamailio#4669)
Thanks, please also post the core dump, e.g. as described here: https://www.kamailio.org/wikidocs/tutorials/troubleshooting/coredumpfile/
sznoname left a comment (kamailio/kamailio#4669)
Always reproducible.
``` Reading symbols from /usr/sbin/kamailio... (No debugging symbols found in /usr/sbin/kamailio) [Thread debugging using libthread_db enabled] Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1". Core was generated by `/usr/sbin/kamailio'. Program terminated with signal SIGSEGV, Segmentation fault. #0 0x00007f0b4cec1cca in ?? () from /lib/x86_64-linux-gnu/libnats.so.3.10 [Current thread is 1 (Thread 0x7f0b4dafeb80 (LWP 9024))] (gdb) bt full #0 0x00007f0b4cec1cca in ?? () from /lib/x86_64-linux-gnu/libnats.so.3.10 No symbol table info available. #1 0x00007f0b4cec33a3 in natsSubscription_Unsubscribe () from /lib/x86_64-linux-gnu/libnats.so.3.10 No symbol table info available. #2 0x00007f0b4cf0fbde in nats_destroy_workers () from /usr/lib/x86_64-linux-gnu/kamailio/modules/nats.so No symbol table info available. #3 0x00007f0b4cf102b3 in ?? () from /usr/lib/x86_64-linux-gnu/kamailio/modules/nats.so No symbol table info available. #4 0x00005568155856c3 in destroy_modules () No symbol table info available. #5 0x00005568152c6472 in cleanup () No symbol table info available. #6 0x00005568152c722d in ?? () No symbol table info available. #7 0x00005568152c7739 in handle_sigs () No symbol table info available. #8 <signal handler called> No locals. #9 __syscall_cancel_arch () at ../sysdeps/unix/sysv/linux/x86_64/syscall_cancel.S:52 No locals. #10 0x00007f0b4db8f668 in __internal_syscall_cancel (a1=<optimized out>, a2=<optimized out>, a3=<optimized out>, a4=<optimized out>, a5=<optimized out>, a6=<optimized out>, nr=45) at ./nptl/cancellation.c:49 result = <optimized out> pd = <optimized out> ch = <optimized out> #11 0x00007f0b4db8f6ad in __syscall_cancel (a1=<optimized out>, a2=<optimized out>, a3=<optimized out>, a4=<optimized out>, a5=<optimized out>, a6=<optimized out>, nr=45) at ./nptl/cancellation.c:75 r = <optimized out> #12 0x00007f0b4dc121d1 in __libc_recvfrom (fd=<optimized out>, buf=<optimized out>, len=<optimized out>, flags=<optimized out>, --Type <RET> for more, q to quit, c to continue without paging--c addr=..., addrlen=<optimized out>) at ../sysdeps/unix/sysv/linux/recvfrom.c:27 No locals. #13 0x0000556815605694 in udp_rcv_loop () No symbol table info available. #14 0x00005568152bedd1 in main () No symbol table info available. ```
henningw left a comment (kamailio/kamailio#4669)
Thanks, looks like its related to the nats module shutdown functions.
miconda left a comment (kamailio/kamailio#4669)
Not to this particular issue, but `fork=no` probably should be removed (changed) all together, its current behavior was not really tested for long time and a lot of things are (supposed) disabled in that mode (e.g., tcp).
The known-to-work actual daemonize options are (see kamailio -h):
``` -DD - do not daemonize the main/parent process -DDD - daemonize all ```
The `-D` (`fork=no`) should be switched probably to `-DD`.
sznoname left a comment (kamailio/kamailio#4669)
Thanks a lot for the explanation!
henningw left a comment (kamailio/kamailio#4669)
I have changed it to enhancement, as this specific no-fork mode is not really supported anymore. We probably should remove/alter this mode, I agree.
Closed #4669 as completed.