|
From: Petar J. <pe...@so...> - 2019-08-13 14:55:56
|
https://sourceware.org/git/gitweb.cgi?p=valgrind.git;h=14911f7d6cc92df110c5987549bfcd84279009a5 commit 14911f7d6cc92df110c5987549bfcd84279009a5 Author: Petar Jovanovic <mip...@gm...> Date: Tue Aug 13 14:51:37 2019 +0000 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: --- NEWS | 1 + none/tests/pth_self_kill.c | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/NEWS b/NEWS index 7217164..6d55d76 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 98adbad..3ad675f 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); } |