Subject: Re: [Boost-bugs] [Boost C++ Libraries] #5727: race condition between ~basic_condition_variable() and notify_all()
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2011-12-02 23:54:03
#5727: race condition between ~basic_condition_variable() and notify_all()
-------------------------------------+--------------------------------------
Reporter: sbear.powell@⦠| Owner: anthonyw
Type: Bugs | Status: new
Milestone: To Be Determined | Component: thread
Version: Boost 1.46.1 | Severity: Problem
Resolution: | Keywords:
-------------------------------------+--------------------------------------
Comment (by viboes):
I'm surely misunderstanding your code
{{{
void foo() {
condition_variable notifier;
mutex m, m2;
mutex::scoped_lock lock(m); //1
bool done=false;
thread t([&]{
mutex::scoped_lock lock(m); //2
done = true;
lock.unlock();
notifier.notify_all();
});
while(!done) notifier.wait(lock); //3
}
}}}
Doesn't this code deadlock. In 1 foo owns the lock m. In 2 the lambda
thread is blocked until the lock variable exits his scope (at the end of
foo). In 3 As done is false thread foo waits for notifier, which can not
be notified by the lambda as blocked.
What am I missing?
-- Ticket URL: <https://svn.boost.org/trac/boost/ticket/5727#comment:1> 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:07 UTC