Do a better job cleaning up memory #239

Merged
ariadne merged 17 commits from dcbaker/pkgconf:free-memory into master 2022-08-04 23:36:16 +00:00

PR moved from github.

This is a lot of cleanup of memory handling in pkgconf and libpkgconf. With this series all of the unittests are green with the address sanitizer enabled, and the usage in Meson++ and Muon reports no leaks. So, success?

PR moved from [github](https://github.com/pkgconf/pkgconf/pull/254). This is a lot of cleanup of memory handling in pkgconf and libpkgconf. With this series all of the unittests are green with the address sanitizer enabled, and the usage in Meson++ and Muon reports no leaks. So, success?
dcbaker added 19 commits 2022-08-02 17:20:42 +00:00
7cd86508a3 dependency: add refcount trace to dependency
This works like the pkg tracing, but for dependencies
2f5a2c56d4 dependency: add a reference to dependency when adding to graph
This makes internal uses more annoying, but fixes a potential bug in
libpkgconf where there are two pointers (one returned and on in the
graph), but only one refcount.
7025581da8 cache: use pkgconf_dependency_free instead of just setting match = NULL
This also means that we don't need to call unref on the pkgs, they've
already been freed by the dependency_free code
ee06ab42d2 main: cleanup when validating
This clears up a few memory leaks in tests
7b3346206e dependency: unref dependency parent if it's set
libpkgconf never sets this internally, but it is in the API and someone
could set it (or libpkgconf could in the future), so let's clean up
after ourselves.
36acd2e409 queue: don't collect static dependencies unless that's what we're looking for
Currently the required_private field gets walked twice, once when the
main required field is walked, and a second time when it is walked
itself. This results in the requires_private field leaking memory.
d23dc2c183 cache: don't try to remove packages from the cache if it's NULL
Otherwise we end up reallocing the cache_table, when we shouldn't
c7b0f86815 cache: set the cache_table to NULL if empty
Instead of realloc'ing to a size of 0, set the cache_table to NULL when
removing the last element from it.
ci/woodpecker/pr/woodpecker Pipeline was successful Details
0c72b7cd41
ci: run meson test with the address sanitizer enabled
Set the ASAN_OPTION so that the exitcode is not 1, this avoids asan
returning the exitcode that the tests already expect from a normal
pkgconf error
dcbaker changed title from Do a better job cleaning up memory to WIP: Do a better job cleaning up memory 2022-08-02 18:50:19 +00:00

I keep finding more issues with memory leaking (or me fixing it incorrectly), so I'm going to mark this as WIP for the moment.

I keep finding more issues with memory leaking (or me fixing it incorrectly), so I'm going to mark this as WIP for the moment.
dcbaker added 5 commits 2022-08-02 19:00:14 +00:00
62608dfe02 queue: don't flatten nothing
If after removing duplicates there are no deps to flatten, return early.
dbc8d248c7 cache: use pkgconf_cache_remove to empty the cache
Which ensures that memory handling is done correctly.
ci/woodpecker/pr/woodpecker Pipeline was successful Details
116e367525
main: unref another pkg

Yeah, sadly libpkgconf API came after pkgconf the tool was written so there's a lot to clean up probably :)

Yeah, sadly libpkgconf API came after pkgconf the tool was written so there's a lot to clean up probably :)
dcbaker force-pushed free-memory from 116e367525 to 90232914cd 2022-08-04 22:25:06 +00:00 Compare
dcbaker changed title from WIP: Do a better job cleaning up memory to Do a better job cleaning up memory 2022-08-04 22:51:45 +00:00
dcbaker force-pushed free-memory from 90232914cd to 179a0560a6 2022-08-04 22:52:15 +00:00 Compare
ariadne approved these changes 2022-08-04 23:35:59 +00:00
ariadne merged commit b310728111 into master 2022-08-04 23:36:16 +00:00
dcbaker deleted branch free-memory 2022-08-05 17:13:42 +00:00
Sign in to join this conversation.
No reviewers
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: ariadne/pkgconf#239
There is no content yet.