Boost C++ Libraries: Ticket #1905: shared_mutex::timed_lock can leave mutex thinking there's a waiting writer https://svn.boost.org/trac10/ticket/1905 <p> I'm experiencing a deadlock in the following code. After an timed out call to boost::shared_mutex::timed_lock(), boost::mutex::state.exclusive_waiting_blocked equals 1, which makes further attempts to shared_lock the mutex block indefinitely. </p> <p> Is this a bug, or are my expectations wrong? </p> <p> Thanks, </p> <p> Mark </p> <pre class="wiki"> #include &lt;boost/thread/thread.hpp&gt; #include &lt;boost/thread/shared_mutex.hpp&gt; #include &lt;iostream&gt; using namespace std; boost::shared_mutex mutex; void thread() { boost::system_time timeout=boost::get_system_time() + boost::posix_time::milliseconds(500); if (mutex.timed_lock(timeout)) { mutex.unlock(); } else { cout &lt;&lt; "thread1: failed to obtain exclusive lock" &lt;&lt; endl; // now mutex.state.exclusive_waiting_blocked == 1; cout &lt;&lt; "thread1: attempting to obtain exclusive lock" &lt;&lt; endl; mutex.lock_shared(); //never get to here cout &lt;&lt; "thread2: obtained shared lock" &lt;&lt; endl; mutex.unlock_shared(); } } int main(int argc, char* argv[]) { mutex.lock_shared(); boost::thread my_thread(&amp;thread); my_thread.join(); mutex.unlock_shared(); return 0; } </pre> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/1905 Trac 1.4.3 Anthony Williams Fri, 09 May 2008 07:49:52 GMT status changed; resolution set https://svn.boost.org/trac10/ticket/1905#comment:1 https://svn.boost.org/trac10/ticket/1905#comment:1 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">fixed</span> </li> </ul> <p> Fixed on trunk, revision 45242 </p> Ticket