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 779548 - Don't leak the name_owner and result in dbus_proxy_reload_properties_sync
Don't leak the name_owner and result in dbus_proxy_reload_properties_sync
Status: RESOLVED FIXED
Product: gnome-online-accounts
Classification: Core
Component: Kerberos
3.22.x
Other Linux
: Normal normal
: ---
Assigned To: GNOME Online Accounts maintainer(s)
GNOME Online Accounts maintainer(s)
Depends on:
Blocks:
 
 
Reported: 2017-03-03 18:28 UTC by Debarshi Ray
Modified: 2017-05-30 17:31 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Valgrind logs (50.13 KB, text/plain)
2017-03-03 18:28 UTC, Debarshi Ray
  Details
kerberos: Don't leak the name_owner (1.84 KB, patch)
2017-03-03 18:46 UTC, Debarshi Ray
committed Details | Review
kerberos: Style fix (1.26 KB, patch)
2017-03-03 18:46 UTC, Debarshi Ray
committed Details | Review
kerberos: Don't leak the result (1.11 KB, patch)
2017-03-09 22:42 UTC, Debarshi Ray
committed Details | Review
daemon: Don't rely on G_DISABLE_ASSERT being undefined (1.27 KB, patch)
2017-03-10 13:42 UTC, Debarshi Ray
committed Details | Review

Description Debarshi Ray 2017-03-03 18:28:54 UTC
Created attachment 347160 [details]
Valgrind logs

The string returned by g_dbus_proxy_get_name_owner needs to be freed. See the attached valgrind log from https://bugzilla.redhat.com/show_bug.cgi?id=1420678
Comment 1 Debarshi Ray 2017-03-03 18:46:21 UTC
Created attachment 347162 [details] [review]
kerberos: Don't leak the name_owner
Comment 2 Debarshi Ray 2017-03-03 18:46:44 UTC
Created attachment 347163 [details] [review]
kerberos: Style fix
Comment 3 Debarshi Ray 2017-03-03 18:47:21 UTC
CCing Igor since he was suffering from a leak too.
Comment 4 Ray Strode [halfline] 2017-03-08 17:29:01 UTC
Review of attachment 347162 [details] [review]:

eek

::: src/goabackend/goakerberosprovider.c
@@ +1334,1 @@
+  name_owner = g_dbus_proxy_get_name_owner (proxy);

nice find.
Comment 5 Debarshi Ray 2017-03-08 18:30:17 UTC
Thanks for the review, halfline. Pushed to master, gnome-3-22 and gnome-3-20.
Comment 6 Debarshi Ray 2017-03-09 22:29:13 UTC
mclasen spotted another leak in the same function.
Comment 7 Debarshi Ray 2017-03-09 22:42:16 UTC
Created attachment 347585 [details] [review]
kerberos: Don't leak the result

Completely untested. Will try it out tomorrow.
Comment 8 Debarshi Ray 2017-03-10 13:42:38 UTC
Created attachment 347638 [details] [review]
daemon: Don't rely on G_DISABLE_ASSERT being undefined

Minor problem - noticed while staring at the code.
Comment 9 Ray Strode [halfline] 2017-03-10 14:30:49 UTC
Review of attachment 347585 [details] [review]:

hey, yea I was chatting with Matthias about this in meat space yesterday.

::: src/goabackend/goakerberosprovider.c
@@ +1360,3 @@
  out:
   g_clear_pointer (&iter, (GDestroyNotify) g_variant_iter_free);
+  g_clear_pointer (&result, (GDestroyNotify) g_variant_unref);

seems right to me. I almost wonder if this function should be gio ...
Comment 10 Ray Strode [halfline] 2017-03-10 14:36:51 UTC
Review of attachment 347638 [details] [review]:

another eeker.

::: src/daemon/goadaemon.c
@@ +1508,3 @@
+
+  task_queued = G_TASK (g_queue_pop_head (self->ensure_credentials_queue));
+  g_assert (task == task_queued);

this is fine, but another way you could do it is..

g_assert (g_queue_peek_head (self->ensur...) == user_data);

task = G_TASK (g_queue_pop_head (self->ensur...));

Would get rid of the barely used extra GTask declaration then. But it's just a subjective style thing, really.  Also, I'm not sure which style I like better.  I'm just throwing it out there as an alternative.
Comment 11 Debarshi Ray 2017-03-10 17:09:16 UTC
(In reply to Ray Strode [halfline] from comment #9)
> ::: src/goabackend/goakerberosprovider.c
> @@ +1360,3 @@
>   out:
>    g_clear_pointer (&iter, (GDestroyNotify) g_variant_iter_free);
> +  g_clear_pointer (&result, (GDestroyNotify) g_variant_unref);
> 
> seems right to me. I almost wonder if this function should be gio ...

You mean g_clear_variant? Same could be said for g_clear_hash_table too, I guess. However, the thing that really irks me is having to write a one-line GDestroyNotify that does:
    g_list_free_full (list, g_object_unref);
Comment 12 Debarshi Ray 2017-03-10 17:15:35 UTC
(In reply to Ray Strode [halfline] from comment #10)
> Review of attachment 347638 [details] [review] [review]:
> ::: src/daemon/goadaemon.c
> @@ +1508,3 @@
> +
> +  task_queued = G_TASK (g_queue_pop_head (self->ensure_credentials_queue));
> +  g_assert (task == task_queued);
> 
> this is fine, but another way you could do it is..
> 
> g_assert (g_queue_peek_head (self->ensur...) == user_data);
> 
> task = G_TASK (g_queue_pop_head (self->ensur...));
> 
> Would get rid of the barely used extra GTask declaration then. But it's just
> a subjective style thing, really.  Also, I'm not sure which style I like
> better.  I'm just throwing it out there as an alternative.

As a matter of style, I try to avoid using user_data after the initial cast to the right type to keep the proliferation of void pointers in check. Plus, spelling out the "task" makes the assertion marginally more readable for me.
Comment 13 Debarshi Ray 2017-03-10 17:16:14 UTC
Halfline, thanks for the quick reviews and the extensive debugging!
Comment 14 Debarshi Ray 2017-03-10 17:38:22 UTC
Pushed to master, gnome-3-22 and gnome-3-20.
Comment 15 Ray Strode [halfline] 2017-03-10 18:01:07 UTC
(In reply to Debarshi Ray from comment #11)
> (In reply to Ray Strode [halfline] from comment #9)
> > ::: src/goabackend/goakerberosprovider.c
> > @@ +1360,3 @@
> >   out:
> >    g_clear_pointer (&iter, (GDestroyNotify) g_variant_iter_free);
> > +  g_clear_pointer (&result, (GDestroyNotify) g_variant_unref);
> > 
> > seems right to me. I almost wonder if this function should be gio ...
> 
> You mean g_clear_variant?
no, i mean, i wonder if gio should have g_dbus_proxy_reload_properties_sync.  But let's just forget I brought it up unless we find another bug in the function :-)