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

Memory leak when reading co_code attribute of deepfrozen code objects #93728

Closed
kumaraditya303 opened this issue Jun 11, 2022 · 2 comments · Fixed by #93729
Closed

Memory leak when reading co_code attribute of deepfrozen code objects #93728

kumaraditya303 opened this issue Jun 11, 2022 · 2 comments · Fixed by #93729
Assignees
Labels

Comments

@kumaraditya303
Copy link
Contributor

@kumaraditya303 kumaraditya303 commented Jun 11, 2022

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.

@kumaraditya303
Copy link
Contributor Author

@kumaraditya303 kumaraditya303 commented Jun 11, 2022

@Fidget-Spinner Can you cherry-pick my fix #93729 to your backport PR #93493?

@Fidget-Spinner
Copy link
Member

@Fidget-Spinner Fidget-Spinner commented Jun 11, 2022

Thanks for catching this, and sure thing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants