On 04/27/2016 05:52 PM, Nathan Scott wrote:
Changes committed to git://git.pcp.io/pcp.git master
..
commit 89686243fe54572db0a5b71952e026e8784a7506
Author: Nathan Scott <nathans@xxxxxxxxxx>
Date: Wed Apr 27 17:49:42 2016 +1000
libpcp: fix brown paper bag pmcd-context-sharing bug
Rewrote test qa/246 (has had some problems since adding global
derived metrics support) to use valgrind instead of doing leak
detection "by-hand" using malloc pointer range checks.
This immediately showed a memory leak between pmNewContext and
pmDestroyContext, via the c_pmcd pointer when a few contexts are
in play. Turns out to be due to a failure to perform reference
counting correctly, which in turn was due to a missing "break"
statement in the loop seeking a PMCD context sharing match. It
is nasty not only because of the incorrect refcnts and leaks, but
because it basically disables sharing for the case of different
host contexts (only when the final context in the context array
happens to be a match would sharing actually happen correctly).
I reviewed the changes to context.c, looks good - taking an extra ref
like that for (potentially) all contexts could be a pretty hairy leak
and I'm surprised we've not noticed it before.
I think you can also break out of the inner loop once we've detected
that the ports are not the same, as in the attached patch.
Regards
libpcp_newcontext_extra.patch
Description: Text Data
|