Subject: Re: [Boost-bugs] [Boost C++ Libraries] #10213: Reproducible crash with Boost Asio and io_service::post
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2014-07-22 21:09:12
#10213: Reproducible crash with Boost Asio and io_service::post
-------------------------------+----------------------------
Reporter: boost-bugs@⦠| Owner: chris_kohlhoff
Type: Bugs | Status: new
Milestone: To Be Determined | Component: asio
Version: Boost 1.55.0 | Severity: Problem
Resolution: | Keywords:
-------------------------------+----------------------------
Comment (by Ben Strong <bstrong@â¦>):
We hit this bug and fixed it with the following patch:
{{{
--- a/boost/asio/detail/posix_event.hpp
+++ b/boost/asio/detail/posix_event.hpp
@@ -58,8 +58,8 @@ public:
{
BOOST_ASIO_ASSERT(lock.locked());
signalled_ = true;
- lock.unlock();
::pthread_cond_signal(&cond_); // Ignore EINVAL.
+ lock.unlock();
}
// Reset the event.
}}}
The issue is that in the task_io_service, the thread_info contains an
event, and the thread_info lifetime is protected by the mutex associated
with the lock passed into {{{signal_and_unlock}}}, so there is a race
where the event is destroyed after the {{{lock.unlock()}}} but before the
{{{pthread_cond_signal()}}}.
The "Ignore EINVAL" comment suggests that someone hit this issue before.
Unfortunately, relying on pthread_cond_signal to return an error (and not
crash) is not a sufficient solution.
-- Ticket URL: <https://svn.boost.org/trac/boost/ticket/10213#comment:2> Boost C++ Libraries <http://www.boost.org/> Boost provides free peer-reviewed portable C++ source libraries.
This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:16 UTC