[C++-sig] boost::python and exceptions, seg fault

Jacques A. Vidrine nectar at celabo.org
Wed Jun 4 19:51:53 CEST 2003


[I would be much obliged if responses are cc'd to me directly, as I
 am not yet subscribed.  Thanks!]


Hello,

I've pulled some of my hair out over this.  I can't seem to get
Boost.Python (from Boost 1.29.0) to handle exceptions.  Instead, they
seem to cause the python interpreter to abort.

A very simple example is below, along with a backtrace.


cd .../boost_1_29_0/libs/python/test && bjam ... exception_translator.run
runs to completion.

Any clues would be much appreciated!


% g++ -v
Using built-in specs.
Configured with: FreeBSD/i386 system compiler
Thread model: posix
gcc version 3.2.2 [FreeBSD] 20030205 (release)

---- begin ----
#include <exception>

#include <boost/python.hpp>

void
example_func()
{
	throw std::exception();
}

BOOST_PYTHON_MODULE(example)
{
	boost::python::def("example", example_func);
}
---- end ----

% python
Python 2.2.2 (#1, Feb 11 2003, 21:28:43) 
[GCC 3.2.2 [FreeBSD] 20030205 (release)] on freebsd5
Type "help", "copyright", "credits" or "license" for more information.
>>> import example
>>> example.example()
zsh: 15134 abort (core dumped)  python

% gdb =python python.core
GNU gdb 5.2.1 (FreeBSD)
[...]
#0  0x28224357 in kill () from /usr/lib/libc.so.5
(gdb) up
#1  0x2828420e in abort () from /usr/lib/libc.so.5
(gdb) up
#2  0x28194e0a in __cxxabiv1::__terminate(void (*)()) ()
   from /usr/lib/libstdc++.so.4
(gdb) up
#3  0x28194e50 in __cxxabiv1::__unexpected(void (*)()) ()
   from /usr/lib/libstdc++.so.4
(gdb) up
#4  0x28194db5 in __cxa_throw () from /usr/lib/libstdc++.so.4
(gdb) up
#5  0x28341344 in example_func() () from ./example.so
(gdb) quit


Cheers,
-- 
Jacques Vidrine   . NTT/Verio SME      . FreeBSD UNIX       . Heimdal
nectar at celabo.org . jvidrine at verio.net . nectar at freebsd.org . nectar at kth.se




More information about the Cplusplus-sig mailing list