Memory leak when reading co_code attribute of deepfrozen code objects · Issue #93728 · python/cpython (original) (raw)
Reproducer:
import os os.path.join.code.co_code
Relevant Valgrind Report:
==21416== HEAP SUMMARY: ==21416== in use at exit: 397 bytes in 1 blocks ==21416== total heap usage: 19,728 allocs, 19,727 frees, 2,629,532 bytes allocated ==21416== ==21416== 397 bytes in 1 blocks are still reachable in loss record 1 of 1 ==21416== at 0x483B7F3: malloc (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_memcheck-amd64-linux.so) ==21416== by 0x2FA6DD: _PyMem_RawMalloc (obmalloc.c:101) ==21416== by 0x2FC5CD: PyObject_Malloc (obmalloc.c:713) ==21416== by 0x287BDC: _PyBytes_FromSize (bytesobject.c:103) ==21416== by 0x2881A6: PyBytes_FromStringAndSize (bytesobject.c:136) ==21416== by 0x29F609: _PyCode_GetCode (codeobject.c:1374) ==21416== by 0x29F69B: code_getcode (codeobject.c:1728) ==21416== by 0x2A31B2: getset_get (descrobject.c:202) ==21416== by 0x2F86E6: _PyObject_GenericGetAttrWithDict (object.c:1269) ==21416== by 0x2F8F14: PyObject_GenericGetAttr (object.c:1357) ==21416== by 0x2F9864: PyObject_GetAttr (object.c:912) ==21416== by 0x3B5B16: _PyEval_EvalFrameDefault (ceval.c:3472) ==21416== ==21416== LEAK SUMMARY: ==21416== definitely lost: 0 bytes in 0 blocks ==21416== indirectly lost: 0 bytes in 0 blocks ==21416== possibly lost: 0 bytes in 0 blocks ==21416== still reachable: 397 bytes in 1 blocks ==21416== suppressed: 0 bytes in 0 blocks ==21416==
This is a 3.12 only regression caused by #93382.