Boost C++ Libraries: Ticket #8916: boost/signals2/detail/lwm_pthreads.hpp: Ignores all failures from pthread_* functions https://svn.boost.org/trac10/ticket/8916 <p> boost/signals2/detail/lwm_pthreads.hpp ignores all failures from pthread_* functions. Functions include pthread_mutex_init, pthread_mutex_lock, pthread_mutex_unlock and pthread_mutex_destroy. </p> <p> A lock failure is usually a bad thing, and I can't come up with scenarios where a silent failure is desired. It will make a bad problem worse by corrupting data or terminating the program. </p> <p> At minimum (as a user), I would expect for Boost to use BOOST_ASSERT with an appropriate exception in debugging and diagnostic builds; and BOOST_VERIFY with an appropriate exception for release or production builds. </p> <p> Perhaps it would be a good idea to use boost/thread/pthread/mutex.hpp or boost/interprocess/sync/posix/mutex.hpp. They appear to be more mature and have a bit more stability. In addition, it throws lock exceptions where appropriate. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/8916 Trac 1.4.3 Frank Mori Hess Fri, 26 Jul 2013 01:02:28 GMT <link>https://svn.boost.org/trac10/ticket/8916#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/8916#comment:1</guid> <description> <p> (In <a class="changeset" href="https://svn.boost.org/trac10/changeset/85161" title="Added BOOST_VERIFY checks on return values from pthread calls. Refs #8916 ">[85161]</a>) Added BOOST_VERIFY checks on return values from pthread calls. Refs <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/8916" title="#8916: Bugs: boost/signals2/detail/lwm_pthreads.hpp: Ignores all failures from ... (closed: fixed)">#8916</a> </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Frank Mori Hess</dc:creator> <pubDate>Fri, 26 Jul 2013 01:08:09 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/8916#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/8916#comment:2</guid> <description> <p> You are free to use boost::mutex with signals2 signals if you choose, it's just not the default. This is because when I wrote it, boost::mutex was not header-only, and apparently still is not. </p> </description> <category>Ticket</category> </item> <item> <author>Jeffrey Walton <noloader@…></author> <pubDate>Fri, 26 Jul 2013 01:18:42 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/8916#comment:3 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/8916#comment:3</guid> <description> <blockquote class="citation"> <p> Added BOOST_VERIFY checks on return values from pthread calls </p> </blockquote> <p> As I understand it (please correct me), BOOST_VERIFY is simply BOOST_ASSERT without the side effect of removal when NDEBUG is defined <a class="changeset" href="https://svn.boost.org/trac10/changeset/1" title="Import core sources for SVNmanger 0.38 ">[1]</a>. That is: </p> <ul><li>with NDEBUG, BOOST_ASSERT(x) is removed (including x) </li><li>without NDEBUG, BOOST_ASSERT(x) calls assert(x) </li></ul><p> For BOOST_VERIFY: </p> <ul><li>with NDEBUG, BOOST_VERIFY(x) is simply x </li><li>without NDEBUG, BOOST_VERIFY(x) is BOOST_ASSERT(x) </li></ul><p> The best that happens in an assert for Diagnostic or Debug builds (i.e., NDEBUG is not defined); but no throw on failure. And in Production or Release code (i.e., NDEBUG is defined), then nothing happens. </p> <p> <a class="changeset" href="https://svn.boost.org/trac10/changeset/1" title="Import core sources for SVNmanger 0.38 ">[1]</a> <a href="http://www.boost.org/doc/libs/1_54_0/libs/utility/assert.html">http://www.boost.org/doc/libs/1_54_0/libs/utility/assert.html</a> </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Frank Mori Hess</dc:creator> <pubDate>Fri, 26 Jul 2013 01:37:42 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/8916#comment:4 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/8916#comment:4</guid> <description> <p> Replying to <a class="ticket" href="https://svn.boost.org/trac10/ticket/8916#comment:3" title="Comment 3">Jeffrey Walton &lt;noloader@…&gt;</a>: </p> <blockquote class="citation"> <p> As I understand it (please correct me), BOOST_VERIFY is simply BOOST_ASSERT without the side effect of removal when NDEBUG is defined <a class="changeset" href="https://svn.boost.org/trac10/changeset/1" title="Import core sources for SVNmanger 0.38 ">[1]</a>. That is: </p> </blockquote> <p> That's right. I'm guessing you're arguing that is not sufficient? According to the man pages, it is impossible for the pthread functions to return errors as I am using them, except by programmer error. Thus asserting seems good enough. This is also what boost.smart_ptr does (which is where I cribbed the mutex code from). Below is a paste of the pthread man page I'm referring to. I'm not using an error checking mutex, and I am initializing the mutex, so the only possible non-zero return value is if the mutex is destroyed while locked. </p> <p> RETURN VALUE </p> <blockquote> <p> pthread_mutex_init always returns 0. The other mutex functions return 0 on success and a non-zero error code on error. </p> </blockquote> <p> ERRORS </p> <blockquote> <p> The pthread_mutex_lock function returns the following error code on error: </p> </blockquote> <blockquote> <blockquote> <p> EINVAL the mutex has not been properly initialized. </p> </blockquote> </blockquote> <blockquote> <blockquote> <p> EDEADLK </p> <blockquote> <p> the mutex is already locked by the calling thread (<code></code>error checking<em> mutexes only). </em></p> </blockquote> </blockquote> </blockquote> <blockquote> <p> The pthread_mutex_trylock function returns the following error codes on error: </p> </blockquote> <blockquote> <blockquote> <p> EBUSY the mutex could not be acquired because it was currently locked. </p> </blockquote> </blockquote> <blockquote> <blockquote> <p> EINVAL the mutex has not been properly initialized. </p> </blockquote> </blockquote> <blockquote> <p> The pthread_mutex_unlock function returns the following error code on error: </p> </blockquote> <blockquote> <blockquote> <p> EINVAL the mutex has not been properly initialized. </p> </blockquote> </blockquote> <blockquote> <blockquote> <p> EPERM the calling thread does not own the mutex (<code></code>error checking<em> mutexes only). </em></p> </blockquote> </blockquote> <blockquote> <p> The pthread_mutex_destroy function returns the following error code on error: </p> </blockquote> <blockquote> <blockquote> <p> EBUSY the mutex is currently locked. </p> </blockquote> </blockquote> </description> <category>Ticket</category> </item> <item> <dc:creator>Frank Mori Hess</dc:creator> <pubDate>Sun, 04 Aug 2013 22:10:04 GMT</pubDate> <title>status changed; resolution set https://svn.boost.org/trac10/ticket/8916#comment:5 https://svn.boost.org/trac10/ticket/8916#comment:5 <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> (In <a class="changeset" href="https://svn.boost.org/trac10/changeset/85211" title="Merged from trunk. Closes #8916 ">[85211]</a>) Merged from trunk. Closes <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/8916" title="#8916: Bugs: boost/signals2/detail/lwm_pthreads.hpp: Ignores all failures from ... (closed: fixed)">#8916</a> </p> Ticket