GNOME Bugzilla – Bug 536521
Refcounting errors in playbin
Last modified: 2008-06-04 17:47:56 UTC
I'm getting occasional errors like: GLib-GObject-WARNING **: invalid unclassed pointer in cast to `GstPlayBaseBin' With G_DEBUG=fatal_warnings, I got this stack trace: (gdb) bt
+ Trace 199525
So, what seems to be happening is this: 1. My code hangs on to some things it gets via a bus messagefor a while. In this case, a message whose source is the decodebin inside playbin. That's fine; it has a reference to it. 2. We set playbin to NULL, then unref it. It gets freed. 3. We're now done with our bus message, so we unref it. This unrefs its source - the decodebin. 4. In GstBin's dispose method, it removes all its children. 5. And thus the element-removed signal is fired. Playbin connected to this signal (and never disconnected). Our callback tries to cast to a playbin instance... but it's been freed, so we explode. Patch to be attached disconnects the signals that playbin attaches to decodebin before unreffing decodebin.
Created attachment 112095 [details] [review] Patch to fix this This patch works for my code, but I'm not sure if there's a nicer fix. Suggestions welcomed.
Wim said on IRC that this code should be fine but he's not sure either if it's the best thing to do. So maybe let's get this in for now for the upcoming releases as it fixes a crash and add a FIXME above the code.
2008-06-04 Michael Smith <msmith@songbirdnest.com> * gst/playback/gstplaybasebin.c: Disconnect signals from decodebins we created before we remove it from playbin, to avoid crashes if the decodebin is eventually disposed after the playbin itself (possible if the app takes a reference on the decodebin). Fixes #536521.