bridge: Fix valgrind memory leak in bridge's signal handler

Setting up the signal handlers before forking to start the ssh and
polkit agents causes the corresponding GSources to never be free'd in
the child processes. This is not a problem in practice as eventually the
agents will execve() -- but our unit tests are so quick that this
doesn't happen fast enough, and thus valgrind sees these GSources a
memory leak.

To mitigate that, set up the signal handlers after forking. Delete the
corresponding suppression.
This commit is contained in:
Martin Pitt 2019-09-12 16:27:27 +02:00 committed by Allison Karlitskaya
parent 3ad8e4d8c5
commit 8cbafde9b8
2 changed files with 3 additions and 14 deletions

View File

@ -528,9 +528,6 @@ run_bridge (const gchar *interactive,
/* Reset the umask, typically this is done in .bashrc for a login shell */
umask (022);
sig_term = g_unix_signal_add (SIGTERM, on_signal_done, &terminated);
sig_int = g_unix_signal_add (SIGINT, on_signal_done, &interupted);
/* Start daemons if necessary */
if (!interactive && !privileged_slave)
{
@ -540,6 +537,9 @@ run_bridge (const gchar *interactive,
agent_pid = start_ssh_agent ();
}
sig_term = g_unix_signal_add (SIGTERM, on_signal_done, &terminated);
sig_int = g_unix_signal_add (SIGINT, on_signal_done, &interupted);
cockpit_dbus_internal_startup (interactive != NULL);
if (interactive)

View File

@ -1,15 +1,4 @@
# cockpit specific valgrind glib suppressions which are not in /usr/share/glib-2.0/valgrind/glib.supp
{
g_unix_signal_add_full
Memcheck:Leak
match-leak-kinds: definite
fun:malloc
fun:g_malloc
...
fun:g_thread_new
...
fun:g_unix_signal_add_full
}
{
leak_dbus_message_from_blob
Memcheck:Leak