[Numpy-discussion] segfault caused by incorrect Py_DECREF in ufunc

Tom Denniston tom.denniston@alum.dartmouth....
Fri Jul 6 18:40:28 CDT 2007


Thanks!

On 7/6/07, Travis Oliphant <oliphant@ee.byu.edu> wrote:
> 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
>
> _______________________________________________
> Numpy-discussion mailing list
> Numpy-discussion@scipy.org
> http://projects.scipy.org/mailman/listinfo/numpy-discussion
>


More information about the Numpy-discussion mailing list