The code used to call g_main_loop_quit() from the main thread, without having any guarantee that runaway_killer_thread_func() has even entered its g_main_loop_run(). If a main loop is not running, g_main_loop_quit() has no effect. This could occasionally be reproduced in test-polkitbackendjsauthority.c, which is creating several very short-lived PolkitBackendJSAuthority instances. Real polkitd should not generally be affected, because it is using a single instance running for the life of the process ~ for the uptime of the system, enough time to enter the runaway_killer_thread main loop.
Created attachment 123948 [details] [review] 0001-Fix-a-race-condition-when-terminating-runaway_killer.patch
Created attachment 123949 [details] [review] 0001-Fix-a-race-condition-when-terminating-runaway_killer.patch
i noticed this problem too running the test suite. I think a more surgical fix would be to start the main loop in the "running" state (e.g. change the FALSE argument to g_main_loop_new to TRUE) and then check g_main_loop_is_running before calling g_main_loop_run. That was the first possible fix that popped into my head anyway. But "more surgical" isn't better in this case, I think, though. You're patch simplifies the code and just seems all around better than what I'm proposing above.
Seems to work great. pushing it to master.
Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.