Boost C++ Libraries: Ticket #7875: BOOST_THREAD_THROW_IF_PRECONDITION_NOT_SATISFIED should not be enabled by default https://svn.boost.org/trac10/ticket/7875 <p> I just upgraded to Boost 1.52 on Windows using pre-built binaries and encountered a problem. Because BOOST_THREAD_THROW_IF_PRECONDITION_NOT_SATISFIED is enabled by default, any code that uses thread::join() will throw an exception if the target thread has already finished executing. Fortunately this was picked up by our unit tests, but the new behaviour could lead to intermittent race condition bugs that could be difficult to track down. </p> <p> I've attached a patch (to be applied in libs/thread/build) which comments out the BOOST_THREAD_THROW_IF_PRECONDITION_NOT_SATISFIED defines in the jamfile. Failing that, could someone please explain to me why this feature is enabled by default? It seems like a recipe for disaster. For example, the fix for ticket <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/7668" title="#7668: Bugs: thread_group::join_all() should check whether its threads are joinable (closed: fixed)">#7668</a>, which is attempting to work around a bug introduced by this feature, seems to introduce a race condition. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/7875 Trac 1.4.3 Andrew Molyneux <andrew.molyneux@…> Thu, 10 Jan 2013 12:19:23 GMT attachment set https://svn.boost.org/trac10/ticket/7875 https://svn.boost.org/trac10/ticket/7875 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">Jamfile.v2.patch</span> </li> </ul> <p> Stop enabling BOOST_THREAD_THROW_IF_PRECONDITION_NOT_SATISFIED by default </p> Ticket viboes Thu, 10 Jan 2013 12:50:44 GMT <link>https://svn.boost.org/trac10/ticket/7875#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/7875#comment:1</guid> <description> <p> Yes, this is abug on 1.52. Version 1.53 lets all (almost all) the uses of BOOST_THREAD_THROW_IF_PRECONDITION_NOT_SATISFIED on the header files </p> <p> E.g. the thread::join function is defined on boost/detail/thread.hpp as follows </p> <pre class="wiki"> void thread::join() { if (this_thread::get_id() == get_id()) boost::throw_exception(thread_resource_error(system::errc::resource_deadlock_would_occur, "boost thread: trying joining itself")); BOOST_THREAD_VERIFY_PRECONDITION( join_noexcept(), thread_resource_error(system::errc::invalid_argument, "boost thread: thread not joinable") ); } </pre><p> I will however comment the Jamfile.v2 line </p> <pre class="wiki">&lt;define&gt;BOOST_THREAD_THROW_IF_PRECONDITION_NOT_SATISFIED </pre> </description> <category>Ticket</category> </item> <item> <dc:creator>viboes</dc:creator> <pubDate>Thu, 10 Jan 2013 12:51:04 GMT</pubDate> <title>owner, status changed https://svn.boost.org/trac10/ticket/7875#comment:2 https://svn.boost.org/trac10/ticket/7875#comment:2 <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> Ticket Andrew Molyneux <andrew.molyneux@…> Thu, 10 Jan 2013 13:28:31 GMT <link>https://svn.boost.org/trac10/ticket/7875#comment:3 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/7875#comment:3</guid> <description> <p> Thanks for the quick response Vicente! Glad to hear you're planning to change it. Have you looked at <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/7668" title="#7668: Bugs: thread_group::join_all() should check whether its threads are joinable (closed: fixed)">#7668</a> yet? I'm not sure if Trac notifies you when comments are added to a closed ticket, but I'm pretty sure your fix to thread_group::join_all() has a race condition. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>viboes</dc:creator> <pubDate>Sat, 12 Jan 2013 10:00:49 GMT</pubDate> <title>milestone changed https://svn.boost.org/trac10/ticket/7875#comment:4 https://svn.boost.org/trac10/ticket/7875#comment:4 <ul> <li><strong>milestone</strong> <span class="trac-field-old">To Be Determined</span> → <span class="trac-field-new">Boost 1.53.0</span> </li> </ul> <p> Changeset <a class="changeset" href="https://svn.boost.org/trac10/changeset/82436" title="Thread: don't set BOOST_THREAD_THROW_IF_PRECONDITION_NOT_SATISFIED by ...">[82436]</a> by viboes </p> Ticket viboes Mon, 14 Jan 2013 17:21:23 GMT status changed; resolution set https://svn.boost.org/trac10/ticket/7875#comment:5 https://svn.boost.org/trac10/ticket/7875#comment:5 <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> <p> Committed revision 82491. </p> Ticket