Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refleak in idle_test test_autocomplete #65881

Closed
zware opened this issue Jun 7, 2014 · 6 comments
Closed

Refleak in idle_test test_autocomplete #65881

zware opened this issue Jun 7, 2014 · 6 comments
Assignees
Labels
performance Performance or resource usage tests Tests in the Lib/test dir topic-IDLE

Comments

@zware
Copy link
Member

zware commented Jun 7, 2014

BPO 21682
Nosy @terryjreedy, @zware
Files
  • issue21682.diff
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = 'https://github.com/terryjreedy'
    closed_at = <Date 2014-06-07.08:32:26.150>
    created_at = <Date 2014-06-07.04:55:18.514>
    labels = ['expert-IDLE', 'tests', 'performance']
    title = 'Refleak in idle_test test_autocomplete'
    updated_at = <Date 2014-06-09.01:13:48.679>
    user = 'https://github.com/zware'

    bugs.python.org fields:

    activity = <Date 2014-06-09.01:13:48.679>
    actor = 'terry.reedy'
    assignee = 'terry.reedy'
    closed = True
    closed_date = <Date 2014-06-07.08:32:26.150>
    closer = 'terry.reedy'
    components = ['IDLE', 'Tests']
    creation = <Date 2014-06-07.04:55:18.514>
    creator = 'zach.ware'
    dependencies = []
    files = ['35506']
    hgrepos = []
    issue_num = 21682
    keywords = ['patch']
    message_count = 6.0
    messages = ['219914', '219919', '219924', '220042', '220044', '220076']
    nosy_count = 4.0
    nosy_names = ['terry.reedy', 'python-dev', 'zach.ware', 'Saimadhav.Heblikar']
    pr_nums = []
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'resource usage'
    url = 'https://bugs.python.org/issue21682'
    versions = ['Python 2.7', 'Python 3.4', 'Python 3.5']

    @zware
    Copy link
    Member Author

    zware commented Jun 7, 2014

    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

    @zware zware added topic-IDLE tests Tests in the Lib/test dir performance Performance or resource usage labels Jun 7, 2014
    @SaimadhavHeblikar
    Copy link
    Mannequin

    SaimadhavHeblikar mannequin commented Jun 7, 2014

    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?

    @terryjreedy
    Copy link
    Member

    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.

    @zware
    Copy link
    Member Author

    zware commented Jun 8, 2014

    Terry, did you mean to push Saimadhav's patch?

    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented Jun 8, 2014

    New changeset b8f33440cd5e by Terry Jan Reedy in branch '2.7':
    Issue bpo-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 bpo-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 bpo-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 bpo-21682: Replace EditorWindow with mock to eliminate memory leaks.
    http://hg.python.org/cpython/rev/7f14a2c10c09

    @terryjreedy
    Copy link
    Member

    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.

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    performance Performance or resource usage tests Tests in the Lib/test dir topic-IDLE
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants