Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Leak with untracked tuples and deferred ref counts #144054

Copy link
Copy link
@nascheme

Description

@nascheme
Issue body actions

Bug report

Bug description:

With the merge of gh-142843, the test case test__interpchannels.ChannelTests.test_send_recv_different_interpreters_and_threads is now failing with reference leaks. A minimal reproducer is below. If the sys.flags object has deferred reference counting enabled in the sub-interpreter, it leaks.

import gc
import sys
import _interpreters


def test_leak():
    id1 = _interpreters.create()

    def f():
        # enable deferred ref counts for sys.flags, causes a leak, even with
        # an explicit gc.collect() call
        _interpreters.run_string(
            id1,
            'import sys, _testcapi; _testcapi.pyobject_enable_deferred_refcount(sys.flags)\n',
        )

    f()
    _interpreters.destroy(id1)


def main():
    for i in range(4):
        test_leak()
    gc.collect()
    old_refs = sys.gettotalrefcount()
    for i in range(10):
        test_leak()
        gc.collect()
        refs = sys.gettotalrefcount()
        print(f'refs {refs} diff {refs-old_refs}')
        old_refs = refs


if __name__ == '__main__':
    main()

CPython versions tested on:

CPython main branch

Operating systems tested on:

Linux

Linked PRs

Reactions are currently unavailable

Metadata

Metadata

Assignees

No one assigned
    No fields configured for issues without a type.

    Projects

    Status
    Done
    Show more project fields

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.