bridge: workaround valgrind issue

Add some code to cockpit-bridge to detect if it's running under valgrind
(ie: as part of 'make check-memory') and cause it to delay its exit by 5
seconds in that case.

This helps avoid https://bugs.kde.org/show_bug.cgi?id=409367, which
otherwise will cause the units test container to hang fairly regularly
on Ubuntu 19.04.

Closes #12255
This commit is contained in:
Allison Karlitskaya 2019-07-01 16:58:03 +02:00 committed by Martin Pitt
parent 78361bf95c
commit 5716079402
1 changed files with 12 additions and 0 deletions

View File

@ -610,6 +610,18 @@ run_bridge (const gchar *interactive,
g_source_remove (sig_term);
g_source_remove (sig_int);
/* HACK: Valgrind contains a bug that causes it to hang when the main
* thread exits quickly in response to a signal received by a handler
* in another thread, when that other thread is waiting in a syscall.
* Avoid that situation by delaying our exit here, but only under
* Valgrind.
*
* Remove this when https://bugs.kde.org/show_bug.cgi?id=409367 is
* fixed and widely distributed.
*/
if (strstr (g_getenv ("LD_PRELOAD") ?: "", "valgrind") != NULL)
g_usleep (5 * G_TIME_SPAN_SECOND);
/* So the caller gets the right signal */
if (terminated)
raise (SIGTERM);