Boost C++ Libraries: Ticket #8422: Assertion in win32::WaitForSingleObject() https://svn.boost.org/trac10/ticket/8422 <p> I get the following assertion when I used Ctrl-C on an app: </p> <p> <code>Assertion failed: win32::WaitForSingleObject( sem,::boost::detail::win32::infinite)==0, file ...\boost\thread\win32\basic_timed_mutex.hpp, line 79</code> </p> <p> Examination of that line of code reveals that the error handling is insufficient. <code>WaitForSingleObject()</code> can return <code>WAIT_ABANDONED</code> if the lock is held when the owning thread is released. In non-debug builds, this means the code falls through to the next statement in such cases, whereas in debug <code>BOOST_VERIFY</code> reports an error. Either way, <code>WAIT_ABANDONED</code> should be handled. </p> <p> (Refer to <a class="ext-link" href="http://msdn.microsoft.com/en-us/library/windows/desktop/ms687032.aspx"><span class="icon">​</span>http://msdn.microsoft.com/en-us/library/windows/desktop/ms687032.aspx</a> for details on the API.) </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/8422 Trac 1.4.3 viboes Tue, 09 Apr 2013 16:29:27 GMT owner, status changed https://svn.boost.org/trac10/ticket/8422#comment:1 https://svn.boost.org/trac10/ticket/8422#comment:1 <ul> <li><strong>owner</strong> changed from <span class="trac-author">Anthony Williams</span> 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> </ul> <p> What would be the expected behavior when <a class="missing wiki">WaitForSingleObject</a>() returns WAIT_ABANDONED? </p> Ticket viboes Tue, 21 May 2013 23:07:35 GMT <link>https://svn.boost.org/trac10/ticket/8422#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/8422#comment:2</guid> <description> <p> ping? </p> </description> <category>Ticket</category> </item> <item> <author>robert.stewart@…</author> <pubDate>Wed, 22 May 2013 11:17:59 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/8422#comment:3 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/8422#comment:3</guid> <description> <p> Since that return value means the calling thread owns the mutex by default of the previous owner, it should be treated as equivalent to <code>WAIT_OBJECT0</code>. Thus, the following seems appropriate: </p> <div class="wiki-code"><div class="code"><pre><span class="n">DWORD</span> <span class="k">const</span> <span class="nf">retval</span><span class="p">(</span><span class="n">win32</span><span class="o">::</span><span class="n">WaitForSingleObject</span><span class="p">(</span><span class="n">sem</span><span class="p">,</span> <span class="o">::</span><span class="n">boost</span><span class="o">::</span><span class="n">detail</span><span class="o">::</span><span class="n">win32</span><span class="o">::</span><span class="n">infinite</span><span class="p">));</span> <span class="n">BOOST_VERIFY</span><span class="p">(</span><span class="n">WAIT_OBJECT0</span> <span class="o">==</span> <span class="n">retval</span> <span class="o">||</span> <span class="n">WAIT_ABANDONED</span> <span class="o">==</span> <span class="n">retval</span><span class="p">);</span> </pre></div></div><p> You might prefer to repackage <code>WAIT_ABANDONED</code> like <code>WAIT_TIMEOUT</code> is, so the following may be more in keeping with the current code: </p> <div class="wiki-code"><div class="code"><pre><span class="n">DWORD</span> <span class="k">const</span> <span class="nf">retval</span><span class="p">(</span><span class="n">win32</span><span class="o">::</span><span class="n">WaitForSingleObject</span><span class="p">(</span><span class="n">sem</span><span class="p">,</span> <span class="o">::</span><span class="n">boost</span><span class="o">::</span><span class="n">detail</span><span class="o">::</span><span class="n">win32</span><span class="o">::</span><span class="n">infinite</span><span class="p">));</span> <span class="n">BOOST_VERIFY</span><span class="p">(</span><span class="mi">0</span> <span class="o">==</span> <span class="n">retval</span> <span class="o">||</span> <span class="o">::</span><span class="n">boost</span><span class="o">::</span><span class="n">detail</span><span class="o">::</span><span class="n">win32</span><span class="o">::</span><span class="n">abandoned</span> <span class="o">==</span> <span class="n">retval</span><span class="p">);</span> </pre></div></div> </description> <category>Ticket</category> </item> <item> <dc:creator>viboes</dc:creator> <pubDate>Tue, 04 Jun 2013 06:14:49 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/8422#comment:4 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/8422#comment:4</guid> <description> <p> Yes, this can be changed. I will do it soon. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>viboes</dc:creator> <pubDate>Tue, 04 Jun 2013 06:17:40 GMT</pubDate> <title>milestone changed https://svn.boost.org/trac10/ticket/8422#comment:5 https://svn.boost.org/trac10/ticket/8422#comment:5 <ul> <li><strong>milestone</strong> <span class="trac-field-old">To Be Determined</span> → <span class="trac-field-new">Boost 1.54.0</span> </li> </ul> Ticket viboes Sun, 09 Jun 2013 08:31:28 GMT <link>https://svn.boost.org/trac10/ticket/8422#comment:6 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/8422#comment:6</guid> <description> <p> Committed in trunk <a class="changeset" href="https://svn.boost.org/trac10/changeset/84710" title="Thread: take in account wait_abandoned.">[84710]</a> </p> </description> <category>Ticket</category> </item> <item> <dc:creator>viboes</dc:creator> <pubDate>Wed, 12 Jun 2013 20:58:53 GMT</pubDate> <title>status changed; resolution set https://svn.boost.org/trac10/ticket/8422#comment:7 https://svn.boost.org/trac10/ticket/8422#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 viboes Wed, 12 Jun 2013 21:00:48 GMT <link>https://svn.boost.org/trac10/ticket/8422#comment:8 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/8422#comment:8</guid> <description> <p> Committed revision <a class="changeset" href="https://svn.boost.org/trac10/changeset/84750" title="Thread: merge fixes for #8422, #8458, #8674.">[84750]</a>. </p> </description> <category>Ticket</category> </item> </channel> </rss>