[Numpy-discussion] Ticket review: #848, leak in PyArray_DescrFromType
Charles R Harris
Fri Jul 18 22:31:46 CDT 2008
On Fri, Jul 18, 2008 at 9:15 PM, Travis E. Oliphant <email@example.com>
> 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 patch
> fixes any remaining leak. We do seem to be having a disagreement about
> whether or not the reference to typecode can be pre-maturely destroyed,
> 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.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Numpy-discussion