Boost logo

Boost Users :

Subject: Re: [Boost-users] [boost.interprocess] Construct boost::basic_string with managed_shared_memory as memory soure crash.
From: Ion Gaztañaga (igaztanaga_at_[hidden])
Date: 2018-08-03 23:34:51


On 02/08/2018 11:31, Zhiming Wang via Boost-users wrote:
> Hi,
>
> I am using boost 1.65.1 interprocess lib, and tried to construct a
> string that is safe to store in a managed_shared_memory.
>
> Types  are defined as below:
>
>  using namespace boost::interprocess;
>  using ShmSegment_t = boost::interprocess::managed_shared_memory;
>  using SegmentMgr_t =
> boost::interprocess::managed_shared_memory::segment_manager;
>  template <typename T>
>  using Allocator_t = boost::interprocess::allocator<T, SegmentMgr_t>;
>
>  using String_t = boost::interprocess::basic_string<char,
> std::char_traits<char>, Allocator_t<char>>;
>
> Code in problem is as below:
>
> using namespace boost::interprocess;
> ShmSegment_t segment(open_or_create, "Test",  1L << 31);
> const std::string stdStr("std_str");
> String_t ipcStr( stdStr.c_str(), segment.get_segment_manager()); *//
> oops, crashed! *

Are you are reserving 2GB of memory? Do you have enough memory in your
system? Linux overcommits by default.

Best,

Ion


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