Skip to content

Reference leaks on current main #124586

Closed
Closed

Description

@Eclips4

Bug report

Bug description:

Noted by @picnixz in #119827 (comment):

Failed tests:

    test__interpchannels
    test_capi
    test__interpreters
    test_ast
    test_importlib

Test leaking resources:

    test_importlib: references
    test_ast: references
    test__interpchannels: references
    test__interpreters: memory blocks
    test_capi: memory blocks
    test_capi: references
    test__interpreters: references
    test_importlib: memory blocks
    test_ast: memory blocks
    test__interpchannels: memory blocks

I'm bisecting a bad commit right now.

CPython versions tested on:

CPython main branch

Operating systems tested on:

macOS

Activity

  1. Eclips4 commented on Sep 26, 2024

    @Eclips4
    MemberAuthor

    Bisected to d929652.
    Seems related to handling immortal objects in subinterpreters.

  2. ZeroIntensity commented on Sep 26, 2024

    @ZeroIntensity
    Member

    I don't think this is related to subinterpreters, but more that the Placeholder singleton isn't stored elsewhere, so it's never freed. It just gets reinitialized for every subinterpreter, so the leak seems greater.

    I can try and fix this much later today, but anyone feel free to try and do it before me.

  3. vstinner commented on Sep 26, 2024

    @vstinner
    Member

    The issue can be reproduced with:

    $ ./python -m test -R 3:3 test_ast -m test_subinterpreter
    (...)
    test_ast leaked [106, 106, 106] references, sum=318
    (...)
    

    which can be simplified to:

        def test_subinterpreter(self):
            code = dedent('import _functools')
            res = support.run_in_subinterp(code)
            self.assertEqual(res, 0)
  4. vstinner commented on Sep 26, 2024

    @vstinner
    Member

    I wrote PR gh-124601 to fix the leak.

  5. vstinner commented on Sep 26, 2024

    @vstinner
    Member

    The leak was fixed by #124601.

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.14bugs and security fixesextension-modulesC modules in the Modules dirtopic-C-APItype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions