https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98449
VinÃcius dos Santos Oliveira <vini.ipsmaker at gmail dot com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |vini.ipsmaker at gmail dot com --- Comment #2 from VinÃcius dos Santos Oliveira <vini.ipsmaker at gmail dot com> --- Created attachment 51126 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=51126&action=edit bugfix Here's a patch fixing the issue. If you want a codebase affected by the issue, here's the code for a thread joining detached threads through a condition variable: https://gitlab.com/emilua/emilua/-/blob/e5706426305733af02983ecb92a08dd8a00ebf2e/src/main.ypp#L275 Once the condition is met, both resources (mutex + condition variables) are destroyed just before the application exits. Therefore I cannot use notify_all_at_thread_exit (there would be a race there).