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: Refleak in idle_test test_autocomplete
Type: resource usage Stage: resolved
Components: IDLE, Tests Versions: Python 3.4, Python 3.5, Python 2.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: terry.reedy Nosy List: Saimadhav.Heblikar, python-dev, terry.reedy, zach.ware
Priority: normal Keywords: patch

Created on 2014-06-07 04:55 by zach.ware, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
issue21682.diff Saimadhav.Heblikar, 2014-06-07 06:30 review
Messages (6)
msg219914 - (view) Author: Zachary Ware (zach.ware) * (Python committer) Date: 2014-06-07 04:55
The recently added test_autocomplete seems to be hanging onto a reference somewhere that it shouldn't be, see below.  This output was obtained by running `python -m test -R :: -uall test_idle`.  I tracked it down to test_autocomplete with hg bisect, and proved it by running the same test with test_autocomplete deleted. This refleak also causes extra scary-looking output when running other GUI tests, see http://buildbot.python.org/all/builders/x86%20Windows7%203.x/builds/8412/steps/test/logs/stdio (look for test_tk).

[1/1] test_idle
beginning 9 repetitions
123456789
warning: callback failed in WindowList <class '_tkinter.TclError'> : invalid command name ".140195409867984.windows"
...
<repeat ad nauseum>
...
warning: callback failed in WindowList <class '_tkinter.TclError'> : invalid command name ".140195377829800.windows"
.
test_idle leaked [6411, 6411, 6411, 6411] references, sum=25644
test_idle leaked [5150, 5153, 5152, 5152] memory blocks, sum=20607
1 test failed:
    test_idle
msg219919 - (view) Author: Saimadhav Heblikar (Saimadhav.Heblikar) * Date: 2014-06-07 06:30
The patch fixes the refleak. Importing EditorWindow, was perhaps the cause. It uses a dummy editwin instead. 

With reference to the current test, was there a particular reason to import real EditorWindow module?
msg219924 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2014-06-07 08:32
This concerns me. I expect that we will eventually want to test a live EditorWindow or subclass. It appears that root.destroy does not clear all the widgets created by EditorWindow(root=root). My guess it that something is created without passing in root, so that tkinter._default_root gets used instead. This needs investigation.

I actually ran into this problem before, though not in full form, as I did not commit test_formatparagraph.py with EditorWindow(). I used a mock containing a method extracted from EditorWindow that does not cause problems, after noting the following.

# A real EditorWindow creates unneeded, time-consuming baggage and
# sometimes emits shutdown warnings like this:
# "warning: callback failed in WindowList <class '_tkinter.TclError'>
# : invalid command name ".55131368.windows".
# Calling EditorWindow._close in tearDownClass prevents this but causes
# other problems (windows left open).

Why did I commit this with EditorWindow used as is? Because I forgot the above, written last August and did not think to see how easy it would be to mock the minimum needed. I need to make sure to put DO NOT USE EditorWindow ... in README.txt.

I did not get the error message in several all ok runs. We can worry later about using mock Text for a non-gui alternative. Thanks Zack for catching this and Saimadhav to fixing it.
msg220042 - (view) Author: Zachary Ware (zach.ware) * (Python committer) Date: 2014-06-08 18:51
Terry, did you mean to push Saimadhav's patch?
msg220044 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2014-06-08 18:58
New changeset b8f33440cd5e by Terry Jan Reedy in branch '2.7':
Issue #21682: Replace EditorWindow with mock to eliminate memory leaks.
http://hg.python.org/cpython/rev/b8f33440cd5e

New changeset e6cc02d32957 by Terry Jan Reedy in branch '3.4':
Issue #21682: Replace EditorWindow with mock to eliminate memory leaks.
http://hg.python.org/cpython/rev/e6cc02d32957

New changeset 30c2f65a6346 by Terry Jan Reedy in branch '2.7':
Issue #21682: Replace EditorWindow with mock to eliminate memory leaks.
http://hg.python.org/cpython/rev/30c2f65a6346

New changeset 7f14a2c10c09 by Terry Jan Reedy in branch '3.4':
Issue #21682: Replace EditorWindow with mock to eliminate memory leaks.
http://hg.python.org/cpython/rev/7f14a2c10c09
msg220076 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2014-06-09 01:13
Checking the buildbot just now, there is some other stuff after test_tk on X86 Windows 7, but I ran the command you gave (but with python_d) and it passed ok. So I presume this is really fixed and should stay closed.
History
Date User Action Args
2022-04-11 14:58:04adminsetgithub: 65881
2014-06-09 01:13:48terry.reedysetmessages: + msg220076
2014-06-08 18:58:15python-devsetnosy: + python-dev
messages: + msg220044
2014-06-08 18:51:25zach.waresetmessages: + msg220042
2014-06-07 08:32:26terry.reedysetstatus: open -> closed
resolution: fixed
messages: + msg219924

stage: needs patch -> resolved
2014-06-07 06:30:22Saimadhav.Heblikarsetfiles: + issue21682.diff
keywords: + patch
messages: + msg219919
2014-06-07 04:55:18zach.warecreate