[Numpy-discussion] segfault caused by incorrect Py_DECREF in ufunc
Travis Oliphant
oliphant at ee.byu.edu
Fri Jul 6 15:43:22 EDT 2007
Tom Denniston wrote:
>Below is the code around line 900 for ufuncobject.c
>(http://svn.scipy.org/svn/numpy/trunk/numpy/core/src/ufuncobject.c)
>
>There is a decref labeled with ">>>" below that is incorrect. As per
>the python documentation
>(http://docs.python.org/api/dictObjects.html):
>
>#PyObject* PyDict_GetItem( PyObject *p, PyObject *key)
>#
>#Return value: Borrowed reference.
>#Return the object from dictionary p which has a key key. Return NULL
>if the key #key is not present, but without setting an exception.
>
>PyDict_GetItem returns a borrowed reference. Therefore this code does
>not own the contents to which the obj pointer points and should not
>decref on it. Simply removing the Py_DECREF(obj) line gets rid of the
>segfault.
>
>I was wondering if someone could confirm that my interpretation is
>correct and remove the line. I don't have access to the svn or know
>how to change it.
>
>Most people do not see this problem because it only affects user defined types.
>
>
You are right on with your analysis. Thank you for the test, check, and
fix.
I've changed it in SVN.
Best regards,
-Travis
More information about the NumPy-Discussion
mailing list