Boost C++ Libraries: Ticket #4452: NDEBUG causes segv in interprocess::managed_mapped_file https://svn.boost.org/trac10/ticket/4452 <p> I have a small test program that uses interprocess::managed_mapped_file almost identically to one of the interprocess library examples - instead of using managed_shared_memory it uses the managed_mapped_file. </p> <p> The program works fine unless -DNDEBUG is set. If -DNDEBUG is set then the program segvs whilst contructing the managed_mapped_file. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/4452 Trac 1.4.3 Richard Murphy <richard.murphy@…> Mon, 19 Jul 2010 10:41:15 GMT attachment set https://svn.boost.org/trac10/ticket/4452 https://svn.boost.org/trac10/ticket/4452 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">boost-interprocess-bug-report.cpp</span> </li> </ul> Ticket Ion Gaztañaga Fri, 01 Apr 2011 18:55:19 GMT status changed; resolution set https://svn.boost.org/trac10/ticket/4452#comment:1 https://svn.boost.org/trac10/ticket/4452#comment:1 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">invalid</span> </li> </ul> <p> I could not reproduce the bug, I close this as wontfix and reopen it if the bug is reported by another user. </p> Ticket Lénaïc Huard <lhuard@…> Sat, 02 Jul 2011 16:24:00 GMT status, version, milestone changed; resolution deleted https://svn.boost.org/trac10/ticket/4452#comment:2 https://svn.boost.org/trac10/ticket/4452#comment:2 <ul> <li><strong>status</strong> <span class="trac-field-old">closed</span> → <span class="trac-field-new">reopened</span> </li> <li><strong>version</strong> <span class="trac-field-old">Boost 1.43.0</span> → <span class="trac-field-new">Boost 1.46.1</span> </li> <li><strong>resolution</strong> <span class="trac-field-deleted">invalid</span> </li> <li><strong>milestone</strong> <span class="trac-field-old">Boost 1.44.0</span> → <span class="trac-field-new">Boost 1.48.0</span> </li> </ul> <p> I have exactly the same problem with Boost 1.46.1 and even managed to reproduce it with a smaller program. </p> <p> Here is the code that reproduces the issue: </p> <pre class="wiki">#include &lt;cstdlib&gt; #include &lt;boost/interprocess/managed_shared_memory.hpp&gt; int main() { boost::interprocess::managed_shared_memory aShm( boost::interprocess::create_only, "/toto", 4096 ); return EXIT_SUCCESS; } </pre><p> In my case, this piece of code works when compiled with g++ 4.4. But this program segvs when compiled: </p> <ul><li>with g++ 4.5 or g++ 4.6; </li><li>with <code>-DNDEBUG</code> (this is really what triggers the bug); </li><li>with optimizations enabled. <code>-O1</code> is enough. </li></ul><p> I had a look at that and managed to have the above program work with <code>g++-4.6 -O1 -DNDEBUG</code> by one patch on <code>intrusive/detail/tree_algorithms.hpp</code>: </p> <pre class="wiki">--- /usr/include/boost/intrusive/detail/tree_algorithms.hpp 2011-06-12 08:15:00.000000000 +0200 +++ boost_patch/include/boost/intrusive/detail/tree_algorithms.hpp 2011-07-02 18:09:02.504756424 +0200 @@ -902,6 +902,7 @@ { //Check if commit_data has not been initialized by a insert_unique_check call. BOOST_INTRUSIVE_INVARIANT_ASSERT(commit_data.node != 0); + ((commit_data.node != 0) ? static_cast&lt;void&gt; (0) : abort()); node_ptr parent_node(commit_data.node); if(parent_node == header){ NodeTraits::set_parent(header, new_node); </pre><p> This patch makes the above program works when compiled with <code>-O1</code> but is not enough for higher level of optimizations. With <code>-O2</code> and above and the above patch, the program keeps on segfaulting. </p> <p> This is obviously not an acceptable patch and I need to better understand the issue, but I hope this gives a clue. </p> Ticket clint@… Wed, 09 Nov 2011 14:19:30 GMT <link>https://svn.boost.org/trac10/ticket/4452#comment:3 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/4452#comment:3</guid> <description> <p> I've noticed in gcc 4.5.0 that passing the -fno-tree-pta seems to clear up the issue on all optimization levels. </p> <p> There is a known issue with pointer analysis in 4.5.0 that this specific fix may be related to. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>anonymous</dc:creator> <pubDate>Wed, 09 Nov 2011 16:52:04 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/4452#comment:4 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/4452#comment:4</guid> <description> <p> Replying to <a class="ticket" href="https://svn.boost.org/trac10/ticket/4452#comment:3" title="Comment 3">clint@…</a>: </p> <blockquote class="citation"> <p> I've noticed in gcc 4.5.0 that passing the -fno-tree-pta seems to clear up the issue on all optimization levels. </p> <p> There is a known issue with pointer analysis in 4.5.0 that this specific fix may be related to. </p> </blockquote> <p> Upon further investigation, this work around doesn't actually solve the problem. Instead, it merely delayed the segmentation fault for my use case. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Ion Gaztañaga</dc:creator> <pubDate>Sat, 24 Dec 2011 11:05:56 GMT</pubDate> <title>status changed; resolution set https://svn.boost.org/trac10/ticket/4452#comment:5 https://svn.boost.org/trac10/ticket/4452#comment:5 <ul> <li><strong>status</strong> <span class="trac-field-old">reopened</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">fixed</span> </li> </ul> <p> This was fixed in Boost 1.48 marking offset_ptr operations as non-inlineable. </p> Ticket