GNOME Bugzilla – Bug 776039
queue: deadlock between sink query and state change
Last modified: 2016-12-22 12:48:46 UTC
Created attachment 341864 [details] Test case A queue can deadlock, if it is handling a sink query and a state change at the same time. This seems to be a regression introduced by 722ad087338520047241a319a506e464017bf0da discussed in https://bugzilla.gnome.org/show_bug.cgi?id=763496 I have attached a test application. With the current master (49f1f35), I hit a repeatable deadlock within seconds. If I revert 722ad087338520047241a319a506e464017bf0da the deadlock does not happen. A trace of the deadlock with gstreamer sources on 49f1f35:
+ Trace 236975
Thread 169 (Thread 0x7fffeffff700 (LWP 26643))
Thread 6 (Thread 0x7fffef7fe700 (LWP 26480))
Thread 3 (Thread 0x7ffff49ad700 (LWP 26477))
Thread 1 (Thread 0x7ffff7fc6700 (LWP 26471))
I can confirm, but not sure why.
Reason is that stopping a task fast enough after starting it, will cause the loop function to be never called. And we do shutdown from src to sink, that is we require the loop function to unlock all things (otherwise we end up with the above mentioned bug again, and unref a query that downstream is still using).
This is a duplicate of https://bugzilla.gnome.org/show_bug.cgi?id=774854?
Possible. I have a fix, will put here after some more testing and then you can tell me ;)
Created attachment 341903 [details] [review] queue/queue2: Ensure that the streaming thread is unlocked after deactivating the srcpad It might happen that the srcpad task function is never called at all, in which case unlocking everything from there will never happen. Make sure to unlock everything another time after the task function is definitely stopped.
The proposed patch seems to work on the test case, as well as the application where I originally saw the issue.
Multiqueue needs some unrelated fixes still commit 3fab00b46aad44e0375988fd61e13e900fa114a4 Author: Sebastian Dröge <sebastian@centricular.com> Date: Tue Dec 13 20:51:17 2016 +0200 queue/queue2: Protect against spurious condition variable wakeups Make sure that we only wake up when we have to flush, or when this specific query was handled. https://bugzilla.gnome.org/show_bug.cgi?id=776039 commit 33c239828bd0563114fddb4fece75f95a986d41e Author: Sebastian Dröge <sebastian@centricular.com> Date: Tue Dec 13 20:00:55 2016 +0200 queue/queue2: Ensure that the streaming thread is unlocked after deactivating the srcpad It might happen that the srcpad task function is never called at all, in which case unlocking everything from there will never happen. Make sure to unlock everything another time after the task function is definitely stopped. https://bugzilla.gnome.org/show_bug.cgi?id=776039
*** Bug 774854 has been marked as a duplicate of this bug. ***