Opened 9 years ago
Last modified 8 years ago
#8884 new Bugs
boost asio in posix_event: lock release before condition signaled
Reported by: | Owned by: | chris_kohlhoff | |
---|---|---|---|
Milestone: | To Be Determined | Component: | asio |
Version: | Boost 1.54.0 | Severity: | Problem |
Keywords: | race multi-thread | Cc: |
Description
valgrind drd warns about a possible race condition ... (possible patch:)
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 @@
{
BOOST_ASIO_ASSERT(lock.locked()); signalled_ = true;
+ ::pthread_cond_signal(&cond_); Ignore EINVAL.
lock.unlock();
- ::pthread_cond_signal(&cond_); Ignore EINVAL.
}
Reset the event.
Attachments (1)
Change History (2)
by , 9 years ago
Attachment: | posix_event_tooEarlyReleaseOfLock.patch added |
---|
comment:1 by , 8 years ago
POSIX states that (emphasis added)
"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, if predictable scheduling behavior is required, then that mutex shall be locked by the thread calling pthread_cond_broadcast() or pthread_cond_signal()." http://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_cond_signal.html
So I recommend that the patch from Carsten is applied.
possible patch for ticket #8884