Re: Interesting deadlock bug found causing three threads to deadlock on the PJSUA, UA, and transaction locks.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi all,

Thanks for the report and sorry for the delay in answering.

For the problem reported by David, we think the problem is actually caused by thread 1 (instead of thread 3) which shouldn't try to obtain PJSUA's lock after holding the transaction lock. So we propose the fix attached. Please revert your temporary fix (where you remove the acquisition of group lock in pjsip_tsx_layer_find_tsx()) and use our patch instead, and share with us whether it rectifies the issue. Thanks.

While for the deadlock issue reported by Alex, despite the similarity, I believe this is an unrelated issue, so I'll reply it separately in the original thread.

Finally, for Janu, without the stack trace, I can't be certain that your problem is the same as one or both of these issues. So my suggestion is to apply both patches and see if the problem disappears. Also, I would recommend to upgrade to version 2.6, if you haven't, since 2.3 is already quite old.

Best regards,
Ming

On Fri, Mar 17, 2017 at 4:58 PM, janu@xxxxxxxxxxx <janu@xxxxxxxxxxx> wrote:
Also seems like the one I reprted (happens also if the application calls pjsua_call_hangup() between receiving a sip BYE and sending the corresponding OK).
I also got no response to that.

Regards,
Thomas

------ Originalnachricht------
Von: Alex Hermann
Datum: Fr., 17. März 2017 09:49
Cc:
Betreff:Re: Interesting deadlock bug found causing three threads to deadlock on the PJSUA, UA, and transaction locks.

On donderdag 16 maart 2017 14:18:25 CET David Richards wrote:> I found a bug that causes my application (using the PJSUA API) to deadlockThis looks like the same deadlock I reported on 7-3-2017. Unfortunately, I got no response to it.-- Alex Hermann_______________________________________________Visit our blog: http://blog.pjsip.orgpjsip mailing listpjsip@lists.pjsip.orghttp://lists.pjsip.org/mailman/listinfo/pjsip_lists.pjsip.org

_______________________________________________
Visit our blog: http://blog.pjsip.org

pjsip mailing list
pjsip@xxxxxxxxxxxxxxx
http://lists.pjsip.org/mailman/listinfo/pjsip_lists.pjsip.org


Index: pjsip/src/pjsua-lib/pjsua_call.c
===================================================================
--- pjsip/src/pjsua-lib/pjsua_call.c	(revision 5564)
+++ pjsip/src/pjsua-lib/pjsua_call.c	(working copy)
@@ -148,7 +148,26 @@
 			(void*)(pj_size_t)id, &reinv_timer_cb);
 }
 
+static void delete_call(void *user_data)
+{
+    pjsua_call *call = (pjsua_call *)user_data;
 
+    PJSUA_LOCK();
+
+    /* Free call */
+    call->inv = NULL;
+
+    pj_assert(pjsua_var.call_cnt > 0);
+    --pjsua_var.call_cnt;
+
+    /* Reset call */
+    reset_call(call->index);
+
+    pjsua_check_snd_dev_idle();
+
+    PJSUA_UNLOCK();
+}
+
 /*
  * Init call subsystem.
  */
@@ -3653,6 +3672,11 @@
 {
     pjsua_call *call;
 
+    /* IMPORTANT: Do not call PJSUA_LOCK() here as it may cause
+     * deadlock since this callback is called by the lower level
+     * module/component.
+     */
+
     pj_log_push_indent();
 
     call = (pjsua_call*) inv->dlg->mod_data[pjsua_var.mod.id];
@@ -3803,23 +3827,9 @@
 
     /* Destroy media session when invite session is disconnected. */
     if (inv->state == PJSIP_INV_STATE_DISCONNECTED) {
-
-	PJSUA_LOCK();
-
 	pjsua_media_channel_deinit(call->index);
-
-	/* Free call */
-	call->inv = NULL;
-
-	pj_assert(pjsua_var.call_cnt > 0);
-	--pjsua_var.call_cnt;
-
-	/* Reset call */
-	reset_call(call->index);
-
-	pjsua_check_snd_dev_idle();
-
-	PJSUA_UNLOCK();
+	
+	pjsua_schedule_timer2(delete_call, call, 0);
     }
     pj_log_pop_indent();
 }
_______________________________________________
Visit our blog: http://blog.pjsip.org

pjsip mailing list
pjsip@xxxxxxxxxxxxxxx
http://lists.pjsip.org/mailman/listinfo/pjsip_lists.pjsip.org

[Index of Archives]     [Asterisk Users]     [Asterisk App Development]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [Linux API]
  Powered by Linux