From 5c067ab1e25b34f3b400c3db6fe36a8c37c11671 Mon Sep 17 00:00:00 2001 From: Pieter Duchi Date: Thu, 22 Oct 2026 06:12:43 +0200 Subject: [PATCH] gtk.cfg: g_thread_join releases the thread g_thread_join() is the deallocator of g_thread_new() and g_thread_try_new(), but its function entry also had , so the join was ignored and every joined thread was reported as Memory leak: thread Drop and describe the arguments of g_thread_join(), g_thread_new() and g_thread_try_new(), which had no function entry. --- cfg/gtk.cfg | 36 +++++++++++++++++++++++++++++++++++- test/cfg/gtk.c | 24 ++++++++++++++++++++++++ 2 files changed, 59 insertions(+), 1 deletion(-) diff --git a/cfg/gtk.cfg b/cfg/gtk.cfg index 024f567c922..c0cce7aea43 100644 --- a/cfg/gtk.cfg +++ b/cfg/gtk.cfg @@ -8385,9 +8385,43 @@ false + + + false + + + + + + + + + + + + + + false + + + + + + + + + + + + + - false + + + + + diff --git a/test/cfg/gtk.c b/test/cfg/gtk.c index 2612b572638..6314e4cc245 100644 --- a/test/cfg/gtk.c +++ b/test/cfg/gtk.c @@ -730,3 +730,27 @@ int g_define_enum_and_flags_type_test(void) { return e + f; } #endif + +static gpointer thread_func(gpointer data) +{ + return data; +} + +void g_thread_join_releases_thread_test(void) +{ + // cppcheck-suppress [constVariablePointer, unusedAllocatedMemory] + GThread *thread = g_thread_new("test", thread_func, NULL); + g_thread_join(thread); + + // cppcheck-suppress constVariablePointer + GThread *thread_try = g_thread_try_new("test", thread_func, NULL, NULL); + if (thread_try) + g_thread_join(thread_try); +} + +void g_thread_not_joined_test(void) +{ + GThread *thread = g_thread_new("test", thread_func, NULL); + (void)thread; + // cppcheck-suppress memleak +}