From: Petar Jovanovic Date: Tue, 13 Aug 2019 14:51:37 +0000 (+0000) Subject: make pth_self_kill_15_other test deterministic X-Git-Tag: VALGRIND_3_16_0~242 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=14911f7d6cc92df110c5987549bfcd84279009a5;p=thirdparty%2Fvalgrind.git make pth_self_kill_15_other test deterministic 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. --- diff --git a/NEWS b/NEWS index 7217164776..6d55d766e6 100644 --- 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. diff --git a/none/tests/pth_self_kill.c b/none/tests/pth_self_kill.c index 98adbadcf4..3ad675f256 100644 --- a/none/tests/pth_self_kill.c +++ b/none/tests/pth_self_kill.c @@ -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); }