[C++-sig] Boost.Python app keeps crashing in debug

David Abrahams dave at boostpro.com
Fri Feb 20 02:18:05 CET 2009


on Thu Feb 19 2009, "Martin Walser" <NurEinDummy-AT-gmx.de> wrote:

> Hi! :)
>
>
> I'm on the best way to become completely insane.
>
> I'm trying to set up VS2005 to run Boost Python in debug mode.
>
> Sorry for the long text...
>
>
> Problem summary:
>
> - applications crash in debug mode
> - dependencies to python25_d.dll AND python25.dll in
> boost_python-vc80-mt-gdy-1_35.dll - normal??

No, that's not normal.  Or at least, it's not intended.  You might try
using <define>BOOST_ALL_NO_LIB to suppress automatic linking altogether.
>
>
>
>
> Only today I found out that I have to pass a special parameter to REALLY get
> a debug version.
>
> So I went into .\boost_1_35_0\libs\python\example\quickstart
> and called bjam with:
>
> bjam toolset=msvc --verbose-test test python-debugging=on
>
> Finally I got my boost_python-vc80-mt-gdy-1_35.dll & .lib files.
>
> Yet, simply defining BOOST_DEBUG_PYTHON & BOOST_ALL_NO_LIB in the header
> didn't work out.

What header?  Why would you do that?

python-debugging=on should define BOOST_DEBUG_PYTHON automatically.  As
for BOOST_ALL_NO_LIB, try adding 

    define=BOOST_ALL_NO_LIB 

to your bjam command line.

> Had to put them in the preprocessor to make VC8 use the ...-gdy-... lib
> instead of the ...-gd-... lib. 
> And to make him stop importing Python25.lib instead of python25_d.lib when
> building my .pyd C extension.
>
>
> Finally I found out that I have to add a _d to my extension filename as well
> so that python_d.exe finds the class I want to import.

python-debugging=on should be handling that as well.

> But now... my application crashes right after starting.
> Even the HelloWorld application from the tutorial crashes instantly:
>
> Unhandled exception at ... in python_d.exe
>
> And the debugger points to boost_1_35_0\libs\python\src\object\class.cpp's:
>
>
> [...]
>
>   BOOST_PYTHON_DECL type_handle class_type()
>   {
>       if (class_type_object.tp_dict == 0)
>       {
>           class_type_object.ob_type = incref(class_metatype().get());
>           class_type_object.tp_base = &PyBaseObject_Type;
> =>!!!     if (PyType_Ready(&class_type_object))
>               return type_handle();
> //          class_type_object.tp_setattro = class_setattro;
>       }
>       return type_handle(borrowed(&class_type_object));
>   }

Sounds like something is still linking PYTHON_DEBUGGING code with a
non-debug python.dll (or vice-versa).

> Additionally, when putting boost_python-vc80-mt-gdy-1_35.dll in dependency
> walker I find dependencies to python25_d.dll AND python25.dll in it.
> I temporarily deleted python25.lib for testing ... and indeed, bjam demands
> python25.lib when building.
>
> Screenshot: http://i41.tinypic.com/2551g5j.jpg
>
>
> I hope someone with more experience got a clue...
> I'm lost. :(

Did you follow the directions in
http://boost.org/libs/python/doc/building.html
?

This used to work.  If someone broke it, I'm not sure how or who.

-- 
Dave Abrahams
BoostPro Computing
http://www.boostpro.com


More information about the Cplusplus-sig mailing list