[pjsip] Deadlock issue (pjsip 2.1 @4701)

Anshuman S Rawat arawat at 3clogic.com
Fri May 23 06:14:20 EDT 2014


Hello,

 

We have our soft-phone application which uses PJSIP (2.1 @ rev 4701). The
following deadlock was noticed while running. I do not have the complete
stack trace but have a reasonable picture of the stack.

 

Stack thread 1 (app dials a call):

 

pj_mutex_lock(mod_ua.mutex) - blocks on this

pjsip_ua_register_dlg()

pjsip_dlg_create_uac()

pjsua_call_make_call() - acquires PJSUA_LOCK()

 

 

Stack thread 2 (an incoming call is answered by the app)

 

pjsua_call_on_state_changed() - blocks on  PJSUA_LOCK (acquired by thread 1)

inv_set_state()

inv_on_state_incoming()

mod_inv_on_tsx_state()

pjsip_dlg_on_tsx_state()

mod_ua_on_tsx_state()

tsx_set_state()

tsx_on_state_proceeding_uas()

pjsip_tsx_send_msg() -  acquires tsx->grp_lock

pjsip_dlg_send_response()

pjsip_inv_send_msg()

pjsua_call_answer2()

 

 

Stack thread 3 (incoming message on same tsx as in thread 2)

 

pj_grp_lock_acquire() - blocks on tsx->grp_lock

pjsip_tsx_layer_find_tsx()

find_dlg_set_for_msg()

mod_ua_on_request() - acquires mod_ua.mutex (on which thread 1 is blocked)

pjsip_endpt_process_rx_data()

endpt_on_rx_msg()

pjsip_tpmgr_received_packet()

udp_on_read_complete()

 

 

Seems like a typical dining philosopher's problem. Has this been
seen/reported earlier?

For me, a simple solution seems to be to do a try lock on (mod_ua.mutex)
when been acquired by the UAC (do not want to miss notifications from
network/UAS) and report failure back to application in case it fails.

 

Any suggestions?

 

Thanks,

Anshuman

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.pjsip.org/pipermail/pjsip_lists.pjsip.org/attachments/20140523/3fbd74d1/attachment-0002.html>


More information about the pjsip mailing list