id,summary,reporter,owner,description,type,status,milestone,component,version,severity,resolution,keywords,cc 12731,boost::thread::join deadlock,Antoine Poliakov ,viboes,"I just hit a deadlock while `join()`ing a `boost::thread`, meaning the `join()` is blocked for ever. I did this by `pthread_cancel()`ing the thread (using `native_handle()`) and then waiting for it to actually terminate using `join()`. See the attached minimal case. Boost's `join()` never returns, while `pthread_join(native_handle())` works as expected. Looking at the code here https://github.com/boostorg/thread/blob/develop/src/pthread/thread.cpp I notice that `join_noexcept()` actually waits on condition variables before calling `pthread_join`. I believe this is a design flaw, as there are many dirty/low-level ways to stop a thread (e.g. signals or OS threading API), and there is no way to keep the `boost::thread` state in sync with the thread state in these cases of non-standard termination. I think we should be only relying on the OS API here, to query the thread state (running, joinable, etc.) instead of storing flags that may run out of sync. Alternatively, the documentation should be updated with a prominent warning saying that `boost::thread` has undefined behavior if a thread is stopped in a non standard way and `native_handle` should be used with care. Note that at least libstdc++ does not exbibit the same problem.",Support Requests,closed,To Be Determined,thread,Boost Development Trunk,Problem,obsolete,thread interuption deadlock,