From: Stafford Horne Date: Sat, 25 Sep 2021 08:02:06 +0000 (+0900) Subject: pthread/tst-cancel28: Fix barrier re-init race condition X-Git-Tag: glibc-2.35~476 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=9874ca536b1d0662b1cea46af3ce09a4d42aeb32;p=thirdparty%2Fglibc.git pthread/tst-cancel28: Fix barrier re-init race condition 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. Reviewed-by: Adhemerval Zanella --- diff --git a/sysdeps/pthread/tst-cancel28.c b/sysdeps/pthread/tst-cancel28.c index 627cbc81601..9286c159b3b 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;