unofficial mirror of libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] pthread/tst-cancel28: Fix barrier re-init race condition
@ 2021-09-25  8:02 Stafford Horne via Libc-alpha
  2021-09-27 20:42 ` Stafford Horne via Libc-alpha
  2021-09-28 13:47 ` Adhemerval Zanella via Libc-alpha
  0 siblings, 2 replies; 3+ messages in thread
From: Stafford Horne via Libc-alpha @ 2021-09-25  8:02 UTC (permalink / raw
  To: GLIBC patches

When running this test on the OpenRISC port I am working on this test
fails with a timeout.  The test passes when being straced or debugged.
Looking at the code there seems to be a race condition in that:

  1 main thread: calls xpthread_cancel
  2 sub thread : receives cancel signal
  3 sub thread : cleanup routine waits on barrier
  4 main thread: re-inits barrier
  5 main thread: waits on barrier

After getting to 5 the main thread and sub thread wait forever as the 2
barriers are no longer the same.

Removing the barrier re-init seems to fix this issue.  Also, the barrier
does not need to be reinitialized as that is done by default.

Cc: Adhemerval Zanella <adhemerval.zanella@linaro.org>
---
 sysdeps/pthread/tst-cancel28.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/sysdeps/pthread/tst-cancel28.c b/sysdeps/pthread/tst-cancel28.c
index 627cbc8160..9286c159b3 100644
--- a/sysdeps/pthread/tst-cancel28.c
+++ b/sysdeps/pthread/tst-cancel28.c
@@ -69,7 +69,6 @@ do_test (void)
 
   xpthread_cancel (timer_thread);
 
-  xpthread_barrier_init (&barrier, NULL, 2);
   xpthread_barrier_wait (&barrier);
 
   return 0;
-- 
2.31.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] pthread/tst-cancel28: Fix barrier re-init race condition
  2021-09-25  8:02 [PATCH] pthread/tst-cancel28: Fix barrier re-init race condition Stafford Horne via Libc-alpha
@ 2021-09-27 20:42 ` Stafford Horne via Libc-alpha
  2021-09-28 13:47 ` Adhemerval Zanella via Libc-alpha
  1 sibling, 0 replies; 3+ messages in thread
From: Stafford Horne via Libc-alpha @ 2021-09-27 20:42 UTC (permalink / raw
  To: GLIBC patches

ping

On Sat, Sep 25, 2021 at 5:02 PM Stafford Horne <shorne@gmail.com> wrote:
>
> When running this test on the OpenRISC port I am working on this test
> fails with a timeout.  The test passes when being straced or debugged.
> Looking at the code there seems to be a race condition in that:
>
>   1 main thread: calls xpthread_cancel
>   2 sub thread : receives cancel signal
>   3 sub thread : cleanup routine waits on barrier
>   4 main thread: re-inits barrier
>   5 main thread: waits on barrier
>
> After getting to 5 the main thread and sub thread wait forever as the 2
> barriers are no longer the same.
>
> Removing the barrier re-init seems to fix this issue.  Also, the barrier
> does not need to be reinitialized as that is done by default.
>
> Cc: Adhemerval Zanella <adhemerval.zanella@linaro.org>
> ---
>  sysdeps/pthread/tst-cancel28.c | 1 -
>  1 file changed, 1 deletion(-)
>
> diff --git a/sysdeps/pthread/tst-cancel28.c b/sysdeps/pthread/tst-cancel28.c
> index 627cbc8160..9286c159b3 100644
> --- a/sysdeps/pthread/tst-cancel28.c
> +++ b/sysdeps/pthread/tst-cancel28.c
> @@ -69,7 +69,6 @@ do_test (void)
>
>    xpthread_cancel (timer_thread);
>
> -  xpthread_barrier_init (&barrier, NULL, 2);
>    xpthread_barrier_wait (&barrier);
>
>    return 0;
> --
> 2.31.1
>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] pthread/tst-cancel28: Fix barrier re-init race condition
  2021-09-25  8:02 [PATCH] pthread/tst-cancel28: Fix barrier re-init race condition Stafford Horne via Libc-alpha
  2021-09-27 20:42 ` Stafford Horne via Libc-alpha
@ 2021-09-28 13:47 ` Adhemerval Zanella via Libc-alpha
  1 sibling, 0 replies; 3+ messages in thread
From: Adhemerval Zanella via Libc-alpha @ 2021-09-28 13:47 UTC (permalink / raw
  To: Stafford Horne, GLIBC patches



On 25/09/2021 05:02, Stafford Horne wrote:
> When running this test on the OpenRISC port I am working on this test
> fails with a timeout.  The test passes when being straced or debugged.
> Looking at the code there seems to be a race condition in that:
> 
>   1 main thread: calls xpthread_cancel
>   2 sub thread : receives cancel signal
>   3 sub thread : cleanup routine waits on barrier
>   4 main thread: re-inits barrier
>   5 main thread: waits on barrier
> 
> After getting to 5 the main thread and sub thread wait forever as the 2
> barriers are no longer the same.
> 
> Removing the barrier re-init seems to fix this issue.  Also, the barrier
> does not need to be reinitialized as that is done by default.
> 
> Cc: Adhemerval Zanella <adhemerval.zanella@linaro.org>

LGTM, thanks.

Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>

> ---
>  sysdeps/pthread/tst-cancel28.c | 1 -
>  1 file changed, 1 deletion(-)
> 
> diff --git a/sysdeps/pthread/tst-cancel28.c b/sysdeps/pthread/tst-cancel28.c
> index 627cbc8160..9286c159b3 100644
> --- a/sysdeps/pthread/tst-cancel28.c
> +++ b/sysdeps/pthread/tst-cancel28.c
> @@ -69,7 +69,6 @@ do_test (void)
>  
>    xpthread_cancel (timer_thread);
>  
> -  xpthread_barrier_init (&barrier, NULL, 2);
>    xpthread_barrier_wait (&barrier);
>  
>    return 0;
> 

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-09-28 13:47 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-09-25  8:02 [PATCH] pthread/tst-cancel28: Fix barrier re-init race condition Stafford Horne via Libc-alpha
2021-09-27 20:42 ` Stafford Horne via Libc-alpha
2021-09-28 13:47 ` Adhemerval Zanella via Libc-alpha

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).