Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/tests/lib/libc/sys Fix race in t_ptrace_wait* LWP tests
details: https://anonhg.NetBSD.org/src/rev/b86373286449
branches: trunk
changeset: 464592:b86373286449
user: kamil <kamil%NetBSD.org@localhost>
date: Sun Oct 13 09:42:15 2019 +0000
description:
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:
tests/lib/libc/sys/t_ptrace_wait.c | 7 +++++--
1 files changed, 5 insertions(+), 2 deletions(-)
diffs (34 lines):
diff -r 4f1dc5a62a32 -r b86373286449 tests/lib/libc/sys/t_ptrace_wait.c
--- a/tests/lib/libc/sys/t_ptrace_wait.c Sun Oct 13 07:46:16 2019 +0000
+++ b/tests/lib/libc/sys/t_ptrace_wait.c Sun Oct 13 09:42:15 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: t_ptrace_wait.c,v 1.136 2019/10/13 04:05:39 kamil Exp $ */
+/* $NetBSD: t_ptrace_wait.c,v 1.137 2019/10/13 09:42:15 kamil 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.136 2019/10/13 04:05:39 kamil Exp $");
+__RCSID("$NetBSD: t_ptrace_wait.c,v 1.137 2019/10/13 09:42:15 kamil Exp $");
#include <sys/param.h>
#include <sys/types.h>
@@ -5458,12 +5458,15 @@
#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();
Home |
Main Index |
Thread Index |
Old Index