boost interprocess error in boost interprocess containers

994 views Asked by At

I am having a boost interprocess vector which contains string (boost::interprocess::basic_string) as values kept in shared memory, I am getting this error in long run

include/boost/interprocess/mem_algo/rbtree_best_fit.hpp:1346: void boost::interprocess::rbtree_best_fit<MutexFamily, VoidMutex, MemAlignment>::priv_deallocate(void*) [with MutexFamily = boost::interprocess::mutex_family; VoidPointer = boost::interprocess::offset_ptr<void>; long unsigned int MemAlignment = 0ul]: Assertionpriv_is_allocated_block(block)' failed.`

There is total 6 process writing to this vector and one process popping the data out.

Questions:

  1. Is there any limitation in number of process accessing a shared memory, especially boost managed containers.
  2. What I understand is that the segment manager and mem algorithm is kept in the shared memory itself, Is it correct?

I use this class:

class SharedVector {
public:
    boost::interprocess::interprocess_mutex mutex;
    complex_vect_type m_vect;
    SharedVector(const void_allocator &a) : m_vect(a) {}
};

and for creation am doing this:

memsegment->construct<SharedVector>("sharedvector") (*m_allocator); 

and in the other process am doing this to access it

mem_segment->find<SharedVector>(t"sharedvector").first;
1

There are 1 answers

7
sehe On
  1. No there is no limitation

  2. yes

You don't mention any locking. I guess this explains your problems.

Multiple processes access shared resources concurrently require the same amount of synchronization of access as multiple threads. Difference being, of course, that you use interprocess synchronization objects