Boost C++ Libraries: Ticket #9666: managed_shared_memory constructor crash https://svn.boost.org/trac10/ticket/9666 <p> The following code causes a crash on Visual Studio 2013 when compiling for 64-bit and with optimization. </p> <pre class="wiki">#include &lt;boost/interprocess/managed_shared_memory.hpp&gt; using namespace boost::interprocess; int main() { static const char name[] = "test_shm"; shared_memory_object::remove(name); managed_shared_memory segment(create_only, name, 65536); return 0; } </pre><p> The reported error is a buffer overrun The crash doesn't happen on 32-bit builds. It also doesn't happen when building without optimization. Finally, it doesn't happen when compiling with /GS- (disable security checks). </p> <p> This is the stack trace: </p> <pre class="wiki">msvcr120.dll!__crt_debugger_hook(int _Reserved=1) Line 60 C testshm.exe!__raise_securityfailure(_EXCEPTION_POINTERS * ExceptionPointers=0x000000013fa8c170) Line 70 C testshm.exe!__report_gsfailure(unsigned __int64 StackCookie=63963535653567328) Line 241 C testshm.exe!boost::intrusive::rbtree_algorithms&lt;boost::intrusive::rbtree_node_traits&lt;boost::interprocess::offset_ptr&lt;void,__int64,unsigned __int64,0&gt;,1&gt; &gt;::rebalance_after_insertion(const boost::interprocess::offset_ptr&lt;boost::intrusive::compact_rbtree_node&lt;boost::interprocess::offset_ptr&lt;void,__int64,unsigned __int64,0&gt; &gt;,__int64,unsigned __int64,0&gt; &amp; header=&lt;struct at NULL&gt;, boost::interprocess::offset_ptr&lt;boost::intrusive::compact_rbtree_node&lt;boost::interprocess::offset_ptr&lt;void,__int64,unsigned __int64,0&gt; &gt;,__int64,unsigned __int64,0&gt; p={...}) Line 528 C++ testshm.exe!boost::intrusive::bstree_impl&lt;boost::intrusive::bhtraits&lt;boost::interprocess::rbtree_best_fit&lt;boost::interprocess::mutex_family,boost::interprocess::offset_ptr&lt;void,__int64,unsigned __int64,0&gt;,0&gt;::block_ctrl,boost::intrusive::rbtree_node_traits&lt;boost::interprocess::offset_ptr&lt;void,__int64,unsigned __int64,0&gt;,1&gt;,0,boost::intrusive::default_tag,3&gt;,void,unsigned __int64,1,4&gt;::insert_equal(boost::interprocess::rbtree_best_fit&lt;boost::interprocess::mutex_family,boost::interprocess::offset_ptr&lt;void,__int64,unsigned __int64,0&gt;,0&gt;::block_ctrl &amp; value={...}) Line 861 C++ testshm.exe!boost::interprocess::rbtree_best_fit&lt;boost::interprocess::mutex_family,boost::interprocess::offset_ptr&lt;void,__int64,unsigned __int64,0&gt;,0&gt;::priv_add_segment(void * addr=0x0000000050000063, unsigned __int64 segment_size=1374736) Line 426 C++ testshm.exe!boost::interprocess::segment_manager&lt;char,boost::interprocess::rbtree_best_fit&lt;boost::interprocess::mutex_family,boost::interprocess::offset_ptr&lt;void,__int64,unsigned __int64,0&gt;,0&gt;,boost::interprocess::iset_index&gt;::segment_manager&lt;char,boost::interprocess::rbtree_best_fit&lt;boost::interprocess::mutex_family,boost::interprocess::offset_ptr&lt;void,__int64,unsigned __int64,0&gt;,0&gt;,boost::interprocess::iset_index&gt;(unsigned __int64 segment_size=65536) Line 414 C++ testshm.exe!boost::interprocess::ipcdetail::basic_managed_memory_impl&lt;char,boost::interprocess::rbtree_best_fit&lt;boost::interprocess::mutex_family,boost::interprocess::offset_ptr&lt;void,__int64,unsigned __int64,0&gt;,0&gt;,boost::interprocess::iset_index,8&gt;::create_impl(void * addr=0x0000000000000000, unsigned __int64 size=1) Line 176 C++ testshm.exe!boost::interprocess::ipcdetail::managed_open_or_create_impl&lt;boost::interprocess::shared_memory_object,8,1,0&gt;::priv_open_or_create&lt;boost::interprocess::ipcdetail::create_open_func&lt;boost::interprocess::ipcdetail::basic_managed_memory_impl&lt;char,boost::interprocess::rbtree_best_fit&lt;boost::interprocess::mutex_family,boost::interprocess::offset_ptr&lt;void,__int64,unsigned __int64,0&gt;,0&gt;,boost::interprocess::iset_index,8&gt; &gt; &gt;(boost::interprocess::ipcdetail::create_enum_t type=1068023640, const char * const &amp; id=0x00000000000000c2, unsigned __int64 size=8, boost::interprocess::mode_t mode=read_write, const void * addr=0x0000000000000000, const boost::interprocess::permissions &amp; perm={...}, boost::interprocess::ipcdetail::create_open_func&lt;boost::interprocess::ipcdetail::basic_managed_memory_impl&lt;char,boost::interprocess::rbtree_best_fit&lt;boost::interprocess::mutex_family,boost::interprocess::offset_ptr&lt;void,__int64,unsigned __int64,0&gt;,0&gt;,boost::interprocess::iset_index,8&gt; &gt; construct_func) Line 407 C++ testshm.exe!main() Line 9 C++ testshm.exe!__tmainCRTStartup() Line 626 C kernel32.dll!BaseThreadInitThunk() Unknown ntdll.dll!RtlUserThreadStart() Unknown </pre> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/9666 Trac 1.4.3 Roger Tue, 13 May 2014 10:21:39 GMT <link>https://svn.boost.org/trac10/ticket/9666#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/9666#comment:1</guid> <description> <p> We are also experiencing what appears to be an identical problem using Boost 1.55 and VS2013, we are also making 64Bit optimised builds when we see this problem. Changing back to Boost 1.51 or using VC10 seems to work fine - Roger </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Ion Gaztañaga</dc:creator> <pubDate>Fri, 27 Jun 2014 06:50:52 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/9666#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/9666#comment:2</guid> <description> <p> This seems solved in current develop and master branches. Could you check this? </p> </description> <category>Ticket</category> </item> <item> <author>seppleviathan@…</author> <pubDate>Thu, 03 Jul 2014 16:33:15 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/9666#comment:3 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/9666#comment:3</guid> <description> <p> Yes, this seems to be fixed in master. Thanks! </p> </description> <category>Ticket</category> </item> </channel> </rss>