[Boost-bugs] [Boost C++ Libraries] #7923: Multiple consecutive named_mutex::remove

Subject: [Boost-bugs] [Boost C++ Libraries] #7923: Multiple consecutive named_mutex::remove
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2013-01-24 13:57:23

#7923: Multiple consecutive named_mutex::remove
 Reporter: cbarrioy <cbarrioy@…> | Type: Bugs
   Status: new | Milestone: To Be Determined
Component: None | Version: Boost 1.52.0
 Severity: Problem | Keywords: named_mutex remove
 I have three named_mutex that need to be removed from system in the same
 inizialization function to ensure the unique existence of the named

 The problem appear with multiple consecutive calls to named_mutex::remove
 with the three named_mutex, obtaining "false" return value randomly.

 I can see that named_mutex::remove use a temporal file and rename it with
 a name generated randomly, using process/system info data, however I
 obtain the same generated name in two consecutive calls and consequently
 remove method fails

 Maybe a precision issue with time used to construct the randomly generated

 I make a simple program to reproduce the problem. With this example you
 can obtain "false" sometimes in the first iteration, sometimes at
 iteration 11000, 23000, 90000...

 #include <boost/interprocess/sync/named_mutex.hpp>
 #include <boost/interprocess/exceptions.hpp>
 #include <boost/scoped_ptr.hpp>
 #include <boost/lexical_cast.hpp>
 #include <boost/thread.hpp>

 using namespace std;

 void sharedMemoryTest()
         boost::scoped_ptr<boost::interprocess::named_mutex> mutex;
         boost::scoped_ptr<boost::interprocess::named_mutex> mutex2;

         std::string mutexName = "ASYSTEM_00000_mutex";
         std::string mutexName2 = "ASYSTEM_00001_mutex";
         bool error = false;
         int count = 0;
                         error = error ||

                         error = error ||

                 catch(boost::interprocess::interprocess_exception& ie)
                         cout<<"Error "<<ie.what() <<" on iteration:
                         error = true;

         cout<<"Error on iteration: "<<count<<std::endl;

 int _tmain(int argc, _TCHAR* argv[])
         return 0;

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