[Numpy-discussion] Ticket review: #848, leak in PyArray_DescrFromType
Travis E. Oliphant
Fri Jul 18 22:34:16 CDT 2008
Charles R Harris wrote:
> On Fri, Jul 18, 2008 at 9:15 PM, Travis E. Oliphant
> <email@example.com <mailto:firstname.lastname@example.org>> wrote:
> Michael Abbott wrote:
> > Only half of my patch for this bug has gone into trunk, and
> without the
> > rest of my patch there remains a leak.
> Thanks for your work Michael. I've been so grateful to have you and
> Chuck and others looking carefully at the code to fix its problems.
> In this particular case, I'm not sure I see how (the rest of) your
> fixes any remaining leak. We do seem to be having a disagreement
> whether or not the reference to typecode can be pre-maturely
> but this doesn't fit what I usually call a "memory leak." I think
> there may be some other cause for remaining leaks.
> There really is (at least) one reference counting error in
> PyArray_FromAny. In particular, the obj == NULL case leaves a
> reference to typecode, then exits through the first return after
> finish. In this case robj doesn't steal a reference to typecode and
> the result can be seen in the python program above or by printing out
> the typecode->ob_refcnt from the code itself. So that needs fixing. I
> would suggest a DECREF in that section and a direct return of robj.
> The next section before finish is also a bit odd. The direct return of
> an array works fine, but if that isn't the branch taken, then
> PyArray_Return decrements the refcnt of arr, which in turn decrements
> the refcnt of typecode. I don't know if the resulting scalar holds a
> reference to typecode, but in any case the situation there should also
> be clarified.
Thank you. I will direct attention there and try to clear this up
tonight. I know Michael is finding problems that do need fixing.
More information about the Numpy-discussion