Skip to content

test_io is leaking references #86311

Closed
Closed

Description

@pablogsal
BPO 42145
Nosy @pablogsal, @shihai1991

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 = None
closed_at = <Date 2020-10-25.18:39:32.963>
created_at = <Date 2020-10-25.05:51:18.166>
labels = ['tests', '3.10']
title = 'test_io is leaking references'
updated_at = <Date 2020-10-25.18:39:50.596>
user = 'https://github.com/pablogsal'

bugs.python.org fields:

activity = <Date 2020-10-25.18:39:50.596>
actor = 'pablogsal'
assignee = 'none'
closed = True
closed_date = <Date 2020-10-25.18:39:32.963>
closer = 'pablogsal'
components = ['Tests']
creation = <Date 2020-10-25.05:51:18.166>
creator = 'pablogsal'
dependencies = []
files = []
hgrepos = []
issue_num = 42145
keywords = []
message_count = 5.0
messages = ['379564', '379566', '379591', '379599', '379600']
nosy_count = 2.0
nosy_names = ['pablogsal', 'shihai1991']
pr_nums = []
priority = 'normal'
resolution = 'fixed'
stage = 'resolved'
status = 'closed'
superseder = None
type = None
url = 'https://bugs.python.org/issue42145'
versions = ['Python 3.10']

Activity

  1. pablogsal commented on Oct 25, 2020

    @pablogsal
    MemberAuthor

    ❯ ./python -m test test_io -m test.test_io.CTextIOWrapperTest.test_read_one_by_one -R :
    0:00:00 load avg: 1.59 Run tests sequentially
    0:00:00 load avg: 1.59 [1/1] test_io
    beginning 9 repetitions
    123456789
    .........
    test_io leaked [3, 3, 3, 3] references, sum=12
    test_io leaked [1, 1, 1, 1] memory blocks, sum=4
    test_io failed

    == Tests result: FAILURE ==

    1 test failed:
    test_io

    Total duration: 398 ms
    Tests result: FAILURE

  2. added
    3.10 (EOL)
    tests
    on Oct 25, 2020
  3. pablogsal commented on Oct 25, 2020

    @pablogsal
    MemberAuthor

    Commit c9f696c introduced a reference leak in the test suite. See https://bugs.python.org/issue42145:

    c9f696c is the first bad commit
    commit c9f696c
    Author: Hai Shi <shihai1992@gmail.com>
    Date: Fri Oct 16 16:34:15 2020 +0800

    bpo-41919, test_codecs: Move codecs.register calls to setUp() (GH-22513)
    

    Reverting the commit eliminates the problem:

    rences, sum=12
    test_io leaked [1, 1, 1, 1] memory blocks, sum=4
    test_io failed

    == Tests result: FAILURE ==

    1 test failed:
    test_io

    Total duration: 397 ms
    Tests result: FAILURE
    g
    ~/github/python/master master|bisect*
    ❯ git revert c9f696c
    Auto-merging Lib/test/test_codecs.py
    [master f3de7c00b4] Revert "bpo-41919, test_codecs: Move codecs.register calls to setUp() (GH-22513)"
    7 files changed, 112 insertions(+), 16 deletions(-)

    ~/github/python/master master|bisect* ⇡
    ❯ make -j -s
    CC='gcc -pthread' LDSHARED='gcc -pthread -shared ' OPT='-g -Og -Wall' _TCLTK_INCLUDES='' _TCLTK_LIBS='' ./python -E ./setup.py -q build

    The following modules found by detect_modules() in setup.py, have been
    built by the Makefile instead, as configured by the Setup files:
    _abc atexit pwd
    time

    ~/github/python/master master|bisect* ⇡
    ❯ ./python -m test test_io -m test.test_io.CTextIOWrapperTest.test_read_one_by_one -R :
    0:00:00 load avg: 2.57 Run tests sequentially
    0:00:00 load avg: 2.57 [1/1] test_io
    beginning 9 repetitions
    123456789
    .........

    == Tests result: SUCCESS ==

    1 test OK.

    Total duration: 455 ms
    Tests result: SUCCESS

    * Move the codecs' (un)register operation to testcases.
    * Remove _codecs._forget_codec() and _PyCodec_Forget()
    

    Lib/test/test_charmapcodec.py | 7 +++++--
    Lib/test/test_codecs.py | 25 +++----------------------
    Lib/test/test_io.py | 7 +++----
    Lib/test/test_unicode.py | 5 ++++-
    Modules/_codecsmodule.c | 20 --------------------
    Modules/clinic/_codecsmodule.c.h | 39 +--------------------------------------
    Python/codecs.c | 25 -------------------------
    7 files changed, 16 insertions(+), 112 deletions(-)

  4. shihai1991 commented on Oct 25, 2020

    @shihai1991
    Member

    I created a possible fix PR: PR-22973

  5. pablogsal commented on Oct 25, 2020

    @pablogsal
    MemberAuthor

    Fixed by #22973

  6. pablogsal commented on Oct 25, 2020

    @pablogsal
    MemberAuthor

    Thanks for the quick fix, hai shi

  7. transferred this issue fromon Apr 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.10 (EOL)tests

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions