From 41bd0fddcd366cf5a0e92d190f8ac297866a6089 Mon Sep 17 00:00:00 2001 From: Philip Withnall Date: Tue, 24 Jan 2023 11:20:04 +0000 Subject: [PATCH 1/3] glib.supp: Further ignore system thread allocations This should stop the following valgrind error: ``` ==14506== 80 bytes in 1 blocks are definitely lost in loss record 1,098 of 1,463 ==14506== at 0x484086F: malloc (vg_replace_malloc.c:381) ==14506== by 0x48C5D83: g_malloc (gmem.c:130) ==14506== by 0x48E7911: g_slice_alloc (gslice.c:1074) ==14506== by 0x48E7951: g_slice_alloc0 (gslice.c:1100) ==14506== by 0x493617D: g_system_thread_new (gthread-posix.c:1188) ==14506== by 0x48F9EAA: g_thread_new_internal (gthread.c:935) ==14506== by 0x48F9E29: g_thread_try_new (gthread.c:919) ==14506== by 0x48FA351: g_thread_pool_spawn_thread (gthreadpool.c:312) ==14506== by 0x48F9D2C: g_thread_proxy (gthread.c:831) ==14506== by 0x4EFA2A4: start_thread (in /usr/lib64/libpthread-2.33.so) ==14506== by 0x4D89322: clone (in /usr/lib64/libc-2.33.so) ``` Signed-off-by: Philip Withnall --- tools/glib.supp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/glib.supp b/tools/glib.supp index 5b03557d9d..941d64bc98 100644 --- a/tools/glib.supp +++ b/tools/glib.supp @@ -505,7 +505,7 @@ { g-system-thread-init-malloc Memcheck:Leak - match-leak-kinds:possible,reachable + match-leak-kinds:possible,reachable,definite fun:malloc ... fun:g_system_thread_new -- GitLab From 90af624d5b25156fa5ebc9c011a0fb830e8f1756 Mon Sep 17 00:00:00 2001 From: Philip Withnall Date: Tue, 24 Jan 2023 11:20:35 +0000 Subject: [PATCH 2/3] glib.supp: Add suppression for the one-time allocation in g_get_tmp_dir() Signed-off-by: Philip Withnall --- tools/glib.supp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/tools/glib.supp b/tools/glib.supp index 941d64bc98..9ff78cc15d 100644 --- a/tools/glib.supp +++ b/tools/glib.supp @@ -843,7 +843,7 @@ # _g_unset_cached_tmp_dir() deliberately leaks the previous cached g_get_tmp_dir() values. # These will not all be reachable on exit. { - g_get_tmp_dir + g_get_tmp_dir_test_init Memcheck:Leak match-leak-kinds:definite,reachable fun:malloc @@ -853,6 +853,16 @@ fun:g_test_init } +# g_get_tmp_dir() caches a one-time allocation +{ + g_get_tmp_dir + Memcheck:Leak + match-leak-kinds:definite,reachable + fun:malloc + ... + fun:g_get_tmp_dir +} + # g_get_system_data_dirs() caches a one-time allocation { g_get_system_data_dirs -- GitLab From 73205b8bbdfa1a3403689aa0cb9fd0525bff506b Mon Sep 17 00:00:00 2001 From: Philip Withnall Date: Tue, 24 Jan 2023 11:25:34 +0000 Subject: [PATCH 3/3] tests: Explicitly remove a timeout handler in gapplication test MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Otherwise if, for whatever reason, the `app` loses its D-Bus name, `g_application_quit()` is called from `name_was_lost()` before it’s called from `quit_already()`, and then `quit_already()` does an invalid read on `app`. If the name was not meant to be lost at this point in the test, the subsequent `g_assert_false (name_lost)` will catch that, so this change shouldn’t cause the test to pass unnecessarily. Signed-off-by: Philip Withnall --- gio/tests/gapplication.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/gio/tests/gapplication.c b/gio/tests/gapplication.c index a11f2b8bc5..9646874b9f 100644 --- a/gio/tests/gapplication.c +++ b/gio/tests/gapplication.c @@ -1159,6 +1159,7 @@ test_replace (gconstpointer data) gboolean name_lost = FALSE; TestReplaceData data; GTestDBus *bus; + guint timeout_id = 0; data.allow_replacement = allow; data.subprocess = NULL; @@ -1173,7 +1174,7 @@ test_replace (gconstpointer data) g_signal_connect (app, "activate", G_CALLBACK (activate), NULL); if (!allow) - g_timeout_add_seconds (1, quit_already, app); + timeout_id = g_timeout_add_seconds (1, quit_already, app); g_application_run (app, G_N_ELEMENTS (argv) - 1, argv); @@ -1183,6 +1184,7 @@ test_replace (gconstpointer data) else g_assert_false (name_lost); + g_clear_handle_id (&timeout_id, g_source_remove); g_object_unref (app); g_free (binpath); -- GitLab