Boost logo

Boost :

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


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.

#define BOOST_PYTHON_DEF( func ) boost::python::def( #func, func )

using namespace boost::python;

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

    BOOST_PYTHON_DEF( PrintHelloWorld );

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

void BeginPythonTest()


        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( "", main, main );


    catch( error_already_set const& /*err*/ )

    catch( std::invalid_argument const& /*err*/ )

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++
(__cdecl*)(void),void>::invoke(boost::detail::function::function_buffer &
function_obj_ptr={...}) Line 191 C++
>::operator()() Line 692 + 0x11 bytes C++
> f={...}) Line 26 C++
(__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, gregod at, cpdaniel at, john at