Boost::Python constructor overloading problems
I have been using boost python for some time now and recently upgraded
to boost_1_28_0 and gcc 3.0.4. I started getting a segmentation fault
when using a library with an overloaded constructor. In trying to
track down the source of the problem, I wrote a simple class with an
overloaded constructor and still get the seg fault.
Perhaps there is something wrong with code or the compile statement,
but I have been unable to find. it. So I've also included some
additional info below that may give someone a clue as to what is going
wrong.
Here is the python script which calls the simple class. The
second constructor crashes with a seg fault:
from TestSimple import Simple
# Default constructor OK
d1 = Simple()
print d1.get()
i = 1
d2 = Simple(i) # this line causes the seg fault
print d2.get()
----
Here is the code I use to make the module TestSimple:
#include
I can't reproduce your problem with gcc-3.0.4 or gcc-3.1
Unzip the enclosed "user" directory to your libs/python directory and run
bjam there to test it yourself. Works for me.
-Dave
----- Original Message -----
From: "John Hunter"
I have been using boost python for some time now and recently upgraded to boost_1_28_0 and gcc 3.0.4. I started getting a segmentation fault when using a library with an overloaded constructor. In trying to track down the source of the problem, I wrote a simple class with an overloaded constructor and still get the seg fault.
[Non-text portions of this message have been removed]
Hi David, I have found out a little bit more about the problem. It only occurs if I link with the dynamic library generated by bjam in build/bin/libboost_python.so/gcc/release/inlining-on/runtime-link-dynamic/shared-linkable-true/libboost_python.so.1.28.0. When I link against the static library, which I built using the makefile linux_gcc.mak, the segmentation fault no longer occurs. I replicated the problem with OverloadTest in comprehensive.cpp (seg fault occurs when calling the first overloaded constructor iff linking against the shared lib compiled by bjam). Are you linking against the static or dynamic version of libboost_python? Below I'll include some relevant lines of my bjam output which I compiled with debug 2 and some from the make output where I build the static library. Could any of the flags that bjam sets be causing my problem if I don't also set them when building my extension module? bjam is setting -ftemplate-depth-100 -DBOOST_PYTHON_DYNAMIC_LIB -g -O0 -fno-inline -fPIC and I am setting -fPIC and -ftemplate-depth-100. BTW: I could not find the enclosed user directory you referred to in your post. Thanks, John Hunter ---- Sample bjam out: gcc-C++-action libs/python/build/bin/libboost_python.so/gcc/debug/runtime-link-dynamic/shared-linkable-true/errors.o g++ -c -Wall -ftemplate-depth-100 -DBOOST_PYTHON_DYNAMIC_LIB -g -O0 -fno-inline -fPIC -I"libs/python/build" -I"/usr/local/include/python2.1" -I"/workn/jdhunter/c/lib/boost_1_28_0" -o "libs/python/build/bin/libboost_python.so/gcc/debug/runtime-link-dynamic/shared-linkable-true/errors.o" "libs/python/build/../src/errors.cpp" gcc-Link-action libs/python/build/bin/libboost_python.so/gcc/debug/runtime-link-dynamic/shared-linkable-true/libboost_python.so LD_LIBRARY_PATH=.:/home/jdhunter/c/lib:/usr/local/lib:/usr/lib:/lib:/usr/X11R6/lib:/usr/local/lib/mysql/:/home/jdhunter/python/lib:/usr/local/lib/vtk:/home/jdhunter/c/lib/xerces/lib:/usr/local/matlab/extern/lib/glnx86:/usr/local/matlab/sys/os/glnx86/ export LD_LIBRARY_PATH g++ -g -fPIC -shared -o "libs/python/build/bin/libboost_python.so/gcc/debug/runtime-link-dynamic/shared-linkable-true/libboost_python.so.1.28.0" -L/usr/local/lib/python2.1/config "libs/python/build/bin/libboost_python.so/gcc/debug/runtime-link-dynamic/shared-linkable-true/types.o" "libs/python/build/bin/libboost_python.so/gcc/debug/runtime-link-dynamic/shared-linkable-true/classes.o" "libs/python/build/bin/libboost_python.so/gcc/debug/runtime-link-dynamic/shared-linkable-true/conversions.o" "libs/python/build/bin/libboost_python.so/gcc/debug/runtime-link-dynamic/shared-linkable-true/extension_class.o" "libs/python/build/bin/libboost_python.so/gcc/debug/runtime-link-dynamic/shared-linkable-true/functions.o" "libs/python/build/bin/libboost_python.so/gcc/debug/runtime-link-dynamic/shared-linkable-true/init_function.o" "libs/python/build/bin/libboost_python.so/gcc/debug/runtime-link-dynamic/shared-linkable-true/module_builder.o" "libs/python/build/bin/libboost_python.so/gcc/debug/runtime-link-dynamic/shared-linkable-true/objects.o" "libs/python/build/bin/libboost_python.so/gcc/debug/runtime-link-dynamic/shared-linkable-true/cross_module.o" "libs/python/build/bin/libboost_python.so/gcc/debug/runtime-link-dynamic/shared-linkable-true/errors.o" -lutil -Wl,-rpath-link,. "-Wl,-soname,libboost_python.so.1.28.0" ln -fs "libboost_python.so.1.28.0" "libs/python/build/bin/libboost_python.so/gcc/debug/runtime-link-dynamic/shared-linkable-true/libboost_python.so" --- Sample make static lib out: g++ -I/usr/local/include/boost -I/usr/local/include/python2.1 -fPIC -ftemplate-depth-21 -g -c errors.cpp rm -f libboost_python.a ar r libboost_python.a classes.o conversions.o errors.o extension_class.o functions.o init_function.o module_builder.o objects.o types.o cross_module.o
"David" == David Abrahams
writes:
David> I can't reproduce your problem with gcc-3.0.4 or gcc-3.1 David> Unzip the enclosed "user" directory to your libs/python David> directory and run bjam there to test it yourself. Works for David> me.
----- Original Message -----
From: "John Hunter"
BTW: I could not find the enclosed user directory you referred to in your post.
Sorry, please see the enclosed. Unzip the enclosed "user" directory to your libs/python directory and run bjam there to test it yourself. Works for me. If you can't make that work, please let me know. [Non-text portions of this message have been removed]
Sorry, it appears this group is configured to ignore attachments. See
http://groups.yahoo.com/group/Boost-Users/files/user.zip
-Dave
----- Original Message -----
From: "David Abrahams"
----- Original Message ----- From: "John Hunter"
BTW: I could not find the enclosed user directory you referred to in your post.
Sorry, please see the enclosed. Unzip the enclosed "user" directory to your libs/python directory and run bjam there to test it yourself. Works for me. If you can't make that work, please let me know.
[Non-text portions of this message have been removed]
participants (2)
-
David Abrahams
-
John Hunter