This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: regrtest.py: spurious leaks with -R option
Type: behavior Stage: resolved
Components: Tests Versions: Python 3.2, Python 3.3
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: meador.inge, python-dev, skrah
Priority: normal Keywords: patch

Created on 2012-08-12 19:31 by skrah, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
warm_latin1_cache.diff skrah, 2012-08-12 19:31 review
test_pseudo_leak.py skrah, 2012-08-12 22:36
issue15632.diff skrah, 2012-08-14 09:19 review
Messages (5)
msg168063 - (view) Author: Stefan Krah (skrah) * (Python committer) Date: 2012-08-12 19:31
With the -R option, test_buffer.py needs an additional warm-up for
the unicode_latin1 cache. Patch attached.
msg168065 - (view) Author: Meador Inge (meador.inge) * (Python committer) Date: 2012-08-12 21:23
I know the title says spurious, but is there a way to reproduce this at all?  Can I run a certain suite N times or something?  How did you find the problem?
msg168066 - (view) Author: Stefan Krah (skrah) * (Python committer) Date: 2012-08-12 22:36
I'm attaching a test case. You're right, in test_buffer it's
hard to reproduce but I've encountered the "leak" several times
in the past months.

Today I realized that the "leak" always occurred with format code
'c'. There's this passage in test_buffer:

    x = randrange(*fmtdict[mode][char])
    if char == 'c':
        x = bytes(chr(x), 'latin1')


After some head scratching I looked into regrtest.py and found
the warm_char_cache() function. The whole thing makes sense: In
each repetition of the refleak mode new characters can be added
to the unicode_latin1 cache.


So, you should be able to reproduce the issue:

$ ./python -m test -uall -R 2:2 test_pseudo_leak
[1/1] test_pseudo_leak
beginning 4 repetitions
1234
....
test_pseudo_leak leaked [8, 8] references, sum=16
1 test failed:
    test_pseudo_leak
[151225 refs]
msg168182 - (view) Author: Stefan Krah (skrah) * (Python committer) Date: 2012-08-14 09:19
Should we go all the way and also explicitly fill the small int cache?

Integers 0-255 should be initialized already, but I'm not sure
about [-5..-1] and 256. I haven't been able to create a test case
for integers though.
msg168479 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2012-08-17 21:14
New changeset dc18d73e67a5 by Stefan Krah in branch 'default':
Closes #15632: regrtest.py: fix spurious refleaks due to various caches
http://hg.python.org/cpython/rev/dc18d73e67a5
History
Date User Action Args
2022-04-11 14:57:34adminsetgithub: 59837
2012-08-17 21:14:37python-devsetstatus: open -> closed

nosy: + python-dev
messages: + msg168479

resolution: fixed
stage: patch review -> resolved
2012-08-14 09:19:53skrahsetfiles: + issue15632.diff

messages: + msg168182
2012-08-12 22:36:26skrahsetfiles: + test_pseudo_leak.py

messages: + msg168066
2012-08-12 21:23:31meador.ingesetnosy: + meador.inge
messages: + msg168065
2012-08-12 19:31:45skrahcreate