GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Ref leaks introduced by _io isolation (gh-101948) · Issue #104510 · python/cpython

Ref leaks introduced by _io isolation (gh-101948) #104510

New issue
Copy link
New issue
Copy link
Closed
#104516
Closed
Ref leaks introduced by _io isolation (gh-101948)#104510
#104516
Copy link
Assignees
kumaraditya303
Labels
release-blockertype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

Description

@Eclips4
Eclips4
opened on May 15, 2023
Issue body actions

Tried on current main.

./python -m test -R 3:3 test_nntplib
0:00:00 load avg: 2.49 Run tests sequentially
0:00:00 load avg: 2.49 [1/1] test_nntplib
beginning 6 repetitions
123456
......
test_nntplib leaked [1222, 1220, 1222] references, sum=3664
test_nntplib leaked [828, 827, 829] memory blocks, sum=2484
test_nntplib failed (reference leak)

== Tests result: FAILURE ==

1 test failed:
    test_nntplib

Total duration: 640 ms
Tests result: FAILURE

OS: WSL Ubuntu 20.04 & Windows 10

UPD:
Leaked tests:
test_nntplib
test_gzip
test_httpservers
test_xmlrpc
test_tarfile

Linked PRs

  • GH-104510: Fix refleaks in _io base types #104516
Reacted by Bogdan Romanyuk

Activity

  1. Eclips4
    added
    type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
    on May 15, 2023
  2. Eclips4 commented on May 15, 2023

    @Eclips4
    Eclips4
    on May 15, 2023
    MemberAuthor
    More actions

    Commit which introduced it
    cc @erlend-aasland

    Reacted by Erlend E. Aasland
  3. erlend-aasland commented on May 15, 2023

    @erlend-aasland
    erlend-aasland
    on May 15, 2023
    Contributor
    More actions

    Commit which introduced it

    cc @erlend-aasland

    Nice! We anticipated errors :) cc. @kumaraditya303 @vstinner

  4. Eclips4 commented on May 15, 2023

    @Eclips4
    Eclips4
    on May 15, 2023
    MemberAuthor
    More actions

    Commit which introduced it
    cc @erlend-aasland

    Nice! We anticipated errors :) cc. @kumaraditya303 @vstinner

    However, nttplib deprecated since 3.11. So, it's good that it wasn't cut out in 3.12 or earlier😄

  5. Eclips4 commented on May 15, 2023

    @Eclips4
    Eclips4
    on May 15, 2023
    MemberAuthor
    More actions

    test_gzip also affected by this commit:

    ./python -m test -R 3:3 test_gzip
    0:00:00 load avg: 0.00 Run tests sequentially
    0:00:00 load avg: 0.00 [1/1] test_gzip
    beginning 6 repetitions
    123456
    ......
    test_gzip leaked [4307, 4303, 4307] references, sum=12917
    test_gzip leaked [3239, 3237, 3239] memory blocks, sum=9715
    test_gzip failed (reference leak)
    
    == Tests result: FAILURE ==
    
    1 test failed:
        test_gzip
    
    Total duration: 4.0 sec
    Tests result: FAILURE
  6. sunmy2019 commented on May 15, 2023

    @sunmy2019
    sunmy2019
    on May 15, 2023
    Member
    More actions

    Incorrectly implemented GC likely causes this.

    e.g. I tracked down one cyclic reference here:

    class MockedNNTPTestsMixin:
        # Override in derived classes
        handler_class = None
    
        def setUp(self):
            super().setUp()
            self.make_server()
    
        def tearDown(self):
            super().tearDown()
    +       self.handler._push_data = None
            del self.server
    
        def make_server(self, *args, **kwargs):
            self.handler = self.handler_class()
            self.sio, file = make_mock_file(self.handler)
            self.server = NNTPServer(file, 'test.server', *args, **kwargs)
            return self.server

    self.handler._push_data contains reference to self.

    When I add the above line, ref leaks drop from

    test_nntplib leaked [1222, 1220, 1222] references, sum=3664
    test_nntplib leaked [828, 827, 829] memory blocks, sum=2484
    

    to

    test_nntplib leaked [343, 343, 343] references, sum=1029
    test_nntplib leaked [207, 207, 208] memory blocks, sum=622
    
  7. Eclips4 commented on May 15, 2023

    @Eclips4
    Eclips4
    on May 15, 2023
    MemberAuthor
    More actions

    test_httpservers, test_xmlrpc, test_tarfile cause also cause reference leaks.
    So, we have at least five tests with reference leaks:

    • test_nntplib
    • test_gzip
    • test_httpservers
    • test_xmlrpc
    • test_tarfile
  8. Eclips4
    changed the title [-]test_nntplib are leaked[/-] [+]Some tests are leaked[/+] on May 15, 2023
  9. sunmy2019 commented on May 15, 2023

    @sunmy2019
    sunmy2019
    on May 15, 2023
    Member
    More actions

    @Eclips4 You can try doing similar things in #104457
    186bf39 introduces three heap types; none have a *_clear set.

    cpython/Modules/_io/_iomodule.c

    Lines 681 to 687 in 186bf39

    // PyIOBase_Type subclasses
    ADD_TYPE(m, state->PyTextIOBase_Type, &textiobase_spec,
    state->PyIOBase_Type);
    ADD_TYPE(m, state->PyBufferedIOBase_Type, &bufferediobase_spec,
    state->PyIOBase_Type);
    ADD_TYPE(m, state->PyRawIOBase_Type, &rawiobase_spec,
    state->PyIOBase_Type);

    But I have not carefully examined the correct value, and I am unsure whether this will fix the issue.

  10. sunmy2019
    changed the title [-]Some tests are leaked[/-] [+]Ref leaks introduced by 186bf39[/+] on May 15, 2023
  11. Eclips4 commented on May 15, 2023

    @Eclips4
    Eclips4
    on May 15, 2023
    MemberAuthor
    More actions

    @Eclips4 You can try doing similar things in #104457 186bf39 introduces three heap types; none have a *_clear set.

    cpython/Modules/_io/_iomodule.c

    Lines 681 to 687 in 186bf39

    // PyIOBase_Type subclasses
    ADD_TYPE(m, state->PyTextIOBase_Type, &textiobase_spec,
    state->PyIOBase_Type);
    ADD_TYPE(m, state->PyBufferedIOBase_Type, &bufferediobase_spec,
    state->PyIOBase_Type);
    ADD_TYPE(m, state->PyRawIOBase_Type, &rawiobase_spec,
    state->PyIOBase_Type);

    But I have not carefully examined the correct value, and I am unsure whether this will fix the issue.

    Sure! I can try this, and later let you know results.

  12. Eclips4 commented on May 15, 2023

    @Eclips4
    Eclips4
    on May 15, 2023
    MemberAuthor
    More actions

    Seems that implementing Py_tp_clear for textiobase_spec, bufferediobase_spec, rawiobase_spec doesn't make sense. There's no need in it. I'll check other types in iomodule_exec.

  13. JelleZijlstra
    added
    release-blocker
    on May 15, 2023
  14. ezio-melotti
    added this to Release and Deferred blockers 🚫on May 15, 2023
  15. github-project-automation
    moved this to Todo in Release and Deferred blockers 🚫on May 15, 2023
  16. erlend-aasland commented on May 15, 2023

    @erlend-aasland
    erlend-aasland
    on May 15, 2023
    Contributor
    More actions

    Bisected and confirmed that 186bf39 is the first bad commit.

    Reacted by Kirill Podoprigora
  17. kumaraditya303
    self-assigned this
    on May 15, 2023
  18. kumaraditya303 commented on May 15, 2023

    @kumaraditya303
    kumaraditya303
    on May 15, 2023
    Contributor
    More actions

    #104516 fixes all the leaks mentioned

    Reacted by sunmy2019 and Kirill Podoprigora
  19. erlend-aasland
    changed the title [-]Ref leaks introduced by 186bf39[/-] [+]Ref leaks introduced by _io isolation (gh-101948)[/+] on May 16, 2023
  20. erlend-aasland
    linked a pull request that will close this issueGH-104510: Fix refleaks in _io base types #104516on May 16, 2023
  21. kumaraditya303
    closed this as completedin #104516on May 16, 2023
  22. github-project-automation
    moved this from Todo to Done in Release and Deferred blockers 🚫on May 16, 2023
  23. kumaraditya303
    added a commit that references this issue on May 16, 2023

    GH-104510: Fix refleaks in `_io` base types (#104516)

    442a3e6
  24. kumaraditya303 commented on May 16, 2023

    @kumaraditya303
    kumaraditya303
    on May 16, 2023
    Contributor
    More actions

    Thanks for the report.

  25. carljm
    added 2 commits that reference this issue on May 16, 2023

    Merge branch 'main' into supermon

    a6dd626

    Merge branch 'main' into 709funconly

    b1bb3a7
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @kumaraditya303
    kumaraditya303

Labels

release-blockertype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

Projects

  • Release and Deferred blockers 🚫
    Status
    Done
    Show more project fields

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.