Re: [Boost-bugs] [Boost C++ Libraries] #11317: boost unique_lock has no mutex

Subject: Re: [Boost-bugs] [Boost C++ Libraries] #11317: boost unique_lock has no mutex
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2015-05-20 15:31:08

#11317: boost unique_lock has no mutex
  Reporter: shyamps@… | Owner: viboes
      Type: Support | Status: assigned
  Requests | Component: thread
 Milestone: To Be | Severity: Problem
  Determined | Keywords: boost unique_lock has no mutex
   Version: Boost 1.58.0 |
Resolution: |

Comment (by shyamps@…):

 Replying to [comment:1 viboes]:
> I would need more context, but I suspect that you are moving a
 unique_lock and then you are locking it.
> How optimization change the behavior of your application is out of my


 Heres a sample code snippet that can be used to reproduce this issue on
 msvc 12.0:

 #include <boost/thread.hpp>

 class MyClass
   boost::mutex myboostmutex;


   void Function1();
   void Function2();

 void MyClass::Function1()
   boost::mutex::scoped_lock SomeVariable (myboostmutex);

   //Application code

 void MyClass::Function2()
   boost::mutex::scoped_lock SomeVariable (myboostmutex);

   //Application code

 To reproduce this bug, you need to follow these steps:

 1) Compile code with one of the flags /Og, /O1, /O2 or /Ox Flags (TURNED
 ON) in msvc 12.0 compiler.
 2) Create an instance of MyClass;
 3) First invoke Function1(), it should execute without any issue.
 4) Next execute Function2().

 When the code attempts to execute the boost::mutex::scoped_lock
 SomeVariable(myboostmutex) line in Function2() You can see a runtime
 exception "boost unique_lock has no mutex". The same erroneous behaviour
 doesn't occur when you turn off all the above mentioned compiler
 optimization flags.

 I would recommend trying to compile boost 1_58 library on an older version
 msvc 10.0 or msvc 11.0 compiler. That can help isolate the problem to
 determine if this is related to the compiler version.


Ticket URL: <>
Boost C++ Libraries <>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:18 UTC