Boost C++ Libraries: Ticket #6895: Segfault when using derived classed and compiling with GCC 4.7.0 https://svn.boost.org/trac10/ticket/6895 <p> In a typical situation of exporting derived virtual class to Python and calling overridden virtual function Boost Python yields segfault if the following conditions are met: </p> <ul><li>the code is compiled with GCC 4.7.0 (for 4.6.x everything is fine) </li></ul><ul><li>C++0x standard is turned on (-std=c++0x is set) </li></ul><ul><li>one declares Boost shared_ptr to store objects in Python wrapper i.e.: class_&lt; A, shared_ptr&lt;A&gt; &gt; </li></ul><p> In the attachment I include the problematic file. To reproduce the error it has to be compiled as (Python version does not matter): </p> <p> g++-4.7 -g -std=c++0x -fPIC -shared -lboost_python-py26 -lpython2.6 -I/usr/include/python2.6 -o boosterror.so boosterror.cpp </p> <p> In Python the following code causes segfault: </p> <p> import boosterror b = boosterror.B() b.f() # segfault here </p> <p> I don't know whether it is a Boost or a GCC bug. However, in the latter case, the direct cause of the problem should be identified to submit bug to GCC and the workaround for GCC 4.7.0 must be implemented in Boost. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/6895 Trac 1.4.3 Maciej Dems <maciej.dems@…> Mon, 14 May 2012 07:49:09 GMT attachment set https://svn.boost.org/trac10/ticket/6895 https://svn.boost.org/trac10/ticket/6895 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">boosterror.cpp</span> </li> </ul> <p> Source code to reproduce the bug. </p> Ticket Maciej Dems <maciej.dems@…> Mon, 14 May 2012 07:52:35 GMT attachment set https://svn.boost.org/trac10/ticket/6895 https://svn.boost.org/trac10/ticket/6895 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">python_part.py</span> </li> </ul> <p> Usage of the compiled module. </p> Ticket Ralf W. Grosse-Kunstleve Mon, 14 May 2012 13:52:55 GMT status changed; resolution set https://svn.boost.org/trac10/ticket/6895#comment:1 https://svn.boost.org/trac10/ticket/6895#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> It is highly likely that this is a gcc 4.7.0 bug (from past experience with numerous similar problems). The only way this will get fixed is that someone spends the time working on a minimal reproducer for a gcc bug report; I'd start with the gcc trunk to get the full attention of the gcc developers. </p> Ticket Jonathan Wakely <jwakely.boost@…> Thu, 14 Jun 2012 13:32:09 GMT <link>https://svn.boost.org/trac10/ticket/6895#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6895#comment:2</guid> <description> <p> This is the same as <a class="ext-link" href="http://gcc.gnu.org/PR53455"><span class="icon">​</span>http://gcc.gnu.org/PR53455</a> which is a duplicate of another GCC PR. </p> <p> Until it's fixed in GCC the workaround is to avoid mixing code built with -std=c++11 with code built with -std=c++98, specifically you need to build boosterror.cpp with the same -std setting as libboost_python.so was built with </p> </description> <category>Ticket</category> </item> </channel> </rss>