Skip to content

gtk.cfg: g_thread_join releases the thread - #9009

Open
pduchi wants to merge 1 commit into
cppcheck-opensource:mainfrom
pduchi:gtk-cfg-g-thread-join
Open

pduchi wants to merge 1 commit into
cppcheck-opensource:mainfrom
pduchi:gtk-cfg-g-thread-join

Conversation

@pduchi

@pduchi pduchi commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

I don't have a Trac account, so there is no ticket for this; the details are below. Feel free to create one and I'll add it to the title.

#include <glib.h>

static gpointer run(gpointer data)
{
    return data;
}

void f(void)
{
    GThread *thread = g_thread_new("worker", run, NULL);
    g_thread_join(thread);
}

$ cppcheck --library=gtk thread.c
thread.c:12:1: error: Memory leak: thread [memleak]

g_thread_join() releases the thread, and gtk.cfg already lists it as a <dealloc> of g_thread_new() and g_thread_try_new(). Its <function> entry also had <leak-ignore/>, so the call was ignored and every joined thread was reported as leaked.

  • <leak-ignore/> is removed from g_thread_join.
  • g_thread_join, g_thread_new and g_thread_try_new get their argument and return value configuration; the last two had no <function> entry.

Tests: test/cfg/gtk.c covers a joined g_thread_new() thread, a joined g_thread_try_new() thread, and a thread that is never joined (still reported as memleak). The false positive shows without the change; cfg/gtk.cfg validates against cppcheck-cfg.rng.

g_thread_join() is the deallocator of g_thread_new() and g_thread_try_new(),
but its function entry also had <leak-ignore/>, so the join was ignored and
every joined thread was reported as
  Memory leak: thread
Drop <leak-ignore/> and describe the arguments of g_thread_join(),
g_thread_new() and g_thread_try_new(), which had no function entry.
@pduchi

pduchi commented Nov 10, 2026

Copy link
Copy Markdown
Contributor Author

The cygwin failure is in Set up Cygwin, before the build; could you re-run it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant