[Boost-bugs] [Boost C++ Libraries] #2330: thread::interrupt() can be lost if condition_variable::wait() in progress

Subject: [Boost-bugs] [Boost C++ Libraries] #2330: thread::interrupt() can be lost if condition_variable::wait() in progress
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2008-09-16 14:12:38


#2330: thread::interrupt() can be lost if condition_variable::wait() in progress
------------------------------------------------+---------------------------
 Reporter: Don Ward <don2387ward_at_[hidden]> | Owner: anthonyw
     Type: Bugs | Status: new
Milestone: Boost 1.37.0 | Component: thread
  Version: Boost 1.36.0 | Severity: Problem
 Keywords: |
------------------------------------------------+---------------------------
 In the pthread implementation of thread, if thread::interrupt() calls
 pthread_cond_broadcast() after condition_variable::wait() has checked for
 interrupt_requested and set current_cond but before it has called
 pthread_cond_wait(), the the cond_broadcast will be ignored and the wait
 will never terminate.

 I have observed this behavior under Cygwin (with Windows XP/SP3). In my
 application it causes the program to hang in the join of the waiting
 thread.

 I think that thread::interrupt() must own the mutex associated with
 current_cond when pthread_cond_broadcast() is called. (Note that if
 thread_info->data_mutex is owned when the current_cond mutex is acquired
 then deadlock can occur.)

 I have attached a patch that demonstrates a fix for the problem. The
 patch looks good to me and works for my application but has not been
 otherwise tested.

 My application (based on the GNU Radio trunk code -
 http://gnuradio.org/trac) is large and not easily simplified, but I think
 that the potential for losing the thread::interrupt notification is
 apparent in the code. I would be happy to test proposed fixes on my
 application; creating a simple example to demonstrate the problem would be
 more difficult for me (I don't have experience programming with boost),
 but I will work on it if needed.

-- 
Ticket URL: <http://svn.boost.org/trac/boost/ticket/2330>
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:49:58 UTC