Hi,
I am facing an issue with the 'Shared Memory File'.. Sometimes I get the 'SharedMemory File Name' as the first element of the structure that I used, to create a 'interprocess::list' and when this happens, it means that the SharedMemory got corrupted and my program crashes. Has anyone faced this issue, or does anyone know what might be wrong?
 
Here's how I am using the Boost::Interprocess

struct

struct_a

{

char sym[6];

char desc[8];

double price;

};

typedef boost::interprocess::managed_shared_memory::segment_manager SegmentManager;
typedef boost::interprocess::allocator<struct_a, SegmentManager> shMemAllocator;
typedef boost::interprocess::list<struct_a, shMemAllocator> shMemList;
typedef boost::interprocess::managed_shared_memory shMemObject
boost::scoped_ptr< boost::interprocess::managed_shared_memory > m_shMemPtr;

shMemList* m_pList;

m_shMemPtr.reset(

new shMemObject(boost::interprocess::open_or_create, "shmemfile.shmem" , 100000*sizeof(struct_a)));

m_shMemPtr->reserve_named_objects(100000);

m_pList = m_shMemPtr->find_or_construct<shMemList>("SHMEM_NAME")(m_shMemPtr->get_segment_manager());

struct_a stOne;

strcpy(stOne.sym, "ABCDE");

strcpy(stOne.desc, "FGHIJK");

stOne.price = 10.25;

m_pList->push_back(stOne);

 

Another program Opens this sharedmemory file and reads the struct from the list and 'pops' it.

What happens sometimes is, In the first field of the struct I see 'SHMEM_NAME' and the program crashes when this happens. I am not sure what's causing the struct.field to comein as Sharedmemory name?

If I clean the shared memory file and restart it works fine but I end up with this problem some ther time. This does not happen regularly but it sure does.

 

I'd really appreciate any help figuring the solution out or if there's any mistake I am making.

Thanks in Advance,

Srinivas Gardas