Pacman

Historical bug tracker for the Pacman package manager.

The pacman bug tracker has moved to gitlab:
https://gitlab.archlinux.org/pacman/pacman/-/issues

This tracker remains open for interaction with historical bugs during the transition period. Any new bugs reports will be closed without further action.
Tasklist

FS#18058 - several memory leaks in pacman

Attached to Project: Pacman
Opened by Jonathan Conder (PirateJonno) - Friday, 29 January 2010, 00:16 GMT
Last edited by Andrew Gregory (andrewgregory) - Sunday, 31 January 2016, 12:19 GMT
Task Type Bug Report
Category General
Status Closed
Assigned To Andrew Gregory (andrewgregory)
Architecture All
Severity Low
Priority Normal
Reported Version git
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 0
Private No

Details

Hi, I'm writing a wrapper library for libalpm for use in a GUI frontend. Anyway, while doing this I noticed that various calls to alpm_trans_prepare return a list of items that need to be free'd.

For example, in pacman/remove.c, line 86 (current git), a PM_ERR_UNSATISFIED_DEPS gives a list of pmdepmissing_t which is free'd using FREELIST. However, in libalpm/remove.c, line 181, this same list is free'd using alpm_list_free_inner with _alpm_depmiss_free followed by alpm_list_free. This appears to be the correct way of doing it, and since pacman doesn't then we are left with a dangling references to the members of each pmdepmissing_t in the list.

I suggest that firstly _alpm_depmiss_free should be exported from alpm so that pacman can use it, and secondly that pacman should be changed to make use of it in this case. Additionally, there are other cases where similar leaks occur. The ones I have been able to identify are in pacman/upgrade.c and pacman/sync.c where PM_ERR_UNSATISFIED_DEPS, PM_ERR_CONFLICTING_DEPS and PM_ERR_FILE_CONFLICTS are handled.

Admittedly, this is a fairly minor issue in pacman itself, as once an error occurs it is likely that the pacman process will end, but for frontends, such as mine, that run in the background it could be much worse. I hope this is not too difficult to fix, and I may be able to write a patch myself if the developers agree with my proposed course of action.
This task depends upon

Closed by  Andrew Gregory (andrewgregory)
Sunday, 31 January 2016, 12:19 GMT
Reason for closing:  Implemented
Additional comments about closing:  alpm now exports the necessary freeing functions.
Comment by Xavier (shining) - Friday, 29 January 2010, 00:40 GMT
Well you already figured out everything. Even the reason why this is still unfixed after 2 years (when we switched to dynamic allocation).

We mentioned/discussed several times this problem (not recently though). But I don't remember exactly the outcome.
Nagy and I were thinking to simply export the freeing functions like you suggested. But Aaron and Dan (and maybe also Nagy and me) found this a bit ugly, maybe the frontend shouldn't need to know about this complexity, and we need to find a way to abstract it / make things nicer.
I don't think there is one public discussion where we discussed all together, just random bits here and there, some private or on IRC. So that's just what I remember of it.

Maybe we just want to go with this suggestion from Aaron, which will be of course much more work than just exporting freeing functions to frontend :
http://mailman.archlinux.org/pipermail/pacman-dev/2008-February/005673.html
Comment by Jonathan Conder (PirateJonno) - Friday, 29 January 2010, 01:03 GMT
Ok, well sorry for the duplicate then, all I did was search the bugtracker. For now my wrapper will just free things individually, which is a bit ugly but it works ok (I think). I guess I'll join the pacman-dev mailing list and wait to see what you guys come up with.
Comment by Allan McRae (Allan) - Sunday, 31 January 2016, 04:22 GMT
@Andrew: can this be closed now? It appears everything described here is fixed.

Loading...