Subject: [Boost-bugs] [Boost C++ Libraries] #12499: Memory allocation fails
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2016-10-04 14:37:36
#12499: Memory allocation fails
-------------------------------------+--------------------------
Reporter: stephan.menzel@⦠| Owner: igaztanaga
Type: Bugs | Status: new
Milestone: To Be Determined | Component: interprocess
Version: Boost 1.62.0 | Severity: Regression
Keywords: container, interprocess |
-------------------------------------+--------------------------
I am having a interprocess based client-server exchange mechanism at a
critical spot in our infrastructure.
It relies on a server opening a named shm segment with a given structure
and clients being able to exchange commands and responses with it. It runs
on Windows (10) and two Linux variants (clang and gcc based).
On Windows I use MSVC14 and static linkage.
This has been written in 1.58 and upgraded every release and worked very
well up until 1.62. With this release it stopped working in all non-Debug
Configurations. In RelWithDebInfo I am getting
the somewhat funny error message:
Unhandled exception at 0x00007FF63A728630 in client.exe: Stack cookie
instrumentation code detected a stack-based buffer overrun.
This happens when the client inserts a string into the message container
living in the shm segment. A sample project demonstrating the issue
including CMakeLists is attached.
The code in question is:
{{{
typedef boost::interprocess::allocator<char,
boost::interprocess::managed_shared_memory::segment_manager>
ShmemCharAllocator;
typedef boost::interprocess::basic_string<char, std::char_traits<char>,
ShmemCharAllocator> ShmemString;
typedef boost::interprocess::allocator<ShmemString,
boost::interprocess::managed_shared_memory::segment_manager>
ShmemStringAllocator;
typedef boost::interprocess::deleter<ShmemString,
boost::interprocess::managed_shared_memory::segment_manager>
ShmemStringDeleter;
typedef boost::interprocess::managed_unique_ptr<ShmemString,
boost::interprocess::managed_shared_memory>::type ShmemStringUPtr;
typedef boost::interprocess::offset_ptr<ShmemString> ShmemStringPtr;
inline void msgmap_insert(MessageMap *n_map, CommandInterfaceSPtr
n_interface,
const boost::uint64_t n_key, const std::string &n_value) {
boost::interprocess::managed_shared_memory::segment_manager *seg_mngr =
n_interface->m_command_segment->get_segment_manager();
// create the string
ShmemStringPtr s =
seg_mngr->construct<ShmemString>(boost::interprocess::anonymous_instance)(n_value.c_str(),
seg_mngr);
(*n_map)[n_key] = s;
}
}}}
Steps to reproduce:
1) Build project against 1.62 on Windows in RelWithDebInfo and Debug
2) In either config run server.exe
3) Run client.exe in both configs.
In Debug it seems to work. In RelWithDebInfo it produces above message
(only if started in Visual Studio Debugger). If started on console, it
appears to crash. The surrounding code in the vs debugger leads me to
believe there's wrong #define dependent CPU instructions baked into the
executable which is why I think this is quite important.
Again, this used to work until 1.62.
Please have a look at it.
Cheers,
Stephan
-- Ticket URL: <https://svn.boost.org/trac/boost/ticket/12499> Boost C++ Libraries <http://www.boost.org/> Boost provides free peer-reviewed portable C++ source libraries.
This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:20 UTC