leaks: warn if object is destroyed while the tracer is disposing

This should not happen and generally means some thread is still running.

https://bugzilla.gnome.org/show_bug.cgi?id=768578
This commit is contained in:
Guillaume Desmottes 2016-07-08 16:53:51 +02:00 committed by Tim-Philipp Müller
parent 40727d9c83
commit 9ba53ff1fc
2 changed files with 11 additions and 0 deletions

View file

@ -153,11 +153,19 @@ static void
handle_object_destroyed (GstLeaksTracer * self, gpointer object)
{
GST_OBJECT_LOCK (self);
if (self->done) {
g_warning
("object %p destroyed while the leaks tracer was finalizing. Some threads are still running?",
object);
goto out;
}
g_hash_table_remove (self->objects, object);
#ifdef G_OS_UNIX
if (self->removed)
g_hash_table_add (self->removed, object_log_new (object));
#endif /* G_OS_UNIX */
out:
GST_OBJECT_UNLOCK (self);
}
@ -447,6 +455,8 @@ gst_leaks_tracer_finalize (GObject * object)
GHashTableIter iter;
gpointer obj;
self->done = TRUE;
/* Tracers are destroyed as part of gst_deinit() so now is a good time to
* report all the objects which are still alive. */
leaks = log_leaked (self);

View file

@ -60,6 +60,7 @@ struct _GstLeaksTracer {
GHashTable *added;
/* Set of owned ObjectLog. Protected by object lock */
GHashTable *removed;
gboolean done;
gboolean log_stack_trace;
};