mardi 6 janvier 2015

Unhandled exception when using std::mutex instead of boost::mutex

I try to get rid of some of the boost dependencies in my code and instead use the new C++11 features (Visual Studio 2013).


In one of my components I used boost::mutex together with boost::lock_guard<boost::mutex> and everything worked fine. When I use std::mutex together with std::lock_guard<std::mutex> instead, I get the following error when returning from main().



Unhandled exception at 0x7721E3BE (ntdll.dll) in GrabberTester.exe: 0xC0000005: Access violation reading location 0xA6A6B491.



The real project is quite complex and it's therefore difficult to provide a full working code example to reproduce this problem. In my real project the mutexes are used in a shared library which is loaded at runtime (but which should already be unloaded by the time I'm returning from main().


My questions are:



  • Are boost::mutex and std::mutex designed to behave absolutely the same?

  • If not, what are the differences? What do I need to keep in mind when using std::mutex instead of boost::mutex?

  • In the shared library I'm creating threads with the boost::thread framework. Could it be that std::mutex can only be used with std::threads and is incompatible with boost::threads?


Aucun commentaire:

Enregistrer un commentaire