Hi,
I am seeing a regression after upgrading from Asterisk 22.5.2 to 22.9/22.10.1.
Environment:
Asterisk/derived build: 22.10.1
PJPROJECT bundled: 2.17
Previous working version: 22.5.2
Previous PJPROJECT bundled: 2.15.1
Transport affected: PJSIP TCP and WSS
The system has many TCP/WSS endpoints. After upgrading, SIP TCP registrations work for a few minutes, then the TCP transport stops responding. Packets are visible with sngrep/tcpdump, but no SIP packet appears in the Asterisk PJSIP logger and no response is sent.
The log repeatedly shows:
pjproject: ../src/pj/ioqueue_epol Assert failed: !pj_list_empty(&ioqueue->free_list)
There are also many messages like:
res_pjsip/pjsip_transport_management.c: Shutting down transport ‘TCP to x.x.x.x:port’ since no request was received in 6 seconds
res_pjsip/pjsip_transport_management.c: Shutting down transport ‘WSS to x.x.x.x:port’ since no request was received in 6 seconds
res_http_websocket.c: Error reading from web socket: Success
iostream.c: SSL_shutdown() failed … Broken pipe
I confirmed this is not an OS file descriptor limit:
Max open files: 300000
lsof -p $(pidof asterisk): around 1900-2200
ss -tanpn | grep asterisk: around 1000-1400
I also tested increasing PJPROJECT limits:
#define PJ_IOQUEUE_MAX_HANDLES 20000
#define PJSIP_TCP_TRANSPORT_BACKLOG 4096
#define PJSIP_TLS_TRANSPORT_BACKLOG 4096
The listen backlog changed correctly:
LISTEN 0 4096 0.0.0.0:7048 users:((“asterisk”…))
but the issue still occurred on 22.10.1.
Rolling back to Asterisk 22.5.2 with the same configuration files immediately fixes the issue. With 22.5.2, the same traffic pattern and even more active TCP sockets do not trigger the ioqueue_epol assertion.
I compared the source trees and noticed that 22.10.1 uses bundled PJPROJECT 2.17 while 22.5.2 uses 2.15.1. The suspicious change seems to be in PJPROJECT ioqueue behavior. In 2.17, PJ_IOQUEUE_CALLBACK_NO_LOCK defaults to 1, and the comment says this may introduce a race between key unregistration and read/write callbacks. There is also new ioqueue_drain_pending_writes() logic during unregister.
This looks relevant because the issue is triggered by many TCP/WSS connections opening and closing quickly.
Questions:
Is this a known regression in PJPROJECT 2.17 with epoll and TCP/WSS transport churn?
Is it safe/recommended for Asterisk to build bundled PJPROJECT 2.17 with:
#define PJ_IOQUEUE_CALLBACK_NO_LOCK 0
#define PJSIP_SAFE_MODULE 1
Are there any known patches or workarounds for ioqueue_epol Assert failed: !pj_list_empty(&ioqueue->free_list) in Asterisk 22.9/22.10.1?
For now I have rolled back to 22.5.2 because it is stable under the same load.
Thanks.