Boost C++ Libraries: Ticket #6794: boost-1.49.0 fails to build with gcc-4.6.2: boost/smart_ptr/intrusive_ptr.hpp:94:5: internal compiler error: Segmentation fault https://svn.boost.org/trac10/ticket/6794 <p> I believe this issue is specific to gcc-4.6.2, not with less than boost-1.49, and I have what I think is a fix. Here's the error: </p> <p> gcc.compile.c++ ../bin.v2/tools/quickbook/src/gcc-4.6/release/link-static/pch-off/id_manager.o </p> <blockquote> <p> "x86_64-pc-linux-gnu-g++" -ftemplate-depth-300 -O2 -pipe -march=amdfam10 -O3 -finline-functions -Wno-inline -Wall -g0 -DBOOST_ALL_NO_LIB=1 -DBOOST_FILESYSTEM_NO_DEPRECATED -DBOOST_SYSTEM_STATIC_LINK=1 -DNDEBUG -I".." -c -o "../bin.v2/tools/quickbook/src/gcc-4.6/release/link-static/pch-off/id_manager.o" "quickbook/src/id_manager.cpp" </p> </blockquote> <p> In file included from ../boost/intrusive_ptr.hpp:16:0, </p> <blockquote> <p> from quickbook/src/fwd.hpp:15, from quickbook/src/values.hpp:20, from quickbook/src/id_manager.hpp:14, from quickbook/src/id_manager.cpp:9: </p> </blockquote> <p> ../boost/smart_ptr/intrusive_ptr.hpp: In destructor ‘boost::intrusive_ptr&lt;T&gt;::~intrusive_ptr() [with T = quickbook::file_info]’: ../boost/smart_ptr/intrusive_ptr.hpp:94:5: internal compiler error: Segmentation fault </p> <p> You can find a full build log and preprocessed id_manager.cpp at &lt;<a class="ext-link" href="https://bugs.gentoo.org/show_bug.cgi?id=411691"><span class="icon">​</span>https://bugs.gentoo.org/show_bug.cgi?id=411691</a>&gt;. Basically I noticed that if I changed the optimization level to -O[01s] or if I removed -DNDEBUG (enabling assertions), it built without error. I came up with both an arbitrary patch, and one that I think makes sense (but itself could be arbitrary since I don't fully understand what the problem is): </p> <p> --- boost_1_49_0/tools/quickbook/src/intrusive_base.hpp.orig 2012-04-14 00:26:49.360818878 -0700 +++ boost_1_49_0/tools/quickbook/src/intrusive_base.hpp 2012-04-14 00:27:10.214279871 -0700 @@ -21,7 +21,7 @@ </p> <blockquote> <p> intrusive_base() : ref_count_(0) {} intrusive_base(intrusive_base const&amp;) : ref_count_(0) {} intrusive_base&amp; operator=(intrusive_base const&amp;) { return *this; } </p> </blockquote> <ul><li> ~intrusive_base() { assert(!ref_count_); } </li></ul><p> + virtual ~intrusive_base() { assert(!ref_count_); } </p> <blockquote> <p> friend void intrusive_ptr_add_ref(T* ptr) </p> <blockquote> <p> { ++ptr-&gt;ref_count_; } </p> </blockquote> </blockquote> <p> Usually base classes need a virtual destructor, though not if you know the actual type of the object when it's destroyed. Anyway, it works now. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/6794 Trac 1.4.3 markus@… Sun, 15 Apr 2012 04:21:43 GMT attachment set https://svn.boost.org/trac10/ticket/6794 https://svn.boost.org/trac10/ticket/6794 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">boost-1.49.0-gcc462-intrusive_ptr.patch</span> </li> </ul> <p> My patch (which was mangled in the bug description). </p> Ticket Daniel James Sun, 15 Apr 2012 10:33:35 GMT status, component, milestone changed; owner set https://svn.boost.org/trac10/ticket/6794#comment:1 https://svn.boost.org/trac10/ticket/6794#comment:1 <ul> <li><strong>owner</strong> set to <span class="trac-author">Daniel James</span> </li> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">assigned</span> </li> <li><strong>component</strong> <span class="trac-field-old">Building Boost</span> → <span class="trac-field-new">quickbook</span> </li> <li><strong>milestone</strong> <span class="trac-field-old">To Be Determined</span> → <span class="trac-field-new">Boost 1.50.0</span> </li> </ul> <p> It didn't need to be virtual because the base class is never used directly. It should have been protected though. Anyway, I think I'll just remove intrusive_base. It's more hassle than it's worth. </p> <p> Btw. the gcc bug seems to happen because the non-virtual destructor is hidden by a virtual destructor in one of the derived classes. A bit of an odd thing to do, but valid in this case. </p> Ticket Daniel James Sun, 15 Apr 2012 20:02:34 GMT <link>https://svn.boost.org/trac10/ticket/6794#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6794#comment:2</guid> <description> <p> (In <a class="changeset" href="https://svn.boost.org/trac10/changeset/77998" title="Quickbook: Remove intrusive_base. Refs #6794.">[77998]</a>) Quickbook: Remove intrusive_base. Refs <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/6794" title="#6794: Bugs: boost-1.49.0 fails to build with gcc-4.6.2: ... (closed: fixed)">#6794</a>. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Daniel James</dc:creator> <pubDate>Thu, 26 Apr 2012 17:46:09 GMT</pubDate> <title>status changed; resolution set https://svn.boost.org/trac10/ticket/6794#comment:3 https://svn.boost.org/trac10/ticket/6794#comment:3 <ul> <li><strong>status</strong> <span class="trac-field-old">assigned</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">fixed</span> </li> </ul> <p> (In <a class="changeset" href="https://svn.boost.org/trac10/changeset/78210" title="Quickbook: Merge from trunk. Fixes #6691, #6794">[78210]</a>) Quickbook: Merge from trunk. Fixes <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/6691" title="#6691: Feature Requests: Add option to emit file dependencies to quickbook (closed: fixed)">#6691</a>, <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/6794" title="#6794: Bugs: boost-1.49.0 fails to build with gcc-4.6.2: ... (closed: fixed)">#6794</a> </p> Ticket