Boost logo

Boost :

From: David Abrahams (david.abrahams_at_[hidden])
Date: 2001-08-17 08:38:06


----- Original Message -----
From: "Andreas Dietrich" <quasi_at_[hidden]>
To: <boost_at_[hidden]>
Sent: Thursday, August 16, 2001 7:25 PM
Subject: [boost] BPL crash

> Hi.
>
> The following code results in a segfault when calling test from python:
>
>
> #include <Python.h>
>
> namespace

>
> PyObject *test(int l,int h){
> // not reached

How do you know this line isn't reached?

> return 0;
> }
> }
> #include <boost/python/class_builder.hpp>
> namespace python = boost::python;
> BOOST_PYTHON_MODULE_INIT(crash) {
> try {
> python::module_builder this_module("crash");
> this_module.def(test,"test");
> }
> catch(...) {
> python::handle_exception();
> }
> }
>
> My setup:
>
> Linux/i386
>
> $ g++-2.96 -v
> Reading specs from /usr/lib/gcc-lib/i586-mandrake-linux-gnu/2.96/specs
> gcc version 2.96 20000731 (Mandrake Linux 8.1 2.96-0.58mdk)
>
> I tried python 2.0, 2.1 each with and without exceptions enabled when
> compiling bpl and crash.cpp. All with the same result, import crash works
> fine, crash.test(1,1) segfaults.
>
> Can anybody help me? I tried to look at it in a debugger, but I don't even
> begin to understand the magic inside of boost::python :-(

The most obvious explanation I can imagine is that someone is trying to
increment a reference-count on the null pointer you're returning. If you can
post a GDB stack backtrace, I might be able to give you a better assessment,
though.

-Dave


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk