#6895 closed Bugs (invalid)
Segfault when using derived classed and compiling with GCC 4.7.0
Reported by: | Owned by: | Ralf W. Grosse-Kunstleve | |
---|---|---|---|
Milestone: | To Be Determined | Component: | python USE GITHUB |
Version: | Boost 1.49.0 | Severity: | Showstopper |
Keywords: | Cc: |
Description
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:
- the code is compiled with GCC 4.7.0 (for 4.6.x everything is fine)
- C++0x standard is turned on (-std=c++0x is set)
- one declares Boost shared_ptr to store objects in Python wrapper i.e.: class_< A, shared_ptr<A> >
In the attachment I include the problematic file. To reproduce the error it has to be compiled as (Python version does not matter):
g++-4.7 -g -std=c++0x -fPIC -shared -lboost_python-py26 -lpython2.6 -I/usr/include/python2.6 -o boosterror.so boosterror.cpp
In Python the following code causes segfault:
import boosterror b = boosterror.B() b.f() # segfault here
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.
Attachments (2)
Change History (4)
by , 10 years ago
Attachment: | boosterror.cpp added |
---|
comment:1 by , 10 years ago
Resolution: | → invalid |
---|---|
Status: | new → closed |
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.
comment:2 by , 10 years ago
This is the same as http://gcc.gnu.org/PR53455 which is a duplicate of another GCC PR.
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
Source code to reproduce the bug.