g_main_loop_run() may leak a GMainLoop reference
Looking at g_main_loop_run()
: if we can't acquire the loop's main context, we take a reference on loop
before calling g_main_context_wait_internal()
. If the loop is no longer running when we acquire the main context, we drop the reference and return. So far, so good. But. If the loop is still running, and we go on to call g_main_context_iterate()
, this reference is leaked.
I first encountered this due to an intermittent leak detection with Clang's address sanitizer, in a project using glib 2.48.2. It appears to be still present at commit 0c6ed994.