After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 566796 - Deadlock using nested compositions
Deadlock using nested compositions
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gnonlin
git master
Other Linux
: Normal normal
: 0.10.11
Assigned To: GStreamer Maintainers
Edward Hervey
Depends on:
Blocks:
 
 
Reported: 2009-01-06 18:04 UTC by Alessandro Decina
Modified: 2009-01-07 12:13 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
script to reproduce the bug (2.94 KB, text/plain)
2009-01-07 10:51 UTC, Alessandro Decina
Details
oops, the previous script was buggered (3.22 KB, text/x-python)
2009-01-07 11:09 UTC, Alessandro Decina
Details

Description Alessandro Decina 2009-01-06 18:04:31 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.
Comment 1 Alessandro Decina 2009-01-07 10:51:46 UTC
Created attachment 125916 [details]
script to reproduce the bug
Comment 2 Alessandro Decina 2009-01-07 11:09:03 UTC
Created attachment 125919 [details]
oops, the previous script was buggered
Comment 3 Edward Hervey 2009-01-07 12:13:15 UTC
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