https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96817
--- Comment #15 from Yuxuan Shui <yshuiv7 at gmail dot com> --- (In reply to Jonathan Wakely from comment #13) > (In reply to Yuxuan Shui from comment #1) > > Example: > > > > This program normally deadlocks when using linked pthread: > > > > https://godbolt.org/z/Yrza4e > > > > But it will throw recursive_init_error when using dlopen'd pthread: > > > > https://godbolt.org/z/afMe5d > > I'm not sure what these examples are very helpful. Throwing > recursive_init_error is the correct behaviour here, it's a bug that we fail > to detect the recursion when it happens in the same thread. This is just to demonstrate the difference in the behavior. It's easy to imagine this happen in a legitimate use case (and we indeed have one).