Subject: [Boost-bugs] [Boost C++ Libraries] #9490: boost::interprocess::named_condition Functions Incorrectly Between 32-bit and 64-bit Applications
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2013-12-12 22:33:25
#9490: boost::interprocess::named_condition Functions Incorrectly Between 32-bit
and 64-bit Applications
------------------------------+--------------------------
Reporter: jsantiago@⦠| Owner: igaztanaga
Type: Bugs | Status: new
Milestone: To Be Determined | Component: interprocess
Version: Boost 1.55.0 | Severity: Problem
Keywords: |
------------------------------+--------------------------
I found that boost::interprocess::named_mutex and
boost::interprocess::shared_memory_object work as expected when used
between 32-bit and 64-bit applications. However
boost::interprocess::named_condition does not. My test environment is
CentOS-6.5 (64-bit X86_64) . I found that if I compile the following two
programs as 32-bit and 64-bit, they work fine when the 32-bit applications
are run together and when the 64-bit applications are run together. But
deadlock when the 32-bit version is used with the 64-bit version:
Program1:
{{{
#include <boost/scoped_ptr.hpp>
#include <boost/date_time.hpp>
#include <boost/thread/thread_time.hpp>
#include <boost/interprocess/sync/named_mutex.hpp>
#include <boost/interprocess/sync/named_condition.hpp>
#include <boost/interprocess/sync/scoped_lock.hpp>
#include <boost/interprocess/shared_memory_object.hpp>
#include <boost/interprocess/mapped_region.hpp>
#include <boost/interprocess/permissions.hpp>
int main(int argc, char * argv [])
{
const char * mutexName_ = "SMT_Mutex_501";
const char * condName_ = "SMT_Cond_501";
boost::interprocess::permissions permissions;
permissions.set_unrestricted();
boost::interprocess::named_mutex::remove(mutexName_);
boost::interprocess::named_condition::remove(condName_);
boost::scoped_ptr<boost::interprocess::named_mutex> nMutex_(
new boost::interprocess::named_mutex(
boost::interprocess::create_only,
mutexName_,
permissions));
boost::scoped_ptr<boost::interprocess::named_condition> nCond_(
new boost::interprocess::named_condition(
boost::interprocess::create_only,
condName_,
permissions));
while (true)
{
// Lock Mutex and Wait and notify the other process.
{
std::cout << "Obtaining Lock.\n";
boost::interprocess::scoped_lock<boost::interprocess::named_mutex>
lock(*nMutex_);
std::cout << "Holding Lock.\n";
sleep(5);
std::cout << "Notifying Other Process and Releasing Lock.\n";
nCond_->notify_all();
}
std::cout << "\n";
sleep(5);
}
boost::interprocess::named_mutex::remove(mutexName_);
boost::interprocess::named_condition::remove(condName_);
return 0;
}
}}}
Program2:
{{{
#include <boost/scoped_ptr.hpp>
#include <boost/date_time.hpp>
#include <boost/thread/thread_time.hpp>
#include <boost/interprocess/sync/named_mutex.hpp>
#include <boost/interprocess/sync/named_condition.hpp>
#include <boost/interprocess/sync/scoped_lock.hpp>
#include <boost/interprocess/shared_memory_object.hpp>
#include <boost/interprocess/mapped_region.hpp>
#include <boost/interprocess/permissions.hpp>
int main(int argc, char * argv [])
{
const char * mutexName_ = "SMT_Mutex_501";
const char * condName_ = "SMT_Cond_501";
boost::interprocess::permissions permissions;
permissions.set_unrestricted();
boost::scoped_ptr<boost::interprocess::named_mutex> nMutex_(
new boost::interprocess::named_mutex(
boost::interprocess::open_only,
mutexName_));
boost::scoped_ptr<boost::interprocess::named_condition> nCond_(
new boost::interprocess::named_condition(
boost::interprocess::open_only,
condName_));
std::cout << "Obtaining Lock.\n";
boost::interprocess::scoped_lock<boost::interprocess::named_mutex>
lock(*nMutex_);
std::cout << "Holding Lock.\n";
while (true)
{
std::cout << "Waiting to be Notified.\n";
nCond_->wait(lock);
std::cout << "Notified by Other Process.\n";
}
return 0;
}
}}}
-- Ticket URL: <https://svn.boost.org/trac/boost/ticket/9490> 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:15 UTC