https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97936
florin at iucha dot net changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |florin at iucha dot net --- Comment #13 from florin at iucha dot net --- Created attachment 49987 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=49987&action=edit a test case that fails in the similar way Running this program with argument 16, spawns 16 threads but it seems some get stuck at the latch despite other threads completing (and latch::wait returning). Program output, under gdb: [New Thread 0x7ffff7a5a700 (LWP 1112060)] [New Thread 0x7ffff7259700 (LWP 1112061)] [New Thread 0x7ffff6a58700 (LWP 1112062)] [New Thread 0x7ffff6257700 (LWP 1112063)] [New Thread 0x7ffff5a56700 (LWP 1112064)] [New Thread 0x7ffff5255700 (LWP 1112065)] [New Thread 0x7ffff4a54700 (LWP 1112066)] [New Thread 0x7ffff4253700 (LWP 1112067)] [New Thread 0x7ffff3a52700 (LWP 1112068)] [New Thread 0x7ffff3251700 (LWP 1112069)] [New Thread 0x7ffff2a50700 (LWP 1112070)] [New Thread 0x7ffff224f700 (LWP 1112071)] [New Thread 0x7ffff1a4e700 (LWP 1112072)] [New Thread 0x7ffff124d700 (LWP 1112073)] [New Thread 0x7ffff0a4c700 (LWP 1112074)] [New Thread 0x7ffff024b700 (LWP 1112075)] All 16 threads started Thread a73f34e0d4ae6a49 started Thread cb3cc899c037915d started Thread ade34b17621c1815 started Thread 7245e72e408faec2 started Thread a7089aace412318c started Thread 75736a54d10fb0e9 started Thread 995f48c2014cc0ec started Thread 5302d144ddde4d68 started Thread b20c0c361ed65c90 started Thread ae85377ab49db7c7 started All threads notified Thread b20c0c361ed65c90 stopped Thread ade34b17621c1815 stopped Thread a73f34e0d4ae6a49 stopped Thread 5302d144ddde4d68 stopped Thread a7089aace412318c stopped Thread ae85377ab49db7c7 stopped Thread 995f48c2014cc0ec stopped Thread 7245e72e408faec2 stopped Thread cb3cc899c037915d stopped Thread 75736a54d10fb0e9 stopped [Thread 0x7ffff4253700 (LWP 1112067) exited] [Thread 0x7ffff3251700 (LWP 1112069) exited] [Thread 0x7ffff3a52700 (LWP 1112068) exited] [Thread 0x7ffff4a54700 (LWP 1112066) exited] [Thread 0x7ffff5255700 (LWP 1112065) exited] [Thread 0x7ffff5a56700 (LWP 1112064) exited] [Thread 0x7ffff6257700 (LWP 1112063) exited] [Thread 0x7ffff6a58700 (LWP 1112062) exited] [Thread 0x7ffff7259700 (LWP 1112061) exited] [Thread 0x7ffff7a5a700 (LWP 1112060) exited] # at this point... the program hangs, but threads are still chewing CPU # Ctrl-C Thread 1 "synchro" received signal SIGINT, Interrupt. __pthread_clockjoin_ex (threadid=140737264289536, thread_return=0x0, clockid=<optimized out>, abstime=<optimized out>, block=<optimized out>) at pthread_join_common.c:145 145 pthread_join_common.c: No such file or directory. (gdb) threads Undefined command: "threads". Try "help". (gdb) info thread Id Target Id Frame * 1 Thread 0x7ffff7a5b740 (LWP 1112056) "synchro" __pthread_clockjoin_ex (threadid=140737264289536, thread_return=0x0, clockid=<optimized out>, abstime=<optimized out>, block=<optimized out>) at pthread_join_common.c:145 12 Thread 0x7ffff2a50700 (LWP 1112070) "synchro" syscall () at ../sysdeps/unix/sysv/linux/x86_64/syscall.S:38 13 Thread 0x7ffff224f700 (LWP 1112071) "synchro" syscall () at ../sysdeps/unix/sysv/linux/x86_64/syscall.S:38 14 Thread 0x7ffff1a4e700 (LWP 1112072) "synchro" syscall () at ../sysdeps/unix/sysv/linux/x86_64/syscall.S:38 15 Thread 0x7ffff124d700 (LWP 1112073) "synchro" syscall () at ../sysdeps/unix/sysv/linux/x86_64/syscall.S:38 16 Thread 0x7ffff0a4c700 (LWP 1112074) "synchro" syscall () at ../sysdeps/unix/sysv/linux/x86_64/syscall.S:38 17 Thread 0x7ffff024b700 (LWP 1112075) "synchro" syscall () at ../sysdeps/unix/sysv/linux/x86_64/syscall.S:38 (gdb) thread 13 [Switching to thread 13 (Thread 0x7ffff224f700 (LWP 1112071))] #0 syscall () at ../sysdeps/unix/sysv/linux/x86_64/syscall.S:38 38 ../sysdeps/unix/sysv/linux/x86_64/syscall.S: No such file or directory. (gdb) bt #0 syscall () at ../sysdeps/unix/sysv/linux/x86_64/syscall.S:38 #1 0x000055555555a676 in std::__detail::__platform_wait<int> ( __addr=0x5555555a8440 <std::__detail::__waiters::_S_for(void const*)::__w+1152>, __val=0) at /opt/gcc11/include/c++/11.0.0/bits/atomic_wait.h:98 #2 0x000055555555967a in std::__detail::__waiters::_M_do_wait ( this=0x5555555a8440 <std::__detail::__waiters::_S_for(void const*)::__w+1152>, __version=0) at /opt/gcc11/include/c++/11.0.0/bits/atomic_wait.h:150 #3 0x0000555555559748 in std::__detail::__waiter::_M_do_wait (this=0x7ffff224ed30) at /opt/gcc11/include/c++/11.0.0/bits/atomic_wait.h:213 #4 0x000055555555a7c7 in std::__atomic_wait<long, std::latch::wait() const::{lambda()#1}>(long const*, long, std::latch::wait() const::{lambda()#1}) (__addr=0x7fffffffe5b8, __old=4, __pred=...) at /opt/gcc11/include/c++/11.0.0/bits/atomic_wait.h:271 #5 0x000055555555865e in std::latch::wait (this=0x7fffffffe5b8) at /opt/gcc11/include/c++/11.0.0/latch:77 #6 std::latch::arrive_and_wait (__update=1, this=0x7fffffffe5b8) at /opt/gcc11/include/c++/11.0.0/latch:84 #7 operator() (__closure=0x5555555bc1a0, st=...) at /home/florin/work/sandbox2/src/synchro.cpp:64 #8 0x00005555555592d8 in std::__invoke_impl<void, start(int)::<lambda(std::stop_token)>, std::stop_token>(std::__invoke_other, struct {...} &&) (__f=...) at /opt/gcc11/include/c++/11.0.0/bits/invoke.h:60 #9 0x000055555555933d in std::__invoke<start(int)::<lambda(std::stop_token)>, std::stop_token>(struct {...} &&) (__fn=...) at /opt/gcc11/include/c++/11.0.0/bits/invoke.h:95 #10 0x0000555555559461 in std::thread::_Invoker<std::tuple<start(int)::<lambda(std::stop_token)>, std::stop_token> >::_M_invoke<0, 1>(std::_Index_tuple<0, 1>) (this=0x5555555bc198) at /opt/gcc11/include/c++/11.0.0/bits/std_thread.h:253 #11 0x0000555555559288 in std::thread::_Invoker<std::tuple<start(int)::<lambda(std::stop_token)>, std::stop_token> >::operator()(void) ( this=0x5555555bc198) at /opt/gcc11/include/c++/11.0.0/bits/std_thread.h:260 #12 0x000055555555926c in std::thread::_State_impl<std::thread::_Invoker<std::tuple<start(int)::<lambda(std::stop_token)>, std::stop_token> > >::_M_run(void) (this=0x5555555bc190) at /opt/gcc11/include/c++/11.0.0/bits/std_thread.h:211 #13 0x00007ffff7e57824 in std::execute_native_thread_routine (__p=0x5555555bc190) at ../../../../../gcc/libstdc++-v3/src/c++11/thread.cc:82 #14 0x00007ffff7f98ea7 in start_thread (arg=<optimized out>) at pthread_create.c:477 #15 0x00007ffff7b5ddef in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95 (gdb)