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 fixes (in library, not extension code) #233

Merged
merged 2 commits into from Nov 6, 2020

Conversation

dralley
Copy link
Contributor

@dralley dralley commented Nov 2, 2020

No description provided.

@dralley
Copy link
Contributor Author

dralley commented Nov 2, 2020

Related issues that are not fixed in this PR: #232

(wasn't able to figure them out)

@kontura kontura self-assigned this Nov 3, 2020
@@ -929,12 +929,16 @@ cr_close(CR_FILE *cr_file, GError **err)
}

if (cr_file->stat) {
if (cr_file->stat->hdr_checksum) {
free(cr_file->stat->hdr_checksum);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is not the right place to free the hdr_checksum, it should be freed together with the rest of the stat struct, ideally by cr_contentstat_free. Its generally not bound to the cr_file, its managed on its own. In fact when running with zchunk (createrepo_c --zck .) this call is causing a double free.

I have looked around where the hdr_checksum could be leaking and I believe that the problem is here: https://github.com/rpm-software-management/createrepo_c/blob/master/src/repomd.c#L199
It should be using the cr_contentstat_free function.

Otherwise looks good to me. 🙂

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed!

@dralley dralley force-pushed the core-mem-leak-fixes branch 2 times, most recently from 46a1ccf to 8ae8a76 Compare November 5, 2020 14:23
@dralley
Copy link
Contributor Author

dralley commented Nov 5, 2020

@kontura (re-do) Fixed now. Thank you!

============================================================================================================ test session starts =============================================================================================================
platform linux -- Python 3.6.8, pytest-6.1.2, py-1.9.0, pluggy-0.13.1 -- /usr/local/lib/pulp/bin/python
cachedir: .pytest_cache
rootdir: /home/vagrant/devel/community/createrepo_c
collected 3 items                                                                                                                                                                                                                            

tests/python/tests/test_compression_wrapper.py::TestCaseCompressionWrapper::test_compression_suffix PASSED                                                                                                                             [ 33%]
tests/python/tests/test_compression_wrapper.py::TestCaseCompressionWrapper::test_compression_type PASSED                                                                                                                               [ 66%]
tests/python/tests/test_compression_wrapper.py::TestCaseCompressionWrapper::test_detect_compression PASSED                                                                                                                             [100%]

============================================================================================================= 3 passed in 4.34s ==============================================================================================================
==9367== 
==9367== HEAP SUMMARY:
==9367==     in use at exit: 7,707,942 bytes in 61,837 blocks
==9367==   total heap usage: 895,713 allocs, 833,876 frees, 177,775,340 bytes allocated
==9367== 
==9367== LEAK SUMMARY:
==9367==    definitely lost: 0 bytes in 0 blocks
==9367==    indirectly lost: 0 bytes in 0 blocks
==9367==      possibly lost: 2,455,124 bytes in 17,977 blocks
==9367==    still reachable: 5,252,818 bytes in 43,860 blocks
==9367==                       of which reachable via heuristic:
==9367==                         newarray           : 1,536 bytes in 16 blocks
==9367==         suppressed: 0 bytes in 0 blocks
==9367== Reachable blocks (those to which a pointer was found) are not shown.
==9367== To see them, rerun with: --leak-check=full --show-leak-kinds=all

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

Successfully merging this pull request may close these issues.

None yet

2 participants