Re: [Boost-bugs] [Boost C++ Libraries] #7720: exception lock_error while intensive locking/unlocking of mutex

Subject: Re: [Boost-bugs] [Boost C++ Libraries] #7720: exception lock_error while intensive locking/unlocking of mutex
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2015-09-17 08:00:41


#7720: exception lock_error while intensive locking/unlocking of mutex
--------------------------------+------------------------
  Reporter: sergey.stepanov@… | Owner: viboes
      Type: Bugs | Status: reopened
 Milestone: Boost 1.54.0 | Component: thread
   Version: Boost 1.51.0 | Severity: Regression
Resolution: | Keywords: lock_error
--------------------------------+------------------------
Changes (by duchungjava@…):

 * status: closed => reopened
 * resolution: fixed =>

Comment:

 To whom it may concern,

 On Boost 1.57, I can replicate this problem with the following code:
 {{{#!C++
 boost::shared_mutex mutex;

 void shared_proc() {
   while ( 1 ) {
     boost::shared_lock<boost::shared_mutex> lock(mutex);
     boost::this_thread::sleep_for(boost::chrono::seconds(2));
   }
 }
 void upgrade_proc() {
   while ( 1 ) {
     boost::upgrade_lock<boost::shared_mutex> lock(mutex);
     boost::this_thread::sleep_for(boost::chrono::milliseconds(1));
   }
 }
 int main() {
   boost::thread ts(boost::bind(shared_proc));
   boost::thread t1(boost::bind(upgrade_proc));
   boost::thread t2(boost::bind(upgrade_proc));

   ts.join();
   t1.join();
   t2.join();

   return 0;
 }
 }}}

 By testing this code with different Boost versions, I've confirmed that:
 1. Boost 1.56 doesn't throw exception
 2. Boost 1.57 and 1.59 throw exception instantly

 I think the root reason is: The variable state.shared_count in
 shared_mutex.hpp couldn't be decreased/reset properly when a shared_mutex
 is being used for both shared_lock and upgrade_lock.

 (I'm using Visual Studio 2012 in this test case)

 Yours sincerely,
 Hung Mai

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/7720#comment:26>
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:19 UTC