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 768989 - leaks: update type filter later for unknown types
leaks: update type filter later for unknown types
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gstreamer (core)
git master
Other Linux
: Normal enhancement
: 1.9.2
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2016-07-20 10:23 UTC by Guillaume Desmottes
Modified: 2016-07-20 13:31 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
leaks: update type filter later for unknown types (2.97 KB, patch)
2016-07-20 10:24 UTC, Guillaume Desmottes
none Details | Review
leaks: update type filter later for unknown types (3.06 KB, patch)
2016-07-20 11:58 UTC, Guillaume Desmottes
none Details | Review
leaks: update type filter later for unknown types (3.33 KB, patch)
2016-07-20 12:36 UTC, Guillaume Desmottes
committed Details | Review

Description Guillaume Desmottes 2016-07-20 10:23:47 UTC
.
Comment 1 Guillaume Desmottes 2016-07-20 10:24:07 UTC
Created attachment 331811 [details] [review]
leaks: update type filter later for unknown types

This allow us to filter using an object type which is implemented by a
plugin like, say, GstGtkGLSink.
Comment 2 Tim-Philipp Müller 2016-07-20 11:24:33 UTC
Comment on attachment 331811 [details] [review]
leaks: update type filter later for unknown types

If I'm not mistaken this isn't thread-safe at all?

I believe objects and mini objects may be created simultaneously from multiple threads at the same time.
Comment 3 Guillaume Desmottes 2016-07-20 11:58:11 UTC
Oh right, we don't own the lock at this point. Fixing.
Comment 4 Guillaume Desmottes 2016-07-20 11:58:36 UTC
Created attachment 331817 [details] [review]
leaks: update type filter later for unknown types

This allow us to filter using an object type which is implemented by a
plugin like, say, GstGtkGLSink.
Comment 5 Tim-Philipp Müller 2016-07-20 11:59:36 UTC
It might also be more efficient to store the GQuarks for the type names in the hash table rather than the strings, and then look up the g_type_qname() instead (which also saves a few g_quark_to_string()). Maybe even get rid of the hash table entirely and just keep a GQuark * array of pending type name quarks? This is all micro-optimising of course ;)
Comment 6 Tim-Philipp Müller 2016-07-20 12:04:20 UTC
Comment on attachment 331817 [details] [review]
leaks: update type filter later for unknown types

>@@ -107,6 +116,24 @@ should_handle_object_type (GstLeaksTracer * self, GType object_type)
> 
>+  if (self->unhandled_filter) {
>+    const gchar *type_name;
>+
>+    type_name = g_type_name (object_type);
>+    GST_OBJECT_LOCK (self);
>+    if (g_hash_table_contains (self->unhandled_filter, type_name)) {
        ...
>+    }
>+    GST_OBJECT_UNLOCK (self);
>+  }

The if (self->unhandled_filter) is still unprotected.

Maybe add an atomic int to check if there are pending unhandled types, and if so take the lock and then do if (self->unhandled_filters) ... ? Or something like that, dunno :)
Comment 7 Guillaume Desmottes 2016-07-20 12:36:11 UTC
Oh yeah that's good ideas, thanks!
I implemented all your suggestions but kept the hash table as it makes the code easier and it should not be called that often (except if user passed an invalid object type as filter but it shouldn't be that common).
Comment 8 Guillaume Desmottes 2016-07-20 12:36:22 UTC
Created attachment 331818 [details] [review]
leaks: update type filter later for unknown types

This allow us to filter using an object type which is implemented by a
plugin like, say, GstGtkGLSink.
Comment 9 Tim-Philipp Müller 2016-07-20 13:31:25 UTC
Cool, thanks.

commit 714ea372827acce932a26c5ebe77537a0fb8c34f
Author: Guillaume Desmottes <guillaume.desmottes@collabora.co.uk>
Date:   Wed Jul 20 12:22:10 2016 +0200

    tracers: leaks: update type filter later for unknown types
    
    This allow us to filter using an object type which is implemented
    by a plugin like, say, GstGtkGLSink.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=768989