[NumPy-Tickets] [NumPy] #2216: Memory leak when an errors are raised (ie. comparison of array and empty list) (was: Memory leak in comparison of array with list?)

NumPy Trac numpy-tickets@scipy....
Tue Sep 18 10:28:18 CDT 2012


#2216: Memory leak when an errors are raised (ie. comparison of array and empty
list)
-----------------------------+----------------------------------------------
 Reporter:  Hauke            |       Owner:  somebody   
     Type:  defect           |      Status:  new        
 Priority:  normal           |   Milestone:  Unscheduled
Component:  numpy.core       |     Version:  1.6.2      
 Keywords:  list comparison  |  
-----------------------------+----------------------------------------------

Comment(by seberg):

 I have a bit trouble with finding the actual python documentation to
 clarify this...

 It seems like the problem is that throughout numpy when `PyErr_SetObject`
 is used, it is assumed that a reference is stolen from the error message,
 but it is not. So whenever broadcasting, etc. fails the error messages
 reference counting gets wrong. The fix is rather simple though, just add a
 `Py_DECREF(errmsg);` after every single `PyErr_SetObject` call. This bug
 effects also current git master.

 IE. the same thing occurs with:
 {{{
 while True:
      try:
          a *= a[:-1]
     except:
        pass
 }}}
 And a few other things (as this is used in quite a few places around
 numpy). I will probably create a PR on github later today, but if this is
 it (and it seems like it) its really easy to fix.

-- 
Ticket URL: <http://projects.scipy.org/numpy/ticket/2216#comment:1>
NumPy <http://projects.scipy.org/numpy>
My example project


More information about the NumPy-Tickets mailing list