GNOME Bugzilla – Bug 737794
multiqueue: deadlock if queue overruns with serialized events
Last modified: 2014-10-14 07:43:59 UTC
If a serialzed event goes into a queue but the queue overruns we hit a deadlock on the multiqueue lock. See Thread 21:
+ Trace 234165
Thread 21 (Thread 0x7f05d4ff9700 (LWP 59217))
Thread 19 (Thread 0x7f05a3fff700 (LWP 59221))
Thread 55 (Thread 0x7f05f6bbd700 (LWP 55195))
Created attachment 287613 [details] [review] release lock before pushing the serialized event
(In reply to comment #1) > Created an attachment (id=287613) [details] [review] > release lock before pushing the serialized event The deadlock is there, but I'm not sure if this patch is correct. I'm observing a different behavior in my application.
Review of attachment 287613 [details] [review]: ::: plugins/elements/gstmultiqueue.c @@ +1867,1 @@ g_cond_wait (&sq->query_handled, &mq->qlock); This causes a race condition. The query (not event!) can already be taken out of the queue again before you lock again and wait for the condition variable, leading to another deadlock caused by waiting forever for the condition variable to be signalled. Why does the dataqueue block in your case? There's a check above that will only consider putting it in the dataqueue in certain conditions. Which is true in your case? !use_buffering? Why is the queue never emptying in your case, which would lead to the deadlock solving itself?
Oh I just noticed... the deadlock comes from the overrun callback which takes the same mutex. I think we need to unlock the mutex in any case then, but need to make sure that the above mentioned new deadlock does not happen. For this you could remember if and which query was answered last, and check that before waiting for the condition variable.
Created attachment 288057 [details] [review] release lock before pushing a serialized query Let's see this one. It's working so far. I just save the last handled query and compare that before waiting on the condition variable.
Created attachment 288090 [details] [review] release lock before pushing a serialized query Same patch as before with comments.
commit 41fa9ad9f293c2079b0a3bf6ccee08ec39753d91 Author: Aleix Conchillo Flaqué <aleix@oblong.com> Date: Wed Oct 8 09:37:41 2014 -0700 multiqueue: don't lock multiqueue when pushing serialized queries If we are pushing a serialized query into a queue and the queue is filled, we will end in a deadlock. We need to release the lock before pushing and acquire it again afterward. https://bugzilla.gnome.org/show_bug.cgi?id=737794