Thank you for the pointer. Could you please explain how to use boost::interprocess::string. Regards Ravi-41 wrote:
On Monday 20 October 2008 02:38:05 hamsinv wrote:
After a few search I found out that we cannot use std::string. Instead we should try with interprocess::basic_string. Can anyone guide me through this.
The fundamental issue is that objects which allocate memory on the heap cannot be used with shared memory. Consider what happens when you use a construct a string in shared memory. Upon construction which requires storage (such as assigning it an initial value), the string constructor allocates some memory on the heap (not in the shared memory segment), which is visible only in the constructing process. Using the memory in the other processes tries to access those memory locations which results in undefined behavior. In order to overcome this problem, you need to use a shared-memory-aware string, such as interprocess::basic_string.
Please read the section named "Limitations When Constructing Objects In Mapped Regions" in the interprocess manual for more information.
Regards, Ravi
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
-- View this message in context: http://www.nabble.com/Segmentation-fault-when-using-std%3A%3Astring-in-stl%3... Sent from the Boost - Users mailing list archive at Nabble.com.