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 711802 - Fix memory leaks in libgio tests
Fix memory leaks in libgio tests
Status: RESOLVED OBSOLETE
Product: glib
Classification: Platform
Component: gio
unspecified
Other Linux
: Normal normal
: ---
Assigned To: gtkdev
gtkdev
Depends on: 725503
Blocks: 711799
 
 
Reported: 2013-11-10 21:06 UTC by Stef Walter
Modified: 2018-05-24 15:59 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
buffered-output-stream: Fix some access after free (2.17 KB, patch)
2013-11-10 21:07 UTC, Stef Walter
committed Details | Review
data-output-stream: Fix some access after free (2.18 KB, patch)
2013-11-10 21:07 UTC, Stef Walter
committed Details | Review
contexts: Fix memory leak in test (796 bytes, patch)
2013-11-10 21:07 UTC, Stef Walter
committed Details | Review
g-icon: Fix memory leak in test (618 bytes, patch)
2013-11-10 21:09 UTC, Stef Walter
committed Details | Review
gsubprocess: Fix error detection logic in tests (4.83 KB, patch)
2013-11-10 21:10 UTC, Stef Walter
committed Details | Review
gsubprocess: Fix leaks in tests (1.10 KB, patch)
2013-11-10 21:11 UTC, Stef Walter
committed Details | Review
gdbus-auth: Fix leaks in tests (1.00 KB, patch)
2013-11-10 21:21 UTC, Stef Walter
committed Details | Review
gdbus-connection: Fix use after free in test (868 bytes, patch)
2013-11-10 21:22 UTC, Stef Walter
committed Details | Review
gdbus-connection-slow: Fix leak in tests (1022 bytes, patch)
2013-11-10 21:22 UTC, Stef Walter
committed Details | Review
gdbus-connection: Fix leaks in tests (1.32 KB, patch)
2013-11-10 21:22 UTC, Stef Walter
committed Details | Review
gdbus-export: Fix leaks in tests (2.04 KB, patch)
2013-11-10 21:23 UTC, Stef Walter
committed Details | Review
gdbus-introspection: Fix leaks in tests (1.06 KB, patch)
2013-11-10 21:23 UTC, Stef Walter
committed Details | Review
gdbus-connection-loss: Fix leak in test (701 bytes, patch)
2013-11-10 21:26 UTC, Stef Walter
needs-work Details | Review

Description Stef Walter 2013-11-10 21:06:30 UTC
In order to make libgio tests be valgrindable, I'll post patches
which fix memory leaks.

In general it's good practice to free stuff in tests, so that we can run
through those code paths, and make sure we received appropriate
references/memory.
Comment 1 Stef Walter 2013-11-10 21:07:32 UTC
Created attachment 259479 [details] [review]
buffered-output-stream: Fix some access after free

The memory pointed to by a GMemoryOutputStream can be realloc'd
Comment 2 Stef Walter 2013-11-10 21:07:37 UTC
Created attachment 259480 [details] [review]
data-output-stream: Fix some access after free

The memory pointed to by a GMemoryOutputStream can be realloc'd
Comment 3 Stef Walter 2013-11-10 21:07:41 UTC
Created attachment 259481 [details] [review]
contexts: Fix memory leak in test
Comment 4 Stef Walter 2013-11-10 21:09:05 UTC
Created attachment 259484 [details] [review]
g-icon: Fix memory leak in test
Comment 5 Stef Walter 2013-11-10 21:10:55 UTC
Created attachment 259486 [details] [review]
gsubprocess: Fix error detection logic in tests

Various tests were depending on local_error being set by a callback
when it could never have been the case. Simplify async error detection
logic in those cases, and fix leak of GError.
Comment 6 Stef Walter 2013-11-10 21:11:00 UTC
Created attachment 259487 [details] [review]
gsubprocess: Fix leaks in tests
Comment 7 Stef Walter 2013-11-10 21:21:31 UTC
Created attachment 259497 [details] [review]
gdbus-auth: Fix leaks in tests
Comment 8 Stef Walter 2013-11-10 21:22:24 UTC
Created attachment 259498 [details] [review]
gdbus-connection: Fix use after free in test
Comment 9 Stef Walter 2013-11-10 21:22:29 UTC
Created attachment 259499 [details] [review]
gdbus-connection-slow: Fix leak in tests
Comment 10 Stef Walter 2013-11-10 21:22:34 UTC
Created attachment 259500 [details] [review]
gdbus-connection: Fix leaks in tests
Comment 11 Stef Walter 2013-11-10 21:23:45 UTC
Created attachment 259502 [details] [review]
gdbus-export: Fix leaks in tests
Comment 12 Stef Walter 2013-11-10 21:23:50 UTC
Created attachment 259503 [details] [review]
gdbus-introspection: Fix leaks in tests
Comment 13 Stef Walter 2013-11-10 21:26:04 UTC
Created attachment 259506 [details] [review]
gdbus-connection-loss: Fix leak in test
Comment 14 Matthias Clasen 2013-11-11 02:23:07 UTC
Review of attachment 259479 [details] [review]:

sure
Comment 15 Matthias Clasen 2013-11-11 03:50:23 UTC
Review of attachment 259480 [details] [review]:

sure
Comment 16 Matthias Clasen 2013-11-11 03:51:28 UTC
Review of attachment 259481 [details] [review]:

ok
Comment 17 Matthias Clasen 2013-11-11 03:56:59 UTC
Review of attachment 259484 [details] [review]:

sure
Comment 18 Matthias Clasen 2013-11-11 03:58:30 UTC
Review of attachment 259486 [details] [review]:

humm, ok
Comment 19 Matthias Clasen 2013-11-11 04:00:16 UTC
Review of attachment 259487 [details] [review]:

absolutely
Comment 20 Matthias Clasen 2013-11-11 04:03:03 UTC
Review of attachment 259497 [details] [review]:

::: gio/tests/gdbus-auth.c
@@ +199,3 @@
   g_thread_join (client_thread);
 
+  while (g_main_context_iteration (NULL, FALSE));

The empty loop body looks a little deceptive here. Maybe

do {
} while (...);

would make it more obvious ?
Comment 21 Matthias Clasen 2013-11-11 04:04:40 UTC
Review of attachment 259498 [details] [review]:

ugh, yes
Comment 22 Matthias Clasen 2013-11-11 04:08:55 UTC
Review of attachment 259499 [details] [review]:

ok
Comment 23 Matthias Clasen 2013-11-11 04:14:52 UTC
Review of attachment 259500 [details] [review]:

sure
Comment 24 Matthias Clasen 2013-11-11 04:22:15 UTC
Review of attachment 259502 [details] [review]:

Not sure I see why you need to strdup the dyna_data members - what does that fix ?
Comment 25 Matthias Clasen 2013-11-11 04:23:25 UTC
Review of attachment 259503 [details] [review]:

ok
Comment 26 Matthias Clasen 2013-11-11 04:23:51 UTC
Review of attachment 259506 [details] [review]:

ok
Comment 27 Stef Walter 2013-11-11 05:59:07 UTC
Review of attachment 259502 [details] [review]:

::: gio/tests/gdbus-export.c
@@ +1203,2 @@
   /* now register a dynamic subtree, spawning objects as they are called */
+  dyna_data = g_ptr_array_new_with_free_func (g_free);

The array now contains heap allocated strings, freed with g_free(). Previously only one of the items were allocated on the heap. Now they all are.
Comment 28 Stef Walter 2013-11-11 06:17:14 UTC
Thanks for the review. First pass pushing patches that don't need modification.

Attachment 259479 [details] pushed as 7217124 - buffered-output-stream: Fix some access after free
Attachment 259480 [details] pushed as 438f711 - data-output-stream: Fix some access after free
Attachment 259481 [details] pushed as faafd4c - contexts: Fix memory leak in test
Attachment 259484 [details] pushed as 78ad171 - g-icon: Fix memory leak in test
Attachment 259486 [details] pushed as fe3c878 - gsubprocess: Fix error detection logic in tests
Attachment 259487 [details] pushed as 95526b5 - gsubprocess: Fix leaks in tests
Attachment 259498 [details] pushed as 0d51ff7 - gdbus-connection: Fix use after free in test
Attachment 259499 [details] pushed as f80e269 - gdbus-connection-slow: Fix leak in tests
Attachment 259500 [details] pushed as 91c8fb8 - gdbus-connection: Fix leaks in tests
Comment 29 Stef Walter 2013-11-11 07:45:47 UTC
(In reply to comment #20)
> Review of attachment 259497 [details] [review]:
> 
> ::: gio/tests/gdbus-auth.c
> @@ +199,3 @@
>    g_thread_join (client_thread);
> 
> +  while (g_main_context_iteration (NULL, FALSE));
> 
> The empty loop body looks a little deceptive here. Maybe
> 
> do {
> } while (...);
> 
> would make it more obvious ?

Hmmm, this is fairly common (esp. when dealing testing gdbus or stuff that uses it). It would be a shame if every instance turned into three lines. Do you think a new function like g_main_context_drain() is in order?
Comment 30 Stef Walter 2013-11-11 07:53:29 UTC
Attachment 259503 [details] pushed as 14b27ea - gdbus-introspection: Fix leaks in tests
Attachment 259506 [details] pushed as 670379b - gdbus-connection-loss: Fix leak in test
Comment 31 Matthias Clasen 2013-11-11 13:17:43 UTC
Review of attachment 259502 [details] [review]:

ah, I missed that point. Would be good to put that explanation in the commit message
Comment 32 Stef Walter 2013-11-13 11:41:47 UTC
Comment on attachment 259506 [details] [review]
gdbus-connection-loss: Fix leak in test

Was causing distcheck to fail for Ryan, reverted.
Comment 33 Matthias Clasen 2013-12-16 02:07:44 UTC
Attachment 259497 [details] pushed as db6a297 - gdbus-auth: Fix leaks in tests
Attachment 259502 [details] pushed as baed90a - gdbus-export: Fix leaks in tests
Comment 34 Philip Withnall 2017-10-24 11:49:21 UTC
(In reply to Stef Walter from comment #32)
> Comment on attachment 259506 [details] [review] [review]
> gdbus-connection-loss: Fix leak in test
> 
> Was causing distcheck to fail for Ryan, reverted.

I’ve applied this patch locally and run the test in a loop, and eventually reproduced the failure, which looks like bug #725503:

(gdb) t a a bt

Thread 1 (Thread 0x7fe0d9272c40 (LWP 9733))

  • #0 _g_log_abort
    at /opt/gnome/source/glib/glib/gmessages.c line 568
  • #1 g_logv
    at /opt/gnome/source/glib/glib/gmessages.c line 1376
  • #2 g_log
    at /opt/gnome/source/glib/glib/gmessages.c line 1417
  • #3 g_return_if_fail_warning
  • #4 g_source_set_ready_time
    at /opt/gnome/source/glib/glib/gmain.c line 1846
  • #5 cancellable_source_cancelled
    at /opt/gnome/source/glib/gio/gcancellable.c line 653
  • #6 g_cclosure_marshal_VOID__VOID
    at /opt/gnome/source/glib/gobject/gmarshal.c line 875
  • #7 g_closure_invoke
    at /opt/gnome/source/glib/gobject/gclosure.c line 804
  • #8 signal_emit_unlocked_R
    at /opt/gnome/source/glib/gobject/gsignal.c line 3635
  • #9 g_signal_emit_valist
    at /opt/gnome/source/glib/gobject/gsignal.c line 3391
  • #10 g_signal_emit
    at /opt/gnome/source/glib/gobject/gsignal.c line 3447
  • #11 g_cancellable_cancel
    at /opt/gnome/source/glib/gio/gcancellable.c line 508
  • #12 _g_dbus_worker_close
    at /opt/gnome/source/glib/gio/gdbusprivate.c line 1712
  • #13 _g_dbus_worker_stop
    at /opt/gnome/source/glib/gio/gdbusprivate.c line 1733
  • #14 g_dbus_connection_dispose
    at /opt/gnome/source/glib/gio/gdbusconnection.c line 630
  • #15 g_object_unref
    at /opt/gnome/source/glib/gobject/gobject.c line 3293
  • #16 ensure_gdbus_testserver_up
    at /opt/gnome/source/glib/gio/tests/gdbus-tests.c line 129
  • #17 main
    at /opt/gnome/source/glib/gio/tests/gdbus-connection-loss.c line 127

Comment 35 GNOME Infrastructure Team 2018-05-24 15:59:38 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to GNOME's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.gnome.org/GNOME/glib/issues/786.