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

Reference leaks on current main #124586

Closed
Eclips4 opened this issue Sep 26, 2024 · 5 comments
Closed

Reference leaks on current main #124586

Eclips4 opened this issue Sep 26, 2024 · 5 comments
Labels
3.14 new features, bugs and security fixes extension-modules C modules in the Modules dir topic-C-API type-bug An unexpected behavior, bug, or error

Comments

@Eclips4
Copy link
Member

Eclips4 commented Sep 26, 2024

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

@Eclips4 Eclips4 added the type-bug An unexpected behavior, bug, or error label Sep 26, 2024
@Eclips4
Copy link
Member Author

Eclips4 commented Sep 26, 2024

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

@ZeroIntensity ZeroIntensity added extension-modules C modules in the Modules dir 3.14 new features, bugs and security fixes topic-C-API labels Sep 26, 2024
@ZeroIntensity
Copy link
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.

@vstinner
Copy link
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)

@vstinner
Copy link
Member

I wrote PR gh-124601 to fix the leak.

@vstinner
Copy link
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
Labels
3.14 new features, bugs and security fixes extension-modules C modules in the Modules dir topic-C-API type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

3 participants