Modify

Ticket #7682 (closed Bugs: fixed)

Opened 17 months ago

Last modified 15 months ago

boost 1.52 named_mutex/named_condition pairing broken

Reported by: damian.coventry@… Owned by: igaztanaga
Milestone: To Be Determined Component: interprocess
Version: Boost 1.52.0 Severity: Showstopper
Keywords: Cc:

Description

The following program works in boost 1.47, however in 1.52 it does not. To test it, run 2 instances. The 2nd instance should output the numbers 1, 3, 5, 7, 9.

Under 1.52, the program outputs the number 1, and then does nothing. The fault appears to be with the named_condition and named_mutex classes.

Tested under Windows 7 Pro, SP1, using Visual Studio 2010 v10.0.40219.1 SP1Rel. The test was done with a statically linked boost date time, with Platform Toolset set to v90, i.e. linked with the library 'libboost_date_time-vc90-mt-sgd-1_47.lib'.

#include <boost/interprocess/managed_shared_memory.hpp> 
#include <boost/interprocess/sync/named_mutex.hpp> 
#include <boost/interprocess/sync/named_condition.hpp> 
#include <boost/interprocess/sync/scoped_lock.hpp> 
#include <iostream> 

int main() 
{ 
  boost::interprocess::managed_shared_memory managed_shm(boost::interprocess::open_or_create, "shm", 1024); 
  int *i = managed_shm.find_or_construct<int>("Integer")(0); 
  boost::interprocess::named_mutex named_mtx(boost::interprocess::open_or_create, "mtx"); 
  boost::interprocess::named_condition named_cnd(boost::interprocess::open_or_create, "cnd"); 
  boost::interprocess::scoped_lock<boost::interprocess::named_mutex> lock(named_mtx); 
  while (*i < 10) 
  { 
    if (*i % 2 == 0) 
    { 
      ++(*i); 
      named_cnd.notify_all(); 
      named_cnd.wait(lock); 
    } 
    else 
    { 
      std::cout << *i << std::endl; 
      ++(*i); 
      named_cnd.notify_all(); 
      named_cnd.wait(lock); 
    } 
  } 
  named_cnd.notify_all(); 
  boost::interprocess::shared_memory_object::remove("shm"); 
  boost::interprocess::named_mutex::remove("mtx"); 
  boost::interprocess::named_condition::remove("cnd"); 
}

Attachments

Change History

comment:1 Changed 15 months ago by jeff.trull@…

I can confirm this behavior on 1.52 and also in trunk, for gcc 4.7.2.

comment:2 Changed 15 months ago by jeff.trull@…

Breaking rev is 80146 "[named_/interprocess]sharable_mutex & [named_/interprocess]condition_any implemented"

comment:3 Changed 15 months ago by igaztanaga

Thanks for the report. It was also reported in #8008.

comment:4 Changed 15 months ago by igaztanaga

  • Status changed from new to closed
  • Resolution set to fixed

(In [82796]) Fixes #7682

comment:5 Changed 15 months ago by Jeff Trull <edaskel@…>

I can confirm this works in trunk now

View

Add a comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
The resolution will be deleted. Next status will be 'reopened'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.