summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authormartin <martin@NetBSD.org>2019-10-15 18:40:02 +0000
committermartin <martin@NetBSD.org>2019-10-15 18:40:02 +0000
commit468550de5981a1d4fa43750b29340bfedea2ba0b (patch)
tree8d7d5c95ac808e9a46e988ec3f53cb2c378731c0 /tests
parent8aa035bf71177bfc9bc28ef0c0f92a9ef12dd5b6 (diff)
Pull up following revision(s) (requested by kamil in ticket #314):
tests/lib/libc/sys/t_ptrace_wait.c: revision 1.137 Fix race in t_ptrace_wait* LWP tests Increment the done variable under a mutex. This variable was updated non-atomically and sometimes not reaching the expected treshold.
Diffstat (limited to 'tests')
-rw-r--r--tests/lib/libc/sys/t_ptrace_wait.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/tests/lib/libc/sys/t_ptrace_wait.c b/tests/lib/libc/sys/t_ptrace_wait.c
index f222800e086..2ff8b2622b2 100644
--- a/tests/lib/libc/sys/t_ptrace_wait.c
+++ b/tests/lib/libc/sys/t_ptrace_wait.c
@@ -1,4 +1,4 @@
-/* $NetBSD: t_ptrace_wait.c,v 1.131.2.2 2019/10/15 18:34:34 martin Exp $ */
+/* $NetBSD: t_ptrace_wait.c,v 1.131.2.3 2019/10/15 18:40:02 martin Exp $ */
/*-
* Copyright (c) 2016, 2017, 2018, 2019 The NetBSD Foundation, Inc.
@@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: t_ptrace_wait.c,v 1.131.2.2 2019/10/15 18:34:34 martin Exp $");
+__RCSID("$NetBSD: t_ptrace_wait.c,v 1.131.2.3 2019/10/15 18:40:02 martin Exp $");
#include <sys/param.h>
#include <sys/types.h>
@@ -5432,12 +5432,15 @@ TRACEME_EXEC(traceme_signalignored_exec, false, true)
#define TRACE_THREADS_NUM 100
static volatile int done;
+pthread_mutex_t trace_threads_mtx = PTHREAD_MUTEX_INITIALIZER;
static void *
trace_threads_cb(void *arg __unused)
{
+ pthread_mutex_lock(&trace_threads_mtx);
done++;
+ pthread_mutex_unlock(&trace_threads_mtx);
while (done < TRACE_THREADS_NUM)
sched_yield();