GNOME Bugzilla – Bug 142813
[PATCH] Deadlock in optimal scheduler
Last modified: 2004-12-22 21:47:04 UTC
When a group gets scheduled by the non-cothread version of the optimal scheduler, a "pre-run" and "post-run" function is executed for each element in the group. However, if the group is altered during the iteration such that an element is removed from that particular group, the post-run function is not executed for that element. This causes a deadlock the next time the element is iterated, because it's properties mutex has been locked by the pre-run function, but never unlocked by the post-run function. For example, this scenario would happen with this pipeline: filesrc ! spider ! osssink If we play a song until EOS, and then delete the spider element during the EOS handler, both filesrc and osssink will be removed from the group. If we then create a new spider and link it back together with the same filesrc and osssink, the osssink and filesrc properties mutex's will deadlock the first time they are iterated.
Created attachment 27860 [details] [review] Patch to fix deadlock This patch fixes the aforementioned deadlock by creating a reference to each element of the group before its pre-run function is executed. The list of elements is duplicated, so we can run the post-run function later for each element that we ran the pre-run function for, even if the group changes during the iteration. After the iteration, we run the post-run functions, and unref each element. The patch applies to 0.8.1, and I've also tested it with 0.8.1, but I suspect it also works fine with HEAD.
The patch is almost correct, it does not free the copied list. In the testsuite is now a testapp that demonstrates the deadlock, after applying your patch (+g_slist_free) the tests work fine. Going to test some more and push it for the next release.
Created attachment 29654 [details] [review] improved patch improved patch. frees the list and makes sure that the right thing even happens when the post/pre functions mess with the group element list.
deadlock with patch, marking as blocker.