Asterisk Dead Lock

Hi all.
I have an asterisk server installed with version 16.1.1 on centos 7 Os.

I have noticed that soem times my all SIP peers going going unreachable inclsuing the looping SIP trunk(127.0.0.1) which i have. i was chekcing for the locks in asterisk using asterisk -rx “core show locks” and below is my result.

=======================================================================
=== 16.1.1
=== Currently Held Locks

===
=== <lock#> (): (times locked)

=== Thread ID: 0x7f1ea0930700 LWP:30389 (do_monitor started at [29979] chan_sip.c restart_monitor())
=== —> Lock #0 (chan_sip.c): MUTEX 29340 handle_request_do &netlock 0x7f1f01b2f680 (1)
asterisk(__ast_pthread_mutex_lock+0x85) [0x501885]
/usr/lib64/asterisk/modules/chan_sip.so(+0xa33d6) [0x7f1f018ff3d6]
/usr/lib64/asterisk/modules/chan_sip.so(+0xa4fcf) [0x7f1f01900fcf]
asterisk(ast_io_wait+0x7a) [0x4f517a]
/usr/lib64/asterisk/modules/chan_sip.so(+0x8086c) [0x7f1f018dc86c]
asterisk() [0x5a0412]
/usr/lib64/libpthread.so.0(+0x7dd5) [0x7f1f2690cdd5]
/usr/lib64/libc.so.6(clone+0x6d) [0x7f1f25caf02d]
=== —> Lock #1 (chan_sip.c): MUTEX 9370 sip_pvt_lock_full pvt 0x7f1e000698f0 (1)
asterisk(__ast_pthread_mutex_lock+0x85) [0x501885]
asterisk(__ao2_lock+0x1c5) [0x45d7f5]
/usr/lib64/asterisk/modules/chan_sip.so(+0x14bd5) [0x7f1f01870bd5]
/usr/lib64/asterisk/modules/chan_sip.so(+0xa3405) [0x7f1f018ff405]
/usr/lib64/asterisk/modules/chan_sip.so(+0xa4fcf) [0x7f1f01900fcf]
asterisk(ast_io_wait+0x7a) [0x4f517a]
/usr/lib64/asterisk/modules/chan_sip.so(+0x8086c) [0x7f1f018dc86c]
asterisk() [0x5a0412]
/usr/lib64/libpthread.so.0(+0x7dd5) [0x7f1f2690cdd5]
/usr/lib64/libc.so.6(clone+0x6d) [0x7f1f25caf02d]
=== —> Lock #2 (rtp_engine.c): MUTEX 692 ast_rtp_instance_set_prop instance 0x7f1e0003ca30 (1)
asterisk(__ast_pthread_mutex_lock+0x85) [0x501885]
asterisk(__ao2_lock+0x1c5) [0x45d7f5]
asterisk(ast_rtp_instance_set_prop+0x29) [0x53ed79]
/usr/lib64/asterisk/modules/chan_sip.so(+0x27ee4) [0x7f1f01883ee4]
/usr/lib64/asterisk/modules/chan_sip.so(+0x95f88) [0x7f1f018f1f88]
/usr/lib64/asterisk/modules/chan_sip.so(+0x9771c) [0x7f1f018f371c]
/usr/lib64/asterisk/modules/chan_sip.so(+0x9a820) [0x7f1f018f6820]
/usr/lib64/asterisk/modules/chan_sip.so(+0xa0bcd) [0x7f1f018fcbcd]
/usr/lib64/asterisk/modules/chan_sip.so(+0xa351e) [0x7f1f018ff51e]
/usr/lib64/asterisk/modules/chan_sip.so(+0xa4fcf) [0x7f1f01900fcf]
asterisk(ast_io_wait+0x7a) [0x4f517a]
/usr/lib64/asterisk/modules/chan_sip.so(+0x8086c) [0x7f1f018dc86c]
asterisk() [0x5a0412]
/usr/lib64/libpthread.so.0(+0x7dd5) [0x7f1f2690cdd5]
/usr/lib64/libc.so.6(clone+0x6d) [0x7f1f25caf02d]
=== -------------------------------------------------------------------

=======================================================================

Can anyone help on thsi to understand this ?

The problem is a deadlock between chan_sip and res_rtp_asterisk. 16.1.1 is nearing two years old, so it is entirely possible the issue has already been fixed.

Hai @jcolp Thanks for the Reply.

Am upgrading to asterisk version 16.13.0 - Hope this will resolve my issue.

Can you help me to find out the root cause or situation this can occur ?

Someone else may, but personally I don’t invest time into old versions such as that. There’s been too many times where I’ve sunk a lot of time into an issue that was already resolved.

@jcolp - I have also upgraded the asterisk version to the latest 16.13.0 and still facing the same issue again.

Just a gut feeling I have… I suspect your loop trunk may be the cause.

Does the problem go away if you remove your loop trunk?

Yes - It still there after removing the loop back trunk. I have trunk with another asterisk server and my telecom operator. Other than that i am using the local channel for dialing out the call from specific context. But Still the issue is happening.

@jcolp @david551 - Can you suugest something to find the issue ?

I have upgarded the asterisk to lastest 16.13.0 and also removed the loppback trunks.

Presently I have SIP trunks from Telecom Operator and SIP trunk between my asterisk boxes. And am also using the local channel to make the call like - AGI Script Executing Application: (dial) Options: (Local/9876543210@DESKPHONE/n,45,gtTm(hold_0373654))
– Called Local/9876543210@DESKPHONE/n

I don’t support chan_sip, so I can’t really add anything additional in regards to it. Changing to the supported chan_pjsip would be an option.