Boost logo

Boost :

Subject: [boost] Need help >> Boost's managed_shared_memory usage in between two processes (C and C++)
From: vijay sharma (sharmavijay1991_at_[hidden])
Date: 2017-10-08 08:18:44


Hi,

I am having a Design/Implementation issue with Boost managed_shared_memory.
Let me describe it:

-------------------- Problem -------------------------
I am having two processes (i) Writer (ii) Reader

Here Writer is a c++ executable which is using boost to write in shared
memory. Code snapshot for writing method:

shm_controller.reset(new boost::interprocess::managed_shared_memory(
boost::interprocess::open_or_create, shmName, size));void * addr =
shm_controller->allocate(size) ;
shm_controller ->deallocate(addr);

Once I have addr pointer, I am using memcpy to write in SHM.

On other hand I am having Reader, which is C executable. They both are
communicating via message passing application. I wrote Reader code in such
way:
Writer is passing address, which is stored in "addr" (from above code
snapshot) to Reader.
Once reader receive the address and size, I am using memcpy to write SHM
data in Reader's local variable.
Note1:- (This reader is not using any boost shm API, as it's C application )
Note2:- I validated address is same on Writer and reader (after
communication).

But reader's memcpy to read shm data is leading crash in my executable
(reader).

-------------------------------------------------------------

I need help in :
1) Can we use boost::interprocess::managed_shared_memory in C ??
2) Is there any implementation problem in above section. (can't a reader
access shm of writer via pointer)
3) Is there a way to solve this C and C++ limitation like any wrapper
implementation etc.

Please provide me any kind of help or pointers on this issue, as I am stuck
with this and need to resolve it ASAP.

Thanks,
sharmavijay1991_at_[hidden]


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk