boost python and debug python binary

Today I had to deal with a rather naughty problem. At work, I have a C++ shared library which is made avaible for python using boost::python. In order to track down a segmentation fault in my C++ library , I created a python binary including debug data using
./configure --with-python-debuggingWhen I used the respective python binary, it crashed with a segmentation fault during import of the shared library. With the help of gdb I found out, that a data structure used at a specific point seemed to be screwed up or uninitialized. The memory access using a pointer from that struct caused the segmentation fault. Using a non-debug binary of python, I verified, that it was the debug version of python only, for which the error occured. After some thinking, I came to the conclusion, that the boost shared library might not be binary compatible to the debug version of the python shared library.

And later I found this link

which explains, why there’s a binary incompatibility. Damn, boost python docs reveal the important details in the smallprints! Sometimes I sincerely have the impression that they try to make it hard to use the library from the official documentation alone.

Btw. here they explain, how to debug your module without using a python debug-enabled binary.