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

David Abrahams dave at boost-consulting.com
Fri Jun 6 05:03:25 CEST 2003


Please keep this dissussion on the C++-sig rather than emailing me
personally.

"Jacques A. Vidrine" <nectar at celabo.org> writes:

> On Wed, Jun 04, 2003 at 04:49:58PM -0400, David Abrahams wrote:
>> "Jacques A. Vidrine" <nectar at celabo.org> writes:
>> 
>> > 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!
>> 
>> 1. What happens if you build and test your example under bjam?
>> 
>> 2. Suppose you add a simple function which doesn't throw to your
>>    module and try calling that first, from Python.  Does it work?
>> 
>> 3. Can you slowly mutate the exception_translator example into your
>>    example and find out when it breaks?
>
> Sorry for the delayed reply.
>
> I haven't had a chance to figure out how to use bjam outside of the
> boost tree.  

So do it inside the Boost tree.

> But, the problem is reproduceable in the exception_translator
> example anyway.  I guess I don't know what `bjam ...
> exception_translator.run' is supposed to do, 

It's supposed to run the test.

> but it apparently didn't run the test :-)

How do you know it didn't run the test?

> When I actually load and call the exception_translator_ext, the
> exception is uncaught as in my previous simple example.
>
>   % pwd
>   ~/boost_1_29_0/libs/python/test
>   % cd bin/exception_translator_ext.so/gcc/debug/runtime-link-dynamic/shared-linkable-true/
>   % env PYTHONPATH="$PWD" 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 exception_translator_ext
>   >>> exception_translator_ext.throw_error()
>   zsh: 30040 abort (core dumped)  env PYTHONPATH="$PWD" python

This doesn't prove much.  The point of running the example under bjam
is that it handles setting up the environment properly.

-- 
Dave Abrahams
Boost Consulting
www.boost-consulting.com





More information about the Cplusplus-sig mailing list