Boost logo

Boost Users :

Subject: Re: [Boost-users] [interprocess] Segmentation fault when using std::string in stl::maps in shared memory
From: hamsinv (hamsinv_at_[hidden])
Date: 2008-10-20 23:39:49


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_at_[hidden]
> 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%3A%3Amaps-in-shared-memory-tp20063079p20082932.html
Sent from the Boost - Users mailing list archive at Nabble.com.

Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net