This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH] [testsuite][racy] Fix race condition in check-libthread-db
- From: Simon Marchi <simon dot marchi at polymtl dot ca>
- To: Alan Hayward <alan dot hayward at arm dot com>
- Cc: gdb-patches at sourceware dot org, nd at arm dot com
- Date: Wed, 26 Sep 2018 23:10:39 -0400
- Subject: Re: [PATCH] [testsuite][racy] Fix race condition in check-libthread-db
- References: <20180926150035.96813-1-alan.hayward@arm.com>
On 2018-09-26 11:00, Alan Hayward wrote:
It is possible for the created thread to reach the breakpoint before
the main thread has set errno to 23.
Prevent this using a pthread barrier.
gdb/testsuite/ChangeLog:
2018-09-26 Alan Hayward <alan.hayward@arm.com>
* gdb.threads/check-libthread-db.c (thread_routine): Use a
pthread barrier.
(main): Likewise.
---
gdb/testsuite/gdb.threads/check-libthread-db.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/gdb/testsuite/gdb.threads/check-libthread-db.c
b/gdb/testsuite/gdb.threads/check-libthread-db.c
index 85a97a93af..39d39694ce 100644
--- a/gdb/testsuite/gdb.threads/check-libthread-db.c
+++ b/gdb/testsuite/gdb.threads/check-libthread-db.c
@@ -23,6 +23,10 @@
#include <pthread.h>
#include <errno.h>
+/* This barrier ensures we only reach the initial breakpoint both
threads have
+ set errno. */
I think you are missing a word here. Otherwise, good catch, LGTM.
Simon