@slavivanyuk Thank you for testing the fix.
I've also verified the fix in 2.31-0ubuntu9.3 on Focal with repro-lp1899800.c in a 4 core VM running on a 4 core machine.
The reproducer did hang after a half hour with unfixed glibc:
$ gcc -pthread repro-lp1899800.c $ unbuffer ./a.out | ts | tee -a run1.log Apr 22 20:52:04 Total Threads Count; 12 Apr 22 20:52:04 RefereeThread - (null) started Apr 22 20:52:04 LoopCriticalSectionThread - 1 started Apr 22 20:52:04 LoopCriticalSectionThread - 2 started Apr 22 20:52:04 LoopCriticalSectionThread - 3 started Apr 22 20:52:04 LoopCriticalSectionThread - 4 started Apr 22 20:52:04 LoopCriticalSectionThread - 6 started Apr 22 20:52:04 LoopCriticalSectionThread - 7 started Apr 22 20:52:04 LoopCriticalSectionThread - 8 started Apr 22 20:52:04 LoopCriticalSectionThread - 9 started Apr 22 20:52:04 LoopCriticalSectionThread - 10 started Apr 22 20:52:04 LoopCriticalSectionThread - 12 started Apr 22 20:52:04 LoopCriticalSectionThread - 5 started Apr 22 20:52:04 LoopCriticalSectionThread - 11 started Apr 22 20:52:06 Monitor - g_counter 974610000, loop_round 12494, threads_finished 12 Apr 22 20:52:08 Monitor - g_counter 1852531000, loop_round 23750, threads_finished 7 Apr 22 20:52:10 Monitor - g_counter -1586651296, loop_round 34721, threads_finished 12 Apr 22 20:52:12 Monitor - g_counter -757148296, loop_round 45356, threads_finished 8 ... Apr 22 21:20:59 Monitor - g_counter 1484067600, loop_round 8278578, threads_finished 0 Apr 22 21:21:01 Monitor - g_counter -2055625696, loop_round 8288261, threads_finished 12 Apr 22 21:21:03 Monitor - g_counter -1700741696, loop_round 8292811, threads_finished 8 Apr 22 21:21:05 Monitor - g_counter -1700741696, loop_round 8292811, threads_finished 8 Apr 22 21:21:07 Monitor - g_counter -1700741696, loop_round 8292811, threads_finished 8 Apr 22 21:21:09 Monitor - g_counter -1700741696, loop_round 8292811, threads_finished 8 $
With the fixed version I have not observed the hang in a day:
$ head run2.log Apr 22 21:23:36 Total Threads Count; 12 Apr 22 21:23:36 RefereeThread - (null) started Apr 22 21:23:36 LoopCriticalSectionThread - 3 started ... ubuntu@ff-glibc-hang:~$ tail run2.log Apr 23 22:50:07 Monitor - g_counter 2116331568, loop_round 435966312, threads_finished 12 Apr 23 22:50:09 Monitor - g_counter -1409321728, loop_round 435976175, threads_finished 12 Apr 23 22:50:11 Monitor - g_counter -656621728, loop_round 435985825, threads_finished 0 Apr 23 22:50:13 Monitor - g_counter 80942716, loop_round 435995281, threads_finished 11
@slavivanyuk Thank you for testing the fix.
I've also verified the fix in 2.31-0ubuntu9.3 on Focal with repro-lp1899800.c in a 4 core VM running on a 4 core machine.
The reproducer did hang after a half hour with unfixed glibc:
$ gcc -pthread repro-lp1899800.c tionThread - 1 started tionThread - 2 started tionThread - 3 started tionThread - 4 started tionThread - 6 started tionThread - 7 started tionThread - 8 started tionThread - 9 started tionThread - 10 started tionThread - 12 started tionThread - 5 started tionThread - 11 started
$ unbuffer ./a.out | ts | tee -a run1.log
Apr 22 20:52:04 Total Threads Count; 12
Apr 22 20:52:04 RefereeThread - (null) started
Apr 22 20:52:04 LoopCriticalSec
Apr 22 20:52:04 LoopCriticalSec
Apr 22 20:52:04 LoopCriticalSec
Apr 22 20:52:04 LoopCriticalSec
Apr 22 20:52:04 LoopCriticalSec
Apr 22 20:52:04 LoopCriticalSec
Apr 22 20:52:04 LoopCriticalSec
Apr 22 20:52:04 LoopCriticalSec
Apr 22 20:52:04 LoopCriticalSec
Apr 22 20:52:04 LoopCriticalSec
Apr 22 20:52:04 LoopCriticalSec
Apr 22 20:52:04 LoopCriticalSec
Apr 22 20:52:06 Monitor - g_counter 974610000, loop_round 12494, threads_finished 12
Apr 22 20:52:08 Monitor - g_counter 1852531000, loop_round 23750, threads_finished 7
Apr 22 20:52:10 Monitor - g_counter -1586651296, loop_round 34721, threads_finished 12
Apr 22 20:52:12 Monitor - g_counter -757148296, loop_round 45356, threads_finished 8
...
Apr 22 21:20:59 Monitor - g_counter 1484067600, loop_round 8278578, threads_finished 0
Apr 22 21:21:01 Monitor - g_counter -2055625696, loop_round 8288261, threads_finished 12
Apr 22 21:21:03 Monitor - g_counter -1700741696, loop_round 8292811, threads_finished 8
Apr 22 21:21:05 Monitor - g_counter -1700741696, loop_round 8292811, threads_finished 8
Apr 22 21:21:07 Monitor - g_counter -1700741696, loop_round 8292811, threads_finished 8
Apr 22 21:21:09 Monitor - g_counter -1700741696, loop_round 8292811, threads_finished 8
$
With the fixed version I have not observed the hang in a day:
$ head run2.log tionThread - 3 started ff-glibc- hang:~$ tail run2.log
Apr 22 21:23:36 Total Threads Count; 12
Apr 22 21:23:36 RefereeThread - (null) started
Apr 22 21:23:36 LoopCriticalSec
...
ubuntu@
Apr 23 22:50:07 Monitor - g_counter 2116331568, loop_round 435966312, threads_finished 12
Apr 23 22:50:09 Monitor - g_counter -1409321728, loop_round 435976175, threads_finished 12
Apr 23 22:50:11 Monitor - g_counter -656621728, loop_round 435985825, threads_finished 0
Apr 23 22:50:13 Monitor - g_counter 80942716, loop_round 435995281, threads_finished 11