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
bpo-46476: Fix memory leak in code objects generated by deepfreeze #30853
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 ;-) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry I missed the review, but I have a question.
https://bugs.python.org/issue46476