Boost logo

Boost Users :

Subject: [Boost-users] Boost.Python and _GLIBCXX_DEBUG
From: Christoph Groth (cwg_at_[hidden])
Date: 2009-12-28 17:10:43


Using boost 1.40 and gcc 4.3.4 (same problem occurs with gcc 4.4.2) I
have the following problem.

After compiling the attached python module with the command

g++ -shared -fPIC -o kernel.so python.cc box.cc -lboost_python -I/usr/include/python2.5

and executing

python run.py

I get the error message

*** glibc detected *** python: free(): invalid next size (fast): 0x0000000001a32a30 ***

This error does not occur when the macro _GLIBCXX_DEBUG is not being
defined. It also does not occur when the contents of python.cc and
box.cc are put into one file.

In more complicated programs defining _GLIBCXX_DEBUG can lead to a
"Segmentation fault". Not defining _GLIBCXX_DEBUG also helps there.

Is there a way to deal with this short of not defining _GLIBCXX_DEBUG?
Could it be a bug in Boost.Python?

Thanks in advance,

Christoph

here are the files:

file python.cc:
****************************************************************
#include <boost/python.hpp>
#define _GLIBCXX_DEBUG

#include <vector>
#include "box.hh"

using namespace boost::python;

BOOST_PYTHON_MODULE(kernel)
{
    class_<Box>("Box", init<> ())
        ;
}
****************************************************************

file box.cc
****************************************************************
#define _GLIBCXX_DEBUG
#include "box.hh"

Box::Box()
{
}
****************************************************************

file box.hh
****************************************************************
#ifndef BOX_HH
#define BOX_HH

#include <vector>

class Box {
public:
    Box();
private:
    std::vector<int> blocks;
};

#endif // BOX_HH
****************************************************************

file run.py
****************************************************************
#!/usr/bin/env python
import kernel

sys = kernel.Box()
****************************************************************


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net