[gst-devel] A case where dispose can be called multiple times

Andy Wingo wingo at pobox.com
Fri Mar 5 06:48:05 CET 2004


Hey folks,

Just came across a case where dispose can be called multiple times.
Consider the case of an element in the PLAYING state whose last
reference belongs to a garbage-collected wrapper. If the wrapper gets
collected, the last reference will go, meaning that the dispose
functions are called, among them gst_element_dispose, which will set the
element's state to NULL if it wasn't there already.

Changing states emits the state-changed signal, and if that signal is
being listened to by an interpreted-lanugage closure, a new wrapper will
be created to represent the object, which will then reference the object
again.

Perhaps that wrapper won't get collected until later. In any case, its
collection will trigger *another* dispose, which won't emit any signals
because it's already in NULL, and after the dispose the refcount will be
0 so finalize can (finally) be run.

Sounds far-fetched, but it happens. Of course the same is true with the
other signals emitted in dispose functions, unlinked and pad-removed.
-- 
Andy Wingo <wingo at pobox.com>




More information about the gstreamer-devel mailing list