From 0239ae7122cfe01cd213a5afbeec2696e035a001 Mon Sep 17 00:00:00 2001 From: Philip Withnall Date: Tue, 8 Mar 2022 20:08:43 +0000 Subject: [PATCH 1/3] tests: Fix a leak in gdbus-test-codegen test MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The `ay` property has type `string` (see the generated code) since it’s not been annotated to force accepting a `GVariant`. This means the GObject property machinery expects a string, and calls `g_strdup()` on the passed-in pointer, rather than sinking the `GVariant`. Signed-off-by: Philip Withnall Helps: #2312 --- gio/tests/gdbus-test-codegen.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gio/tests/gdbus-test-codegen.c b/gio/tests/gdbus-test-codegen.c index 0681e7ec8..0701f50f1 100644 --- a/gio/tests/gdbus-test-codegen.c +++ b/gio/tests/gdbus-test-codegen.c @@ -869,7 +869,7 @@ check_bar_proxy (FooiGenBar *proxy, "s", "a string", "o", "/a/path", "g", "asig", - "ay", g_variant_new_parsed ("[byte 0x65, 0x67]"), + "ay", "eg", "as", array_of_strings, "ao", array_of_objpaths, "ag", g_variant_new_parsed ("[@g 'ass', 'git']"), From 9499aeb8bf79c48992552a221fb1a8b3bd263d17 Mon Sep 17 00:00:00 2001 From: Philip Withnall Date: Tue, 8 Mar 2022 20:09:59 +0000 Subject: [PATCH 2/3] tests: Wait for signal unsubscriptions in gdbus-test-codegen When destroying `GDBusProxy`s in a custom `GMainContext`, the context must be iterated enough after finalisation of the proxies that any pending D-Bus traffic, and the signal subscription data, can be freed. See the documentation for `g_dbus_connection_signal_unsubscribe()`. Signed-off-by: Philip Withnall Fixes: #2312 --- gio/tests/gdbus-test-codegen.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/gio/tests/gdbus-test-codegen.c b/gio/tests/gdbus-test-codegen.c index 0701f50f1..cd8424118 100644 --- a/gio/tests/gdbus-test-codegen.c +++ b/gio/tests/gdbus-test-codegen.c @@ -1382,6 +1382,12 @@ check_proxies_in_thread (gpointer user_data) g_object_unref (thread_proxy_1); g_object_unref (thread_proxy_2); + /* Wait for the proxy signals to all be unsubscribed. */ + while (g_main_context_iteration (thread_context, FALSE)) + { + /* Nothing needs to be done here */ + } + g_main_loop_unref (thread_loop); g_main_context_unref (thread_context); #endif From bed82b807fc99537da6ab96ec77fe4d6244c7752 Mon Sep 17 00:00:00 2001 From: Philip Withnall Date: Tue, 8 Mar 2022 20:11:24 +0000 Subject: [PATCH 3/3] tests: Re-enable address sanitizer for gdbus-test-codegen Now that the leaks are fixed, this test can be run under the sanitizer again. This is a partial revert of commit f3783520514a6ba8d15454e14175d086883cdb0f. Signed-off-by: Philip Withnall Helps: #2312 --- gio/tests/gdbus-test-codegen.c | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/gio/tests/gdbus-test-codegen.c b/gio/tests/gdbus-test-codegen.c index cd8424118..22628c078 100644 --- a/gio/tests/gdbus-test-codegen.c +++ b/gio/tests/gdbus-test-codegen.c @@ -23,8 +23,6 @@ #include #include -#include "glib/glib-private.h" - #include "gdbus-tests.h" #if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_64 @@ -1304,18 +1302,6 @@ static gpointer check_proxies_in_thread (gpointer user_data) { GMainLoop *loop = user_data; -#ifdef _GLIB_ADDRESS_SANITIZER - - /* Silence "Not available before 2.38" when using old API */ - G_GNUC_BEGIN_IGNORE_DEPRECATIONS - g_test_incomplete ("FIXME: Leaks a GWeakRef, see glib#2312"); - G_GNUC_END_IGNORE_DEPRECATIONS - - (void) check_thread_proxies; - (void) check_authorize_proxy; - (void) check_bat_proxy; - (void) check_bar_proxy; -#else GMainContext *thread_context; GMainLoop *thread_loop; GError *error; @@ -1390,7 +1376,6 @@ check_proxies_in_thread (gpointer user_data) g_main_loop_unref (thread_loop); g_main_context_unref (thread_context); -#endif /* this breaks out of the loop in main() (below) */ g_main_loop_quit (loop);