-
-
Notifications
You must be signed in to change notification settings - Fork 33.9k
Closed
Labels
topic-free-threadingtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Description
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
Metadata
Metadata
Assignees
Labels
topic-free-threadingtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Projects
Status
Done