]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
make pth_self_kill_15_other test deterministic
authorPetar Jovanovic <mips32r2@gmail.com>
Tue, 13 Aug 2019 14:51:37 +0000 (14:51 +0000)
committerPetar Jovanovic <mips32r2@gmail.com>
Tue, 13 Aug 2019 14:54:58 +0000 (14:54 +0000)
Modify the pth_self_kill_15_other test to make its behaviour deterministic
by introducing a pthread_join call. Do so by modifying the signal handler
for SIGTERM for the spawned thread which would issue the pthread_join call
prior to exiting.

This fixes KDE #410599.

Patch by Stefan Maksimovic.

NEWS
none/tests/pth_self_kill.c

diff --git a/NEWS b/NEWS
index 7217164776ac6a7f0ab68810539619f2f7027a36..6d55d766e6093d4b154999c8a9a8c5551dc56035 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -58,6 +58,7 @@ where XXXXXX is the bug number as listed below.
 404406  s390x: z14 miscellaneous instructions not implemented
 409141  Valgrind hangs when SIGKILLed
 409367  exit_group() after signal to thread waiting in futex() causes hangs
+410599  Non-deterministic behaviour of pth_self_kill_15_other test
 
 n-i-bz  Fix minor one time leaks in dhat.
 n-i-bz  Add --run-cxx-freeres=no in outer args to avoid inner crashes.
index 98adbadcf49f54f4a373350bfed03290794e120a..3ad675f256ca49cc8c8c1b0bcea7599932ff7d32 100644 (file)
@@ -10,6 +10,8 @@
    valgrind ./pth_self_kill 15 killotherthread  was looping.
 */
 
+pthread_t parent_thr;
+
 void *t(void *p)
 {
    sleep (200);
@@ -18,10 +20,28 @@ void *t(void *p)
    return NULL;
 }
 
+void handler_15(int signum)
+{
+   pthread_join(parent_thr, NULL);
+   exit(2);
+}
+
 int main(int argc, char **argv)
 {
    pthread_t thr;
 
+   parent_thr = pthread_self();
+
+   struct sigaction sa_old;
+   struct sigaction sa_new;
+
+   sigaction(15, NULL, &sa_old);
+   sa_new.sa_mask = sa_old.sa_mask;
+   sa_new.sa_flags = sa_old.sa_flags;
+   sa_new.sa_handler = &handler_15;
+   sigaction(15, &sa_new, NULL);
+
+
    if (argc <= 1)
    {
       printf
@@ -41,4 +61,5 @@ int main(int argc, char **argv)
    }
    else
       raise(s);
+   sigaction(15, &sa_old, NULL);
 }