Opened 6 years ago

Closed 6 years ago

#2115 closed defect (fixed)

Deadlock between PJSUA LOCK and conference mutex

Reported by: ming Owned by: bennylp
Priority: normal Milestone: release-2.8
Component: pjsua-lib Version: trunk
Keywords: Cc:
Backport to 1.x milestone: Backported: no

Description

The same issue as in ticket #1464 happens again.

The ticket doesn't entirely fix the problem, because PJSUA_LOCK() can be called by the upper functions instead, such as:

 	pjsua_call_on_state_changed(pjsip_inv_session * inv, pjsip_event * e) Line 4016	C
 	inv_set_state(pjsip_inv_session * inv, pjsip_inv_state state, pjsip_event * e) Line 317	C
 	inv_on_state_null(pjsip_inv_session * inv, pjsip_event * e) Line 3941	C
 	mod_inv_on_tsx_state(pjsip_transaction * tsx, pjsip_event * e) Line 717	C
 	pjsip_dlg_on_tsx_state(pjsip_dialog * dlg, pjsip_transaction * tsx, pjsip_event * e) Line 2069	C
 	mod_ua_on_tsx_state(pjsip_transaction * tsx, pjsip_event * e) Line 178	C
 	tsx_set_state(pjsip_transaction * tsx, pjsip_tsx_state_e state, pjsip_event_id_e event_src_type, void * event_src, int flag) Line 1268	C
 	tsx_on_state_null(pjsip_transaction * tsx, pjsip_event * event) Line 2483	C
 	pjsip_tsx_send_msg(pjsip_transaction * tsx, pjsip_tx_data * tdata) Line 1790	C
 	pjsip_dlg_send_request(pjsip_dialog * dlg, pjsip_tx_data * tdata, int mod_data_id, void * mod_data) Line 1288	C
 	pjsip_inv_send_msg(pjsip_inv_session * inv, pjsip_tx_data * tdata) Line 3282	C
 	on_make_call_med_tp_complete(int call_id, const pjsua_med_tp_state_info * info) Line 518	C
 	pjsua_call_make_call(int acc_id, const pj_str_t * dest_uri, const pjsua_call_setting * opt, void * user_data, const pjsua_msg_data * msg_data, int * p_call_id) Line 919	C

In the above stack trace, both pjsua_call_make_call() and on_make_call_med_tp_complete() both call PJSUA_LOCK().

The fix in this current ticket will improve the one in #1464 by ensuring that PJSUA_LOCK is not held before calling the callback. Note that if deadlock issue still persists, we may need to consider using group lock or chain the locks with pj_grp_lock_chain_lock()).

Thanks to Marcus Froeschl again for the report.

Change History (1)

comment:1 Changed 6 years ago by ming

  • Resolution set to fixed
  • Status changed from new to closed

In 5795:

Fixed #2115: Deadlock between PJSUA LOCK and conference mutex

Note: See TracTickets for help on using tickets.