GNOME Bugzilla – Bug 566796
Deadlock using nested compositions
Last modified: 2009-01-07 12:13:15 UTC
Using nested compositions leads to a deadlock. Here's helgrind output: ==18146== Thread #5: Attempt to re-lock a non-recursive lock I already hold ==18146== at 0x4C26D35: pthread_mutex_lock (hg_intercepts.c:397) ==18146== by 0xA2291C9: gnl_composition_event_handler (gnlcomposition.c:919) ==18146== by 0x913A903: gst_pad_send_event (gstpad.c:4634) ==18146== by 0xA230635: no_more_pads_object_cb (gnlcomposition.c:1583) ==18146== by 0x626B25C: g_closure_invoke (in /usr/lib/libgobject-2.0.so.0.1800.2) ==18146== by 0x6280F5C: (within /usr/lib/libgobject-2.0.so.0.1800.2) ==18146== by 0x6282607: g_signal_emit_valist (in /usr/lib/libgobject-2.0.so.0.1800.2) ==18146== by 0x6282B32: g_signal_emit (in /usr/lib/libgobject-2.0.so.0.1800.2) ==18146== by 0x9114E81: gst_element_no_more_pads (gstelement.c:835) ==18146== by 0xA229BBC: gnl_composition_ghost_pad_set_target (gnlcomposition.c:1004) ==18146== by 0xA23044D: no_more_pads_object_cb (gnlcomposition.c:1574) ==18146== by 0x626B25C: g_closure_invoke (in /usr/lib/libgobject-2.0.so.0.1800.2) The deadlock is on COMP_OBJECTS_LOCK. After some debugging i came up with this patch: Index: gnl/gnlcomposition.c =================================================================== RCS file: /cvs/gstreamer/gnonlin/gnl/gnlcomposition.c,v retrieving revision 1.80 diff -u -r1.80 gnlcomposition.c --- gnl/gnlcomposition.c 28 Dec 2008 15:28:40 -0000 1.80 +++ gnl/gnlcomposition.c 6 Jan 2009 17:57:49 -0000 @@ -1000,8 +1000,11 @@ gst_pad_set_active (comp->private->ghostpad, TRUE); if (!(gst_element_add_pad (GST_ELEMENT (comp), comp->private->ghostpad))) GST_WARNING ("Couldn't add the ghostpad"); - else + else { + COMP_OBJECTS_UNLOCK (comp); gst_element_no_more_pads (GST_ELEMENT (comp)); + COMP_OBJECTS_LOCK (comp); + } } GST_DEBUG_OBJECT (comp, "END"); } I _think_ it's safe to release the lock, but i'm not 100% sure.
Created attachment 125916 [details] script to reproduce the bug
Created attachment 125919 [details] oops, the previous script was buggered
2009-01-07 Edward Hervey <edward.hervey@collabora.co.uk> Patch by: Alessandro Decina <alessandro.decina@collabora.co.uk> * gnl/gnlcomposition.c: (gnl_composition_ghost_pad_set_target): Release objects lock temporarily when emitting no-more-pads. This should not affect anything considering that the composition is in the process of being built at that point and no actions should be attempting to modify it while that lock is released. Fixes #566796