Boost logo

Boost :

From: Robert Dailey (rcdailey_at_[hidden])
Date: 2008-02-21 12:04:27


Hi,

First off I am using Boost 1.34.1 and I have built the libraries myself
using the following command line. My compiler is MSVC 9.0.
*bjam --toolset=msvc --layout=system link=shared threading=multi
variant=debug-python stage*

The code I'm running has worked fine using *variant=debug*, however it
crashes with an "access violation" against NULL with *variant=debug-python*,
which I had assumed defined BOOST_DEBUG_PYTHON. My goal was to get the debug
Boost.Python library to link against the debug python25 shared library (it
seemed to work). Below is the code I'm compiling.

BEGIN CODE
---------------------------------------------
#define BOOST_PYTHON_DEF( func ) boost::python::def( #func, func )

using namespace boost::python;

static char const* PrintHelloWorld()
{
    return "Hello World!";
}

BOOST_PYTHON_MODULE(Script)
{
    BOOST_PYTHON_DEF( PrintHelloWorld );
}

object GetNamespace( char const* mod )
{
    object theModule = import( mod );
    return theModule.attr( "__dict__" );
}

void BeginPythonTest()
{
    try
    {
        Py_Initialize();

        initScript();

        object main = GetNamespace( "__main__" );
        object sys = GetNamespace( "sys" );

        list path( sys["path"] );
        path.insert( 0, "python" );
        sys["path"] = path;

        main["Script"] = import( "Script" );
        main["rocket"] = import( "rocket" );

        exec_file( "pythontest.py", main, main );

        Py_Finalize();
    }

    catch( error_already_set const& /*err*/ )
    {
        PyErr_Print();
    }

    catch( std::invalid_argument const& /*err*/ )
    {
        PyErr_Print();
    }
}
---------------------------------------------
END CODE

And, for your reference, the callstack at the time of the crash (note that
it may be a little bit mangled):

*> boost_python-mt-gy.dll!boost::python::objects::function::function(const
boost::python::objects::py_function & implementation={...}, const
boost::python::detail::keyword * const names_and_defaults=0x7ffdb000,
unsigned int num_keywords=3435973836) Line 104 + 0xb bytes C++
     0012f520()
     boost_python-
mt-gy.dll!boost::detail::function::void_function_ref_invoker0<void
(__cdecl*)(void),void>::invoke(boost::detail::function::function_buffer &
function_obj_ptr={...}) Line 191 C++
     boost_python-mt-gy.dll!boost::function0<void,std::allocator<boost::function_base>
>::operator()() Line 692 + 0x11 bytes C++
     boost_python-mt-gy.dll!boost::python::handle_exception_impl(boost::function0<void,std::allocator<boost::function_base>
> f={...}) Line 26 C++
     boost_python-mt-gy.dll!boost::python::handle_exception<void
(__cdecl*)(void)>(void (void)* f=0x00474695) Line 29 + 0x2c bytes C++
     boost_python-mt-gy.dll!boost::python::detail::init_module(const char *
name=0x0055ea08, void (void)* init_function=0x00474695) Line 39 + 0x9
bytes C++
     rocket_test_Debug.exe!initScript() Line 15 + 0x30 bytes C++
     rocket_test_Debug.exe!BeginPythonTest() Line 34 C++*


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