pkgconf_pkg_find() doesn't add package to cache #133

Closed
opened 2017-09-11 22:45:33 +00:00 by karen-arutyunov · 1 comment
karen-arutyunov commented 2017-09-11 22:45:33 +00:00 (Migrated from github.com)

If pkgconf_pkg_find() creates a package via the pkgconf_pkg_new_from_file() it doesn't call pkgconf_cache_add() for it. The fact it will keep reloading the package again and again on the consecutive pkgconf_pkg_find() calls is only a half of the issue. The real problem is that pkgconf_pkg_free() being called for this package tries to remove it from the cache calling pkgconf_cache_remove(). This operation being called for a package that is not in the cache just breaks the cache (decrement it lenghts by 1 and resets tail/head to NULL), leaking all cached packages (see pkgconf_cache_remove() and pkgconf_node_delete() implementations).

If pkgconf_pkg_find() creates a package via the pkgconf_pkg_new_from_file() it doesn't call pkgconf_cache_add() for it. The fact it will keep reloading the package again and again on the consecutive pkgconf_pkg_find() calls is only a half of the issue. The real problem is that pkgconf_pkg_free() being called for this package tries to remove it from the cache calling pkgconf_cache_remove(). This operation being called for a package that is not in the cache just breaks the cache (decrement it lenghts by 1 and resets tail/head to NULL), leaking all cached packages (see pkgconf_cache_remove() and pkgconf_node_delete() implementations).

in the case where pkgconf_pkg_new_from_file() is invoked, it's intentional to bypass the cache as it's a direct path instead of a dependency name.

i refactored the cache handling for the larger memory leak issue, thanks for spotting it.

in the case where pkgconf_pkg_new_from_file() is invoked, it's intentional to bypass the cache as it's a direct path instead of a dependency name. i refactored the cache handling for the larger memory leak issue, thanks for spotting it.
Sign in to join this conversation.
No Milestone
No project
No Assignees
1 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#133
There is no content yet.