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

Simon Marchi simon.marchi@polymtl.ca
Thu Sep 27 03:10:00 GMT 2018


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



More information about the Gdb-patches mailing list