This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] [testsuite][racy] Fix race condition in check-libthread-db


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]