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


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]

View this message in context:
Sent from the Boost - Users mailing list archive at

Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at