[Boost-bugs] [Boost C++ Libraries] #4978: Deadlock on interrupt() all threads if they are in wait()

Subject: [Boost-bugs] [Boost C++ Libraries] #4978: Deadlock on interrupt() all threads if they are in wait()
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2010-12-13 14:53:36


#4978: Deadlock on interrupt() all threads if they are in wait()
------------------------------------+---------------------------------------
 Reporter: d.schneider@… | Owner: anthonyw
     Type: Bugs | Status: new
Milestone: To Be Determined | Component: thread
  Version: Boost 1.45.0 | Severity: Showstopper
 Keywords: |
------------------------------------+---------------------------------------
 After the change in changeset 66228 a deadlock can happen, if many threads
 are in waiting state and then all threads will be interrupted.
 I just saw the problem on a 4-core 64-bit machine (gcc (Ubuntu
 4.4.3-4ubuntu5) 4.4.3). On an older 2-core machine (gcc (GCC) 3.4.6
 20060404 (Red Hat 3.4.6-11)) this newer occurred. It only happened with
 more than 5 threads, in average in every 2nd or 3th run.

 In condition_variable::wait() the following two mutex get locked:
 1. in interrupt_checker c-tor internal_mutex, there also
 thread_info::'''cond_mutex''' = internal_mutex get set
 2. in this_thread::interrupt_point thread_info->'''data_mutex''' to
 protect thread_info::interrupt_requested

 In thread::interrupt() the same two mutex get locked in reversed order:
 1. local_thread_info->'''data_mutex'''
 2. boost::pthread::pthread_mutex_scoped_lock
 internal_lock(local_thread_info->'''cond_mutex''');

 I attached my test code.

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/4978>
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:05 UTC