kamailio icon indicating copy to clipboard operation
kamailio copied to clipboard

http_async_client module crashing kamailio v5.5 on startup (macos 12)

Open joeygo opened this issue 3 years ago • 5 comments

Description

Hello, Loading http_async_client module causes kamailio to crash on startup with the following errors:

 0(60541) INFO: http_async_client [async_http.c:85]: async_http_init_worker(): started worker process: 1
[warn] kevent: Bad file descriptor
16(60557) CRITICAL: <core> [core/pt.c:405]: fork_tcp_process(): called from a non "main" process
16(60557) ERROR: <core> [core/tcp_main.c:5121]: tcp_init_children(): fork failed: Bad file descriptor
 0(60541) ALERT: <core> [main.c:786]: handle_sigs(): child process 60557 exited normally, status=255
 0(60541) INFO: <core> [main.c:813]: handle_sigs(): terminating due to SIGCHLD
 1(60542) INFO: <core> [main.c:868]: sig_usr(): signal 15 received
 5(60546) INFO: <core> [main.c:868]: sig_usr(): signal 15 received

Issue reproduced with kamailio sample configuration + loadmodule "http_async_client.so"

Additional Information

  • Kamailio Version *
kamailio -v
version: kamailio 5.5.3 (x86_64/darwin) b42dfd
flags: USE_TCP, USE_TLS, USE_SCTP, TLS_HOOKS, DISABLE_NAGLE, USE_MCAST, DNS_IP_HACK, SHM_MMAP, PKG_MALLOC, Q_MALLOC, F_MALLOC, TLSF_MALLOC, DBG_SR_MEMORY, FAST_LOCK-ADAPTIVE_WAIT, USE_DNS_CACHE, USE_DNS_FAILOVER, USE_NAPTR, USE_DST_BLOCKLIST, HAVE_RESOLV_RES, TLS_PTHREAD_MUTEX_SHARED
ADAPTIVE_WAIT_LOOPS 1024, MAX_RECV_BUFFER_SIZE 262144, MAX_URI_SIZE 1024, BUF_SIZE 65535, DEFAULT PKG_SIZE 8MB
poll method support: poll, select, kqueue.
id: b42dfd 
compiled on 22:25:21 Jan  6 2022 with gcc Apple clang version 13.0.0 (clang-1300.0.29.30)
  • Operating System:
MacOS

joeygo avatar Jan 09 '22 08:01 joeygo

Thanks for the report. Not many people are using/building Kamailio on MacOS, so there might be not much response to this issue. Most people use Linux, but you probably know this.

henningw avatar Jan 10 '22 13:01 henningw

I compile Kamailio and a lot of modules on MacOS as for a development environment, doing some tests as well, but not planning to use it for a production system. Considering this, if you use also tls module or others modules are linked to libssl, try with --atexit=no -- see the remarks at:

  • https://www.kamailio.org/docs/modules/devel/modules/tls.html#tls.overview

If it's not that one, then provide full details of MacOS version, I can try to reproduce and if I find a quick solution, then it will be fixed, otherwise, it will have really low priority, given that newer MacOS versions have lots of restrictions related to signed and trusted apps.

miconda avatar Jan 10 '22 14:01 miconda

Thanks for your reply. I'm using MacOS only for development purposes and not for production. I have tried running kamailio with --atexit=no but I doesn't help.

I'm using MacBook Pro (15-inch, 2018) Processor 2.9 GHz 6-Core Intel Core i9 macOS Monterey v12.1

I totally understand and thank you for trying..

joeygo avatar Jan 10 '22 14:01 joeygo

It seems to be failure of the libevent function event_base_dispatch(), which also logs [warn] kevent: Bad file descriptor:

 6(38960) DEBUG: http_async_client [hm_hash.c:59]: init_http_m_table(): hash table 0x10f7f82a8 initialized with size 2048
[warn] kevent: Bad file descriptor
 6(38960) ERROR: http_async_client [async_http.c:97]: async_http_run_worker(): event base dispatch failed - ret: -1 (errno: 9 - Bad file descriptor)

The above logs are from current master, as I pushed a commit to http_async_client module to exit the worker process (and thus shutdown kamailio) in the case of this failure.

Could be something that changed in the new MacOS 12 kqueue implementation. I am not familiar with libevent, maybe @grumvalski or someone else can comment or analyse further.

miconda avatar Jan 10 '22 17:01 miconda

If it helps someone, here is a minimal config that exposes the issue at startup:

#!KAMAILIO

debug=3
log_stderror=yes

children=2

listen=udp:127.0.0.1
listen=tcp:127.0.0.1

loadmodule "tm.so"
loadmodule "pv.so"
loadmodule "http_async_client.so"


request_route {
    return;
}

miconda avatar Jan 11 '22 09:01 miconda

This issue is stale because it has been open 6 weeks with no activity. Remove stale label or comment or this will be closed in 2 weeks.

github-actions[bot] avatar Nov 08 '23 08:11 github-actions[bot]