id,summary,reporter,owner,description,type,status,milestone,component,version,severity,resolution,keywords,cc 1950,pthread/condition_variable::wait() unlocks associated mutex prematurely and may miss a notification,Stas Maximov ,Anthony Williams,"pthread implementation of class condition_variable implements wait() is as follows: template void wait(lock_type& m) { int res=0; { detail::interruption_checker check_for_interruption(&cond); { boost::pthread::pthread_mutex_scoped_lock internal_lock(&internal_mutex); m.unlock(); res=pthread_cond_wait(&cond,&internal_mutex); } m.lock(); } if(res) { throw condition_error(); } } Each condition variable must have an associated mutex. pthread_cond_wait() must enter with the mutex locked. Having the mutex locked guarantees that no notifications will be missed by the receiving thread. The above implementation releases mutex before entering pthread_cond_wait(). This creates an opportunity for pre-emption of the thread just after the mutex was unlocked, but before pthread has been entered. If another thread pre-empts at this point and tries to notify this condition variable, this notification will be missed by this thread. Substitution of some random, unrelated mutex into pthread_cond_wait() is not a solution. It is the original mutex that is associated with the condition that must be passed to pthread_cond_wait(). ",Bugs,closed,Boost 1.36.0,thread,Boost 1.35.0,Showstopper,invalid,pthread_cond_wait condition variable pthread mutex,