Re: [Boost-bugs] [Boost C++ Libraries] #5432: Deadlock with thread group's join_all and other modifier methods.

Subject: Re: [Boost-bugs] [Boost C++ Libraries] #5432: Deadlock with thread group's join_all and other modifier methods.
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2011-04-06 14:17:56


#5432: Deadlock with thread group's join_all and other modifier methods.
-------------------------------+--------------------------------------------
  Reporter: JDKunk@… | Owner: anthonyw
      Type: Bugs | Status: new
 Milestone: To Be Determined | Component: threads
   Version: Boost 1.47.0 | Severity: Showstopper
Resolution: | Keywords:
-------------------------------+--------------------------------------------

Comment (by Jeff Kunkel <JDKunk@…>):

 Woops, I made a mistake on my test case. I never unlocked the mutex in
 run, and I never returned from main.
 {{{
 #include <boost/thread.hpp>

 boost::mutex lock;
 boost::thread * t[128];
 boost::thread_group tg;

 void run(int i) {
   lock.lock();
   // remove_thread locks the thread_group's mutex,
   // and join_all locks the thread_group's mutex
   // causing deadlock.
   tg.remove_thread(t[i]); // ***** Deadlock when tg.m is locked.
   lock.unlock();
 }

 int main() {
   lock.lock();
   for( int i = 0; i < 128; ++i ) {
     t[i] = new boost::thread(run,i);
     tg.add_thread(t[i]);
   }
   lock.unlock();
   tg.join_all(); // ***** Deadlock when tg.m is locked.
   return 0;
 }
 }}}

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