[Numpy-tickets] [NumPy] #378: NumPy or Python crashing with segfault
NumPy
numpy-tickets at scipy.net
Mon Nov 13 06:21:58 CST 2006
#378: NumPy or Python crashing with segfault
--------------------------------+-------------------------------------------
Reporter: tecki | Owner: somebody
Type: defect | Status: reopened
Priority: normal | Milestone:
Component: numpy.core | Version:
Severity: normal | Resolution:
Keywords: segfault vectorize |
--------------------------------+-------------------------------------------
Comment (by tecki):
I think I found the bug. In ''ufuncobject.c'' line 1975, there is a
''Py_XDECREF''. This decreases the reference counter of the object
in the buffer ''castbuf''. When this buffer is re-used in the next
pass in the loop, in line 1906 the refcounter gets decreased again.
Changing the ''Py_XDECREF'' to ''Py_CLEAR'' solved my problem.
(I still get spurious segfaults, but at different places).
I think this does not introduce new bugs, since the content of the
buffer should not be used anymore anyways once ''Py_XDECREF''ed.
So I propose the following patch:
{{{
--- ufuncobject.c (révision 3435)
+++ ufuncobject.c (copie de travail)
@@ -1972,7 +1972,7 @@
size =
loop->leftover;
for (j=0; j<size;
j++) {
-
Py_XDECREF(*objptr);
+
Py_CLEAR(*objptr);
objptr +=
1;
}
}
}}}
--
Ticket URL: <http://projects.scipy.org/scipy/numpy/ticket/378#comment:5>
NumPy <http://projects.scipy.org/scipy/numpy>
The fundamental package needed for scientific computing with Python.
More information about the Numpy-tickets
mailing list