[Boost-bugs] [Boost C++ Libraries] #5840: thread.cpp: race condition in thread_proxy's thread state

Subject: [Boost-bugs] [Boost C++ Libraries] #5840: thread.cpp: race condition in thread_proxy's thread state
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2011-08-30 06:47:21


#5840: thread.cpp: race condition in thread_proxy's thread state
--------------------------------+-------------------------------------------
 Reporter: noloader@… | Owner:
     Type: Bugs | Status: new
Milestone: To Be Determined | Component: None
  Version: Boost 1.47.0 | Severity: Problem
 Keywords: |
--------------------------------+-------------------------------------------
 Using BOOST_HAS_PTHREADS to clarify the code, but all paths appear to
 suffer.


 {{{
 extern "C" {
   static void* thread_proxy(void* param)
   {
     // try
     {
       thread_param* p = static_cast<thread_param*>(param);
       boost::function0<void> threadfunc = p->m_threadfunc;
       p->started();
       threadfunc();
     }
     ...
   }
 }}}

 p->started() is called *before* the actual thread function. started() will
 change state even if an exception occurs such that the thread is not
 actually started:

 {{{
 void started()
 {
   boost::mutex::scoped_lock scoped_lock(m_mutex);
   m_started = true;
   m_condition.notify_one();
 }
 }}}

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