Boost C++ Libraries: Ticket #8884: boost asio in posix_event: lock release before condition signaled https://svn.boost.org/trac10/ticket/8884 <p> valgrind drd warns about a possible race condition ... (possible patch:) </p> <p> Index: boost/asio/detail/posix_event.hpp =================================================================== --- boost/asio/detail/posix_event.hpp (Revision 85130) +++ boost/asio/detail/posix_event.hpp (Arbeitskopie) @@ -58,8 +58,8 @@ </p> <blockquote> <p> { </p> <blockquote> <p> BOOST_ASIO_ASSERT(lock.locked()); signalled_ = true; </p> </blockquote> </blockquote> <p> + ::pthread_cond_signal(&amp;cond_); <em> Ignore EINVAL. </em></p> <blockquote> <p> lock.unlock(); </p> </blockquote> <ul><li> ::pthread_cond_signal(&amp;cond_); <em> Ignore EINVAL. </em></li></ul><blockquote> <p> } </p> </blockquote> <p> </p> <blockquote> <p> <em> Reset the event. </em></p> </blockquote> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/8884 Trac 1.4.3 carsten.becker@… Tue, 23 Jul 2013 09:50:26 GMT attachment set https://svn.boost.org/trac10/ticket/8884 https://svn.boost.org/trac10/ticket/8884 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">posix_event_tooEarlyReleaseOfLock.patch</span> </li> </ul> <p> possible patch for ticket <a class="new ticket" href="https://svn.boost.org/trac10/ticket/8884" title="#8884: Bugs: boost asio in posix_event: lock release before condition signaled (new)">#8884</a> </p> Ticket Bjorn Reese <breese@…> Mon, 30 Jun 2014 14:34:51 GMT <link>https://svn.boost.org/trac10/ticket/8884#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/8884#comment:1</guid> <description> <p> POSIX states that (emphasis added) </p> <blockquote> <p> "The pthread_cond_broadcast() or pthread_cond_signal() functions may be called by a thread whether or not it currently owns the mutex that threads calling pthread_cond_wait() or pthread_cond_timedwait() have associated with the condition variable during their waits; however, <strong>if predictable scheduling behavior is required, then that mutex shall be locked by the thread calling pthread_cond_broadcast() or pthread_cond_signal()</strong>." <a class="ext-link" href="http://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_cond_signal.html"><span class="icon">​</span>http://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_cond_signal.html</a> </p> </blockquote> <p> So I recommend that the patch from Carsten is applied. </p> </description> <category>Ticket</category> </item> </channel> </rss>