bpo-46476: Fix memory leak in code objects generated by deepfreeze #30853
bpo-46476: Fix memory leak in code objects generated by deepfreeze #30853vstinner merged 25 commits intopython:mainfrom
Conversation
|
Valgrind log after this PR: ==7131== HEAP SUMMARY:
==7131== in use at exit: 0 bytes in 0 blocks
==7131== total heap usage: 18,468 allocs, 18,468 frees, 2,631,556 bytes allocated
==7131==
==7131== All heap blocks were freed -- no leaks are possible
==7131==
==7131== Use --track-origins=yes to see where uninitialised values come from
==7131== For lists of detected and suppressed errors, rerun with: -s
==7131== ERROR SUMMARY: 81 errors from 16 contexts (suppressed: 0 from 0)
|
|
A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated. Once you have made the requested changes, please leave a comment on this pull request containing the phrase And if you don't make the requested changes, you will be put in the comfy chair! |
|
The new code is causing a segfault. |
|
I have made the requested changes; please review again |
|
Thanks for making the requested changes! @tiran: please review the changes made to this pull request. |
|
Before reviewing, I checked that the PR fix my issue: https://bugs.python.org/issue46476#msg411315 Yes, it does :-) Python no longer leaks any memory block at exit! |
My concern is more that this C code is far from the code responsible to handle PyCodeObject, codeobject.c. I would prefer to make it close to
Even if it's somehow "hidden", there is already _PyObject_IMMORTAL_INIT() in Include/internal/pycore_object.h. |
Ok, I moved it to the codeobject.c added a comment as it is for deepfreeze.
That is a partial implementation because if an object is immortal then |
|
A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated. Once you have made the requested changes, please leave a comment on this pull request containing the phrase |
|
Thanks @kumaraditya303 for the PR and the updates, the final change is even better! I merged your PR. Ah right, I hesitated to complain about the braces / PEP 7, @tiran did it ;-) |
gvanrossum
left a comment
There was a problem hiding this comment.
Sorry I missed the review, but I have a question.
https://bugs.python.org/issue46476