[C++-SIG] 5.0b : CXX.example throws exception.

Barry Scott barry at scottb.demon.co.uk
Thu Sep 7 00:42:29 CEST 2000

Here is what I know from CXX on FreeBSD.

If python 1.5.2 is not compiled and linked correctly you cannot import C++ code.
This was fixed for FreeBSD a few months back. Maybe the port to Linux has the
same problem.

In spite of a good python I get the following SEGV under FReeBSD with the lastest

Under FreeBSD I get:

Python 1.5.2 (#2, May 22 2000, 20:03:56)  [GCC 2.95.2 19991024 (release)] on freebsd4
Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
>>> import example
>>> example.test()
Example Test starting
Trying to convert a String to an Int
Segmentation fault (core dumped)

I cannot find a reason that the throw in this case is not trapped by the enclosing try.
Under Windows/NT and MSVC 6 + SP3 it all works as expected.

I use the following script to compile CXX on FreeBSD.

g++  -fpic -ansi  -I. -I./Demo -O -D_THREAD_SAFE -I/usr/local/include/python1.5 -I/usr/local/include/python1.5 -DHAVE_CONFIG_H -c
g++  -fpic -ansi  -I. -I./Demo -O -D_THREAD_SAFE -I/usr/local/include/python1.5 -I/usr/local/include/python1.5 -DHAVE_CONFIG_H -c
g++  -fpic -ansi  -I. -I./Demo -O -D_THREAD_SAFE -I/usr/local/include/python1.5 -I/usr/local/include/python1.5 -DHAVE_CONFIG_H -c
g++  -fpic -ansi  -I. -I./Demo -O -D_THREAD_SAFE -I/usr/local/include/python1.5 -I/usr/local/include/python1.5 -DHAVE_CONFIG_H -c
cc -fpic -ansi  -I. -I./Demo -O -D_THREAD_SAFE -I/usr/local/include/python1.5 -I/usr/local/include/python1.5 -DHAVE_CONFIG_H -c
g++  -fpic -ansi  -I. -I./Demo -O -D_THREAD_SAFE -I/usr/local/include/python1.5 -I/usr/local/include/python1.5 -DHAVE_CONFIG_H -c
g++  -shared -pthread  r.o example.o rtest.o cxxsupport.o cxxextensions.o cxx_extensions.o -lgcc  -lstdc++ -o example.so

Hope some of this helps.


> -----Original Message-----
> From: c++-sig-admin at python.org [mailto:c++-sig-admin at python.org]On
> Behalf Of Joe Van Andel
> Sent: 28 August 2000 18:14
> To: Python/C++ SIG
> Subject: [C++-SIG] 5.0b : CXX.example throws exception.
> Using Python 1.52, gcc 2.95.2 on Redhat Linux 6.2
> (As a minor correction, to run the example, I had to add
> "libraries=['stdc++']" to Demo/setup.py, in the invocation of
> 'Extension()'
> Even though I had linked Python with c++, 'cerr' was undefined until I
> linked the extension with std+++.)
> When I try to run the example (import CXX.example), it throws an
> exception:
> #0  0x80c3f64 in __throw ()
> #1  0x40422890 in Py::Object::validate (this=0xbfffdc50) at
> /local/include/python1.5/CXX/Exception.hxx:19
> #2  0x404031fc in Py::ExtensionModuleBase::module (this=0x811a548) at
> /local/include/python1.5/CXX/Objects.hxx:123
> #3  0x40403525 in Py::ExtensionModuleBase::moduleDictionary
> (this=0x811a548) at /local/etc/CXX/cxx_extensions.cxx:108
> #4  0x40424ef8 in Py::ExtensionModule<example_module>::initialize
> (this=0x811a548, module_doc=0x4043f820 "documentation for the example
> module") at /local/include/python1.5/CXX/Extensions.hxx:191
> #5  0x403de46d in initexample () at example.cxx:266
> #6  0x805f540 in _PyImport_LoadDynamicModule (name=0xbfffe754
> "CXX.example", pathname=0xbfffe2c4
> "/usr/local/lib/python1.5/site-packages/CXX/example.so", fp=0x8112828)
> at ./importdl.c:851
> Any idea how to fix this?
> --
> Joe VanAndel
> National Center for Atmospheric Research
> http://www.atd.ucar.edu/~vanandel/
> Internet: vanandel at ucar.edu

More information about the Cplusplus-sig mailing list