[NumPy-Tickets] [NumPy] #1588: numpy.ndarray.clip segfaults on big-endian dtype
NumPy Trac
numpy-tickets@scipy....
Thu Aug 30 23:36:20 CDT 2012
#1588: numpy.ndarray.clip segfaults on big-endian dtype
------------------------+---------------------------------------------------
Reporter: bdkern | Owner: somebody
Type: defect | Status: new
Priority: normal | Milestone: 1.7.0
Component: numpy.core | Version: 1.6.1
Keywords: |
------------------------+---------------------------------------------------
Comment(by ocertik):
The following patch seems to fix it (now there are leaks):
{{{
diff --git a/numpy/core/src/multiarray/calculation.c
b/numpy/core/src/multiarray/calculation.c
index 618a871..1dd4a18 100644
--- a/numpy/core/src/multiarray/calculation.c
+++ b/numpy/core/src/multiarray/calculation.c
@@ -931,7 +931,7 @@ PyArray_Clip(PyArrayObject *self, PyObject *min,
PyObject *max, PyArrayObject *o
}
if (max != NULL) {
newdescr = PyArray_DescrFromObject(max, indescr);
- Py_XDECREF(indescr);
+ //Py_XDECREF(indescr);
if (newdescr == NULL) {
return NULL;
}
@@ -959,12 +959,12 @@ PyArray_Clip(PyArrayObject *self, PyObject *min,
PyObject *max, PyArrayObject *o
indescr = PyArray_DESCR(self);
Py_INCREF(indescr);
}
- Py_DECREF(newdescr);
+ //Py_DECREF(newdescr);
if (!PyDataType_ISNOTSWAPPED(indescr)) {
PyArray_Descr *descr2;
descr2 = PyArray_DescrNewByteorder(indescr, '=');
- Py_DECREF(indescr);
+ //Py_DECREF(indescr);
if (descr2 == NULL) {
goto fail;
}
@@ -981,7 +981,7 @@ PyArray_Clip(PyArrayObject *self, PyObject *min,
PyObject *max, PyArrayObject *o
}
else {
/* Side-effect of PyArray_FromAny */
- Py_DECREF(indescr);
+ //Py_DECREF(indescr);
}
/*
@@ -998,14 +998,14 @@ PyArray_Clip(PyArrayObject *self, PyObject *min,
PyObject *max, PyArrayObject *o
zero = PyInt_FromLong(0);
cmp = PyObject_RichCompareBool(min, zero, Py_LT);
if (cmp == -1) {
- Py_DECREF(zero);
+ //Py_DECREF(zero);
goto fail;
}
if (cmp == 1) {
min = zero;
}
else {
- Py_DECREF(zero);
+ //Py_DECREF(zero);
Py_INCREF(min);
}
}
@@ -1017,7 +1017,7 @@ PyArray_Clip(PyArrayObject *self, PyObject *min,
PyObject *max, PyArrayObject *o
Py_INCREF(indescr);
mina = (PyArrayObject *)PyArray_FromAny(min, indescr, 0, 0,
NPY_ARRAY_DEFAULT, NULL);
- Py_DECREF(min);
+ //Py_DECREF(min);
if (mina == NULL) {
goto fail;
}
@@ -1147,11 +1147,11 @@ PyArray_Clip(PyArrayObject *self, PyObject *min,
PyObject *max, PyArrayObject *o
func(PyArray_DATA(newin), PyArray_SIZE(newin), min_data, max_data,
PyArray_DATA(newout));
/* Clean up temporary variables */
- Py_XDECREF(mina);
- Py_XDECREF(maxa);
- Py_DECREF(newin);
+ //Py_XDECREF(mina);
+ //Py_XDECREF(maxa);
+ //Py_DECREF(newin);
/* Copy back into out if out was not already a nice array. */
- Py_DECREF(newout);
+ //Py_DECREF(newout);
return (PyObject *)out;
fail:
}}}
So the problem is right here somewhere.
--
Ticket URL: <http://projects.scipy.org/numpy/ticket/1588#comment:9>
NumPy <http://projects.scipy.org/numpy>
My example project
More information about the NumPy-Tickets
mailing list