Boost C++ Libraries: Ticket #6201: managed_shared_memory construstor crashes https://svn.boost.org/trac10/ticket/6201 <p> The following code crashes with segmentation fault when compiled with the symbol -DNDEBUG and optimization -O1 or -O2 or -O3 using gcc 4.6.1 from ubuntu oneiric. </p> <pre class="wiki">int main(int argc, char** argv) { namespace bi = boost::interprocess; const char* name = "foobar"; bi::shared_memory_object::remove(name); bi::managed_shared_memory segment(bi::create_only, name, 10 * 1024 * 1024); } </pre><p> Without the NDEGUB symbol it always works. With NDEBUG it works only with -O0. </p> <p> The call stack obtained with -O1 -g -DNDEBUG is the following: </p> <pre class="wiki">Program received signal SIGSEGV, Segmentation fault. get_color (n=&lt;optimized out&gt;) at /usr/include/boost/intrusive/detail/rbtree_node.hpp:136 136 { return (color)ptr_bit::get_bits(n-&gt;parent_); } (gdb) bt #0 get_color (n=&lt;optimized out&gt;) at /usr/include/boost/intrusive/detail/rbtree_node.hpp:136 #1 boost::intrusive::rbtree_algorithms&lt;boost::intrusive::rbtree_node_traits&lt;boost::interprocess::offset_ptr&lt;void&gt;, true&gt; &gt;::rebalance_after_insertion (header=..., p=...) at /usr/include/boost/intrusive/rbtree_algorithms.hpp:855 #2 0x0000000000409445 in insert_equal_upper_bound&lt;boost::intrusive::detail::key_nodeptr_comp&lt;std::less&lt;boost::interprocess::rbtree_best_fit&lt;boost::interprocess::mutex_family&gt;::block_ctrl&gt;, boost::intrusive::rbtree_impl&lt;boost::intrusive::setopt&lt;boost::intrusive::detail::base_hook_traits&lt;boost::interprocess::rbtree_best_fit&lt;boost::interprocess::mutex_family&gt;::block_ctrl, boost::intrusive::rbtree_node_traits&lt;boost::interprocess::offset_ptr&lt;void&gt;, true&gt;, (boost::intrusive::link_mode_type)0, boost::intrusive::default_tag, 3&gt;, std::less&lt;boost::interprocess::rbtree_best_fit&lt;boost::interprocess::mutex_family&gt;::block_ctrl&gt;, unsigned long, true&gt; &gt; &gt; &gt; (comp=..., new_node=..., h=...) at /usr/include/boost/intrusive/rbtree_algorithms.hpp:539 #3 boost::intrusive::rbtree_impl&lt;boost::intrusive::setopt&lt;boost::intrusive::detail::base_hook_traits&lt;boost::interprocess::rbtree_best_fit&lt;boost::interprocess::mutex_family, boost::interprocess::offset_ptr&lt;void&gt;, 0ul&gt;::block_ctrl, boost::intrusive::rbtree_node_traits&lt;boost::interprocess::offset_ptr&lt;void&gt;, true&gt;, (boost::intrusive::link_mode_type)0, boost::intrusive::default_tag, 3&gt;, std::less&lt;boost::interprocess::rbtree_best_fit&lt;boost::interprocess::mutex_family, boost::interprocess::offset_ptr&lt;void&gt;, 0ul&gt;::block_ctrl&gt;, unsigned long, true&gt; &gt;::insert_equal (this=0x7ffff6477038, value=&lt;optimized out&gt;) at /usr/include/boost/intrusive/rbtree.hpp:482 #4 0x0000000000409550 in insert (value=&lt;optimized out&gt;, this=&lt;optimized out&gt;) at /usr/include/boost/intrusive/set.hpp:1569 #5 boost::interprocess::rbtree_best_fit&lt;boost::interprocess::mutex_family, boost::interprocess::offset_ptr&lt;void&gt;, 0ul&gt;::priv_add_segment (this=&lt;optimized out&gt;, addr=&lt;optimized out&gt;, size=&lt;optimized out&gt;) at /usr/include/boost/interprocess/mem_algo/rbtree_best_fit.hpp:538 #6 0x0000000000409725 in rbtree_best_fit (this=0x7ffff6477010, extra_hdr_bytes=104, size=10485744) at /usr/include/boost/interprocess/mem_algo/rbtree_best_fit.hpp:374 #7 segment_manager_base (reserved_bytes=104, size=10485744, this=0x7ffff6477010) at /usr/include/boost/interprocess/segment_manager.hpp:96 #8 boost::interprocess::segment_manager&lt;char, boost::interprocess::rbtree_best_fit&lt;boost::interprocess::mutex_family, boost::interprocess::offset_ptr&lt;void&gt;, 0ul&gt;, boost::interprocess::iset_index&gt;::segment_manager (this=0x7ffff6477010, size=10485744) at /usr/include/boost/interprocess/segment_manager.hpp:408 #9 0x000000000040a00b in create_impl (size=10485744, addr=0x7ffff6477010, this=0x7fffffffe0a0) at /usr/include/boost/interprocess/detail/managed_memory_impl.hpp:178 #10 operator() (created=true, size=10485744, addr=0x7ffff6477010, this=0x7fffffffe088) at /usr/include/boost/interprocess/detail/managed_memory_impl.hpp:735 #11 boost::interprocess::detail::managed_open_or_create_impl&lt;boost::interprocess::shared_memory_object, true, true&gt;::priv_open_or_create&lt;boost::interprocess::detail::create_open_func&lt;boost::interprocess::detail::basic_managed_memory_impl&lt;char, boost::interprocess::rbtree_best_fit&lt;boost::interprocess::mutex_family, boost::interprocess::offset_ptr&lt;void&gt;, 0ul&gt;, boost::interprocess::iset_index, 16ul&gt; &gt; &gt; ( this=0x7fffffffe0a8, type=&lt;optimized out&gt;, id=&lt;optimized out&gt;, size=10485760, mode=&lt;optimized out&gt;, addr=0x0, perm=..., construct_func=...) at /usr/include/boost/interprocess/detail/managed_open_or_create_impl.hpp:374 #12 0x0000000000404bfb in managed_open_or_create_impl&lt;boost::interprocess::detail::create_open_func&lt;boost::interprocess::detail::basic_managed_memory_impl&lt;char, boost::interprocess::rbtree_best_fit&lt;boost::interprocess::mutex_family&gt;, boost::interprocess::iset_index, 16u&gt; &gt; &gt; (construct_func=..., mode=boost::interprocess::read_write, id=@0x7fffffffe0f8, this=0x7fffffffe0a8, perm=..., addr=0x0, size=10485760) at /usr/include/boost/interprocess/detail/managed_open_or_create_impl.hpp:170 #13 basic_managed_shared_memory (perm=..., addr=0x0, size=10485760, name=0x40a8e8 "foobar", create_only=&lt;optimized out&gt;, this=0x7fffffffe0a0) at /usr/include/boost/interprocess/managed_shared_memory.hpp:90 #14 main (argc=&lt;optimized out&gt;, argv=&lt;optimized out&gt;) at /home/gaspa/programmazione/openni/main.cpp:25 </pre> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/6201 Trac 1.4.3 djgaspa@… Fri, 02 Dec 2011 23:34:06 GMT <link>https://svn.boost.org/trac10/ticket/6201#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6201#comment:1</guid> <description> <p> I can confirm that exactly the same error happens on windows using the official Mingw32 4.6.1 compiler, with both boost 1.47.0 and 1.48.0. Seems to be something wrong with any gcc 4.6 series, when optimizing with the NDEBUG symbol. </p> <p> IMHO it's a really critical bug!! </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Ion Gaztañaga</dc:creator> <pubDate>Sat, 03 Dec 2011 16:22:16 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/6201#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6201#comment:2</guid> <description> <p> I can't reproduce the bug with MingGW and GCC 4.6.2, I'll keep investigating. </p> </description> <category>Ticket</category> </item> <item> <author>djgaspa@…</author> <pubDate>Sun, 04 Dec 2011 12:49:27 GMT</pubDate> <title>status, version changed; resolution set https://svn.boost.org/trac10/ticket/6201#comment:3 https://svn.boost.org/trac10/ticket/6201#comment:3 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">closed</span> </li> <li><strong>version</strong> <span class="trac-field-old">Boost 1.48.0</span> → <span class="trac-field-new">Boost 1.47.0</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">wontfix</span> </li> </ul> <p> I'm very sorry, for some strange reason I was still using 1.47.0 headers. The problem is there, but seems to be fixed in 1.48.0. </p> Ticket