Repository navigation
py_loader: release PyObject_Str results in error print and error value - #921
Open
bhuvan-somisetty wants to merge 1 commit into
Open
bhuvan-somisetty wants to merge 1 commit into
bhuvan-somisetty wants to merge 1 commit into
Conversation
py_loader_impl_error_print never released type_str_obj and value_str_obj, and py_loader_impl_error_value_from_exception never released value_str_obj. Both come from PyObject_Str so they are new references, and they leaked every time a python error was handled. exception_create_const copies the strings, so it is safe to release them after creating the exception. Found with valgrind.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
First python leak from going through the valgrind CI with @viferga.
PyObject_Strreturns a new reference, butpy_loader_impl_error_printnever releasedtype_str_objandvalue_str_obj, andpy_loader_impl_error_value_from_exceptionnever releasedvalue_str_obj. So two strings leaked every time a python error got printed, and one more every time it was turned into a throwable.exception_create_constcopies the strings, so it's safe to release them after.Tested with
./docker-compose.sh test-memcheck(python only) and thenMEMCHECK_TEST=python make memcheckinside the image. The definitely lost records coming from these two functions go from 7 to 0,metacall-python-fail-testgoes from 629 to 0 bytes definitely lost andmetacall-python-relative-path-testfrom 219 to 0, with no new invalid reads or frees. All 12 python tests still pass without valgrind. The rest of the python errors are mostly "possibly lost" from the interpreter itself, that needs the instrumented python so I left it for later.