[Python-Dev] refleak hunting fun!

Michael Hudson mwh at python.net
Mon Aug 18 15:25:04 EDT 2003


Walter Dörwald <walter at livinglogic.de> writes:

> Michael Hudson wrote:
>
>> Walter Dörwald <walter at livinglogic.de> writes:
>> 
>>>Michael Hudson wrote:
>>>
>>>>[...]
>>>>
>>>>>>test_codeccallbacks leaked 1107 references
>>>>
>>>>[...]
>>>>
>>>>>but there seem to be real leaks here.
>>>>
>>>>In a perverse kind of way, phew :-) Wouldn't want to have gone to all
>>>>this effort to uncover *nothing* but a bunch of false alarms...
>>>
>>>I've fixed two of the leaks.
>> Cool.  Do you think that's it for real leaks in test_codeccallbacks?
>
> All leaks in test_codeccallbacks are fixed now.

Cool!

> Take a look at
> http://styx.livinglogic.de/~walter/refleakhunt/reflog3.txt which is
> the result of running the test suite with the patch at
> http://styx.livinglogic.de/~walter/refleakhunt/unittest.diff The
> only test_codeccallbacks test that seems to leak references is
> test_callbacks() and this is the result of calling
> codecs.register_error(), i.e. the refcount leak disappears when the
> call to register_error() is moved out of the test method.

That makes sense.

> The other number that is worrying me is
> test_builtin.BuiltinTest.test_filter_subclasses() which is probably
> the result of the recent changes for tuple, str und unicode
> subclasses. I'm going to look into this tomorrow.

Goody.  I found that that test was a problem this morning but got
confused looking at the function :-)

I did notice that there are more than just leaks here, I'm afraid:

>>> class BadSeq(tuple):
...  def __getitem__(self, i):
...   raise IndexError
... 
[25508 refs]
>>> filter(None, BadSeq((1,)))
Segmentation fault


>>>http://styx.livinglogic.de/~walter/reflog3.txt
>>>
>>>(This includes only unittest based tests)
>> Cool.  Is this from CVS head?  I thought a bunch of leaks in arrays
>> had already been fixed.
>
> Seems they have. The bad numbers from test_array are gone, so
> it *was* an older checkout.

Excellent.

Cheers,
mwh

-- 
  I never realized it before, but having looked that over I'm certain
  I'd rather have my eyes burned out by zombies with flaming dung
  sticks than work on a conscientious Unicode regex engine.
                                             -- Tim Peters, 3 Dec 1998



More information about the Python-Dev mailing list