GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — _testcapi._tuple_resize() leaks item references on allocation failure · Issue #159514 · python/cpython Closed Labels 3.14bugs and security fixesbugs and security fixes3.15bugs and security fixesbugs and security fixes3.16new features, bugs and security fixesnew features, bugs and security fixesinterpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error DescriptionBug report
The old allocation remains valid after the failed resize, so its remaining elements must be decref'ed before it is freed. For a shrinking resize, the removed tail entries have already been cleared; the retained entries still need cleanup if resizing fails. ReproducerRun this with a build that includes import gc import struct import sys import weakref import _testcapi class Item: pass item = Item() original = (item,) ref = weakref.ref(item) try: # The helper creates a private copy of the tuple before resizing it. # Header overhead makes this exceed the GC allocator's size limit. _testcapi._tuple_resize(original, sys.maxsize // struct.calcsize("P")) except MemoryError: pass else: raise AssertionError("expected MemoryError") del original, item gc.collect() print("element released:", ref() is None) assert ref() is None Expected: CPython versions tested onReproduced with the unmodified runtime from CPython Source inspection also confirms the same cleanup path in release tags v3.14.8 and v3.15.0. Those versions were not executed for this report. Operating systems tested onmacOS 27.0.1, Apple Silicon. Related reportsI searched for an existing report. #155053 concerns a caller dereferencing NULL after resize failure; its proposed fix does not address these leaked element references. The bug was manually spotted and investigated, but AI tools assisted with the investigation, reproducer, and proposed fix. The reproducer and regression test were executed locally before submission. Linked PRsActivity
MetadataMetadataAssigneesLabels3.14bugs and security fixesbugs and security fixes3.15bugs and security fixesbugs and security fixes3.16new features, bugs and security fixesnew features, bugs and security fixesinterpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error ProjectsMilestoneRelationshipsDevelopmentIssue 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. |