&引用;“损坏的双链接列表”;在C+之后+;python扩展程序终止 我正在开发一个用C++代码扩展Python的程序,看起来我在初始化或清理过程中缺少了一些东西。症状是当程序终止时,它会打印出如下内容: *** glibc detected *** ... corrupted double-linked list: 0x0000000001ad0700 *** ======= Backtrace: ========= .../python2.7/site-packages/numpy/core/../.libs/libgfortran-ed201abd.so.3.0.0(+0xc249a)[0x7f242063749a] ... npy_intp dims[] = { width, height }; int nd = sizeof(dims) / sizeof(dims[0]); PyObject * ndArray = PyArray_SimpleNew( nd , dims, NPY_FLOAT32 ); Py_INCREF( ndArray ); for( int y = 0; y < dims[ 1 ]; ++y ) for( int x = 0; x < dims[ 0 ]; ++x ) * (float *) PyArray_GETPTR2( ndArray, x, y ) = ... PyObject* out = Py_BuildValue( "(Offf)", ndArray, ... ); Py_INCREF( out ); return out;

&引用;“损坏的双链接列表”;在C+之后+;python扩展程序终止 我正在开发一个用C++代码扩展Python的程序,看起来我在初始化或清理过程中缺少了一些东西。症状是当程序终止时,它会打印出如下内容: *** glibc detected *** ... corrupted double-linked list: 0x0000000001ad0700 *** ======= Backtrace: ========= .../python2.7/site-packages/numpy/core/../.libs/libgfortran-ed201abd.so.3.0.0(+0xc249a)[0x7f242063749a] ... npy_intp dims[] = { width, height }; int nd = sizeof(dims) / sizeof(dims[0]); PyObject * ndArray = PyArray_SimpleNew( nd , dims, NPY_FLOAT32 ); Py_INCREF( ndArray ); for( int y = 0; y < dims[ 1 ]; ++y ) for( int x = 0; x < dims[ 0 ]; ++x ) * (float *) PyArray_GETPTR2( ndArray, x, y ) = ... PyObject* out = Py_BuildValue( "(Offf)", ndArray, ... ); Py_INCREF( out ); return out;,c++,python-extensions,C++,Python Extensions,我这样做是为了初始化: PyMODINIT_FUNC init_dosemap() { Py_InitModule3( "_dosemap", methods, ... ); import_array(); } 数组的初始化方式如下: *** glibc detected *** ... corrupted double-linked list: 0x0000000001ad0700 *** ======= Backtrace: ========= .../python2.7/

我这样做是为了初始化:

PyMODINIT_FUNC init_dosemap()
{
    Py_InitModule3( "_dosemap", methods, ... );
    import_array();
}
数组的初始化方式如下:

*** glibc detected *** ... corrupted double-linked list: 0x0000000001ad0700 ***
======= Backtrace: =========
.../python2.7/site-packages/numpy/core/../.libs/libgfortran-ed201abd.so.3.0.0(+0xc249a)[0x7f242063749a]
...
npy_intp dims[] = { width, height };
int nd = sizeof(dims) / sizeof(dims[0]);
PyObject * ndArray = PyArray_SimpleNew( nd , dims, NPY_FLOAT32 );
Py_INCREF( ndArray );
for( int y = 0; y < dims[ 1 ]; ++y )
    for( int x = 0; x < dims[ 0 ]; ++x )
        * (float *) PyArray_GETPTR2( ndArray, x, y ) = ...
PyObject* out = Py_BuildValue( "(Offf)", ndArray, ... );
Py_INCREF( out );
return out;
填写如下:

*** glibc detected *** ... corrupted double-linked list: 0x0000000001ad0700 ***
======= Backtrace: =========
.../python2.7/site-packages/numpy/core/../.libs/libgfortran-ed201abd.so.3.0.0(+0xc249a)[0x7f242063749a]
...
npy_intp dims[] = { width, height };
int nd = sizeof(dims) / sizeof(dims[0]);
PyObject * ndArray = PyArray_SimpleNew( nd , dims, NPY_FLOAT32 );
Py_INCREF( ndArray );
for( int y = 0; y < dims[ 1 ]; ++y )
    for( int x = 0; x < dims[ 0 ]; ++x )
        * (float *) PyArray_GETPTR2( ndArray, x, y ) = ...
PyObject* out = Py_BuildValue( "(Offf)", ndArray, ... );
Py_INCREF( out );
return out;
在程序退出之前,似乎没有问题。我错过了什么