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 755505 - ges: trivial leakages
ges: trivial leakages
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gst-editing-services
git master
Other Linux
: Normal normal
: git master
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2015-09-24 05:36 UTC by Justin Kim
Modified: 2015-10-01 15:42 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
[1/4] pitivi-formatter (758 bytes, patch)
2015-09-24 05:36 UTC, Justin Kim
committed Details | Review
[2/4] timeline-element (730 bytes, patch)
2015-09-24 05:37 UTC, Justin Kim
rejected Details | Review
[3/4] uri-asset (1.97 KB, patch)
2015-09-24 05:37 UTC, Justin Kim
committed Details | Review
[4/4] pipeline (620 bytes, patch)
2015-09-24 05:38 UTC, Justin Kim
committed Details | Review

Description Justin Kim 2015-09-24 05:36:05 UTC
Here are trivial leakages I found.
Comment 1 Justin Kim 2015-09-24 05:36:47 UTC
Created attachment 311998 [details] [review]
[1/4] pitivi-formatter
Comment 2 Justin Kim 2015-09-24 05:37:13 UTC
Created attachment 311999 [details] [review]
[2/4] timeline-element
Comment 3 Justin Kim 2015-09-24 05:37:38 UTC
Created attachment 312000 [details] [review]
[3/4] uri-asset
Comment 4 Justin Kim 2015-09-24 05:38:03 UTC
Created attachment 312001 [details] [review]
[4/4] pipeline
Comment 5 Thibault Saunier 2015-09-24 07:36:56 UTC
Review of attachment 311998 [details] [review]:

Looks good

::: ges/ges-pitivi-formatter.c
@@ -689,2 +689,2 @@
   if (priv->clips_table != NULL) {
     g_hash_table_foreach (priv->clips_table,

I wonder why priv->clips_table is not instanciate with g_hash_table_new_full and list_table_destroyer as GDestroyFunc. Not a big deal anyway :)
Comment 6 Thibault Saunier 2015-09-24 07:39:08 UTC
Review of attachment 311999 [details] [review]:

::: ges/ges-timeline-element.c
@@ -263,1 +263,3 @@
   G_OBJECT_CLASS (ges_timeline_element_parent_class)->finalize (self);
+
+  if (object_name_counts)

Looks wrong, that is a static global counter which should be kept alive for the whole duration of the process and be cleared only on ges_deinit (which I do not remember whether it exists or not :))
Comment 7 Thibault Saunier 2015-09-24 07:40:48 UTC
Review of attachment 312000 [details] [review]:

Why can't we just use priv->uri ?
Comment 8 Thibault Saunier 2015-09-24 07:41:36 UTC
Review of attachment 312001 [details] [review]:

OK
Comment 9 Justin Kim 2015-09-24 08:32:25 UTC
Review of attachment 312000 [details] [review]:

::: ges/ges-uri-asset.c
@@ +598,2 @@
   if (g_str_has_prefix (priv->uri, GES_MULTI_FILE_URI_PREFIX)) {
+    trackelement = GES_TRACK_ELEMENT (ges_multi_file_source_new (uri));

Up to this point, this is exactly same as left, but the different thing is whether uri is freed at line 612.
I think I cannot free priv->uri directly because it is used by the other functions.

@@ -595,3 @@
   if (g_str_has_prefix (priv->uri, GES_MULTI_FILE_URI_PREFIX)) {
-    trackelement =
-        GES_TRACK_ELEMENT (ges_multi_file_source_new (g_strdup (priv->uri)));

ges_####_file_source_new also copies string by g_strdup inside. Therefore, as a result, one more duplicated string is created and not freed.
Comment 10 Justin Kim 2015-09-24 08:38:23 UTC
Review of attachment 311999 [details] [review]:

::: ges/ges-timeline-element.c
@@ -263,1 +263,3 @@
   G_OBJECT_CLASS (ges_timeline_element_parent_class)->finalize (self);
+
+  if (object_name_counts)

I thought the lifecycle of object_name_counts variable should be same with timeline-lement because it is defined as static and local variable.

If the purpose of this quark container is to trace object number, how about replacing this with atomic operations like 'g_atomic_int_inc' to make code simple?
Comment 11 Thibault Saunier 2015-09-24 10:16:26 UTC
(In reply to Justin J. Kim from comment #9)
> Review of attachment 312000 [details] [review] [review]:
> 
> ::: ges/ges-uri-asset.c
> @@ +598,2 @@
>    if (g_str_has_prefix (priv->uri, GES_MULTI_FILE_URI_PREFIX)) {
> +    trackelement = GES_TRACK_ELEMENT (ges_multi_file_source_new (uri));
> 
> Up to this point, this is exactly same as left, but the different thing is
> whether uri is freed at line 612.
> I think I cannot free priv->uri directly because it is used by the other
> functions.

My mistake, thanks for the explanation.

(In reply to Justin J. Kim from comment #10)
> Review of attachment 311999 [details] [review] [review]:
> 
> ::: ges/ges-timeline-element.c
> @@ -263,1 +263,3 @@
>    G_OBJECT_CLASS (ges_timeline_element_parent_class)->finalize (self);
> +
> +  if (object_name_counts)
> 
> I thought the lifecycle of object_name_counts variable should be same with
> timeline-lement because it is defined as static and local variable.

https://phabricator.freedesktop.org/diffusion/GES/browse/master/ges/ges-timeline-element.c;0b900bddc9eb534535e57c42afd27b6fc8d97399$39

I am not sure what you mean, did I miss something? :)

> If the purpose of this quark container is to trace object number, how about
> replacing this with atomic operations like 'g_atomic_int_inc' to make code
> simple?

It is a bit more complex than that as we keep a counter for each object type (name).
Comment 12 Thibault Saunier 2015-09-24 10:16:38 UTC
Review of attachment 312000 [details] [review]:

OK then.
Comment 13 Justin Kim 2015-09-25 09:51:09 UTC
(In reply to Thibault Saunier from comment #11)
> (In reply to Justin J. Kim from comment #9)
> > I thought the lifecycle of object_name_counts variable should be same with
> > timeline-lement because it is defined as static and local variable.
> 
> https://phabricator.freedesktop.org/diffusion/GES/browse/master/ges/ges-
> timeline-element.c;0b900bddc9eb534535e57c42afd27b6fc8d97399$39
> 
> I am not sure what you mean, did I miss something? :)
> 
> It is a bit more complex than that as we keep a counter for each object type
> (name).

Ah. I might choose wrong English word to explain "local". :)
What I want to say is that object_name_count variable is global variable, but it is created only by timeline-element. Therefore, I was thinking creator should call destroyer also.

OR, how about to make/define the APIs of this quark container as library? instead of using it only inside of timeline-element.

I mean, 
rather than calling like this, 
https://phabricator.freedesktop.org/diffusion/GES/browse/master/ges/ges-timeline-element.c;0b900bddc9eb534535e57c42afd27b6fc8d97399$435

using another function like, ges_quark_next_count (q); 


It could be off-topic though, can I use arcanist for my proposed patch?
phabricator looks like more simple than bugzilla to submit patch. :)
Comment 14 Thibault Saunier 2015-09-25 10:08:11 UTC
(In reply to Justin J. Kim from comment #13)
> (In reply to Thibault Saunier from comment #11)
> > (In reply to Justin J. Kim from comment #9)
> > > I thought the lifecycle of object_name_counts variable should be same with
> > > timeline-lement because it is defined as static and local variable.
> > 
> > https://phabricator.freedesktop.org/diffusion/GES/browse/master/ges/ges-
> > timeline-element.c;0b900bddc9eb534535e57c42afd27b6fc8d97399$39
> > 
> > I am not sure what you mean, did I miss something? :)
> > 
> > It is a bit more complex than that as we keep a counter for each object type
> > (name).
> 
> 
> I mean, 
> rather than calling like this, 
> https://phabricator.freedesktop.org/diffusion/GES/browse/master/ges/ges-
> timeline-element.c;0b900bddc9eb534535e57c42afd27b6fc8d97399$435
> 
> using another function like, ges_quark_next_count (q); 

Sure, would be cleaner (though that naming does not sound right :))

> It could be off-topic though, can I use arcanist for my proposed patch?
> phabricator looks like more simple than bugzilla to submit patch. :)

For GES I have no problem but you should not use it for anything else (the migration is not done yet, there is nothing official yet, and I am more or less the only one using it right now)