boost::interprocess::bad_alloc in copy ctor of slist

Hi! I have an object containing an interprocess slist (wrapped in a simple template) which I first construct outside shared memory. Then I want to push_front this object into a slist lying inside shared memory. And I get an interprocess::bad_alloc exception from the lists copy constructor. If I don't use the slist's copy ctor but something like this->assign(x.begin(), x.end()), the code runs through (the list was always empty in the test). I use gcc 4.2.4 on linux 2.6.24 (ubuntu 8.04). Boost 1.36 What am I doning wrong? Christoph Following the throwing code: #include <boost/interprocess/containers/vector.hpp> #include <boost/interprocess/containers/slist.hpp> #include <boost/interprocess/allocators/allocator.hpp> #include <boost/interprocess/managed_shared_memory.hpp> using namespace boost::interprocess; managed_shared_memory* getSegment() { static managed_shared_memory segment(create_only, "MySharedMemory", 65536); return &segment; } template<typename T> struct my_slist { typedef allocator<T, managed_shared_memory::segment_manager> ShmemAllocator; typedef slist<T, ShmemAllocator> List; my_slist() : m_list(ShmemAllocator(getSegment()->get_segment_manager())) { } void push_front(const T& obj) { m_list.push_front(obj); } List m_list; }; struct ListHolder { my_slist<int> m_slist; }; typedef my_slist<ListHolder> HolderList; int main() { shared_memory_object::remove("MySharedMemory"); HolderList *holderlist = getSegment()->construct<HolderList>("IntListHolderList")(); ListHolder asdf; holderlist->push_front(asdf); // exception boost::interprocess::bad_alloc return 0; }

Christoph Mathys wrote:
Hi!
I have an object containing an interprocess slist (wrapped in a simple template) which I first construct outside shared memory. Then I want to push_front this object into a slist lying inside shared memory. And I get an interprocess::bad_alloc exception from the lists copy constructor. If I don't use the slist's copy ctor but something like this->assign(x.begin(), x.end()), the code runs through (the list was always empty in the test).
I use gcc 4.2.4 on linux 2.6.24 (ubuntu 8.04). Boost 1.36
What am I doning wrong?
Nothing. You've hit an embarrasing bug. In theory the bug was reported and fixed recently. Try to get Interprocess from trunk SVN to see if this works. Regards, Ion

Christoph Mathys wrote:
On Wed, Dec 3, 2008 at 6:42 PM, Ion Gaztañaga <igaztanaga@gmail.com> wrote:
Nothing. You've hit an embarrasing bug. In theory the bug was reported and fixed recently. Try to get Interprocess from trunk SVN to see if this works.
It does! :)
Christoph
Nice to hear it ;-) Regards, Ion
participants (2)
-
Christoph Mathys
-
Ion Gaztañaga