Boost C++ Libraries: Ticket #9569: [windows] Upgrade lock is not acquired when previous upgrade lock releases if another read lock is present https://svn.boost.org/trac10/ticket/9569 <p> The problem is described here <a class="ext-link" href="https://svn.boost.org/trac/boost/ticket/5516"><span class="icon">​</span>https://svn.boost.org/trac/boost/ticket/5516</a>. Example and result are the same. The only difference is that I use &lt;boost/thread/win32/shared_mutex.hpp&gt; instead of &lt;boost/thread/pthread/shared_mutex.hpp&gt;. </p> <p> I tried to compile with BOOST_THREAD_PROVIDES_GENERIC_SHARED_MUTEX_ON_WIN flag and everything goes right. So the problem is in function unlock_upgrade() in &lt;boost/thread/win32/shared_mutex.hpp&gt;. </p> <p> My platform: Windows 7 x64, MS VS 2012. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/9569 Trac 1.4.3 viboes Mon, 13 Jan 2014 22:01:05 GMT status, component changed; owner set https://svn.boost.org/trac10/ticket/9569#comment:1 https://svn.boost.org/trac10/ticket/9569#comment:1 <ul> <li><strong>owner</strong> set to <span class="trac-author">viboes</span> </li> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">assigned</span> </li> <li><strong>component</strong> <span class="trac-field-old">None</span> → <span class="trac-field-new">thread</span> </li> </ul> Ticket viboes Wed, 26 Feb 2014 07:10:07 GMT <link>https://svn.boost.org/trac10/ticket/9569#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/9569#comment:2</guid> <description> <p> Hi, </p> <p> Please could you try adding </p> <pre class="wiki"> void release_shared_waiters(state_data old_state) { if(old_state.shared_waiting || old_state.exclusive_waiting) { BOOST_VERIFY(detail::win32::ReleaseSemaphore(semaphores[unlock_sem],old_state.shared_waiting + (old_state.exclusive_waiting?1:0),0)!=0); } } </pre><p> and changing the implementation to </p> <pre class="wiki"> void unlock_upgrade() { state_data old_state=state; for(;;) { state_data new_state=old_state; new_state.upgrade=false; bool const last_reader=!--new_state.shared_count; if(last_reader) { if(new_state.exclusive_waiting) { --new_state.exclusive_waiting; new_state.exclusive_waiting_blocked=false; } new_state.shared_waiting=0; } state_data const current_state=interlocked_compare_exchange(&amp;state,new_state,old_state); if(current_state==old_state) { if(last_reader) { release_waiters(old_state); } else { release_shared_waiters(old_state); } // #7720 //else { // release_waiters(old_state); //} break; } old_state=current_state; } } </pre><p> Please could you also try the test in <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/7720" title="#7720: Bugs: exception lock_error while intensive locking/unlocking of mutex (closed: fixed)">#7720</a>? </p> </description> <category>Ticket</category> </item> <item> <dc:creator>viboes</dc:creator> <pubDate>Wed, 12 Mar 2014 23:03:27 GMT</pubDate> <title>milestone changed https://svn.boost.org/trac10/ticket/9569#comment:3 https://svn.boost.org/trac10/ticket/9569#comment:3 <ul> <li><strong>milestone</strong> <span class="trac-field-old">To Be Determined</span> → <span class="trac-field-new">Boost 1.57.0</span> </li> </ul> Ticket viboes Sat, 06 Sep 2014 14:53:47 GMT summary changed https://svn.boost.org/trac10/ticket/9569#comment:4 https://svn.boost.org/trac10/ticket/9569#comment:4 <ul> <li><strong>summary</strong> <span class="trac-field-old">Upgrade lock is not acquired when previous upgrade lock releases if another read lock is present</span> → <span class="trac-field-new">[windows] Upgrade lock is not acquired when previous upgrade lock releases if another read lock is present</span> </li> </ul> Ticket viboes Tue, 16 Sep 2014 06:19:22 GMT <link>https://svn.boost.org/trac10/ticket/9569#comment:5 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/9569#comment:5</guid> <description> <p> Any new on this issue? </p> </description> <category>Ticket</category> </item> <item> <dc:creator>viboes</dc:creator> <pubDate>Wed, 08 Oct 2014 05:36:12 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/9569#comment:6 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/9569#comment:6</guid> <description> <p> <a class="ext-link" href="https://github.com/boostorg/thread/commit/6f91af2154da808eb29de2e9e12c3e1774cdea31"><span class="icon">​</span>https://github.com/boostorg/thread/commit/6f91af2154da808eb29de2e9e12c3e1774cdea31</a> </p> </description> <category>Ticket</category> </item> <item> <dc:creator>viboes</dc:creator> <pubDate>Sat, 11 Oct 2014 05:26:16 GMT</pubDate> <title>status changed; resolution set https://svn.boost.org/trac10/ticket/9569#comment:7 https://svn.boost.org/trac10/ticket/9569#comment:7 <ul> <li><strong>status</strong> <span class="trac-field-old">assigned</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">fixed</span> </li> </ul> Ticket