libabigail/include
Dodji Seketeli 49db3f838c Plug leak of diffs of member variables of class type
On certain work loads, cycles in the tree of diffs of member variables
can appear.  This because:

  1/ each diff tree nodes holds a reference on each of its children
  nodes
  2/ each var_diff tree node holds a reference on the diff tree node
  representing its type changes.

There can thus be reference cycles in involving diff the tree --> child
node relationship and the var_diff tree --> type diff tree
relationship.

This patch fixes the issue be make sure that a diff tree node does not
hold a reference on its children nodes.  That is, rather than having a
vector of shared pointers to its children diff nodes, it has a vector
of naked pointers to those.  The patch goes further by making sure
that a var_diff node does not hold a reference to its type diff node
either.  It holds a weak pointer to the type diff node, rather than a
shared pointer.

The patch should be followed by a patch make sure that all kinds of
diff nodes follow this pattern; that is, if a diff node needs to carry
a sub-type diff node, it should do so by either using a naked pointer
to the sub-type diff node, or a weak pointer.

For now, the patch fixes the leaks reported by running all the tests
of the suite under Valgrind.

	* include/abg-comparison.h (diff_wptr, unordered_diff_sptr_set): New typedefs.
	(struct diff_sptr_hasher): Define new type.
	(diff_context::keep_diff_alive): Declare new member function.
	(diff::children_nodes): Return a vector of diff*, rather than a
	vector of diff_sptr.
	* src/abg-comparison.cc (diff_context::priv::live_diffs_): New
	data member.
	(diff_context::keep_diff_alive): Define new data member.
	(diff::priv::children_): Make this be a vector of diff*, rather
	than a vector of diff_sptr.
	(diff_less_than_functor::operator()): Add a new overload for
	diff*.  Make the existing overload of diff_sptr use the new one.
	(diff::children_nodes): Adjust;
	(diff::append_child_node): Make sure the child node is kept
	alive.  Only add the naked pointer to the child node to the vector
	of children.
	(diff::traverse): Adjust.
	(var_diff::priv::type_diff_): Make this be a weak pointer, rather
	than a shared pointer.
	(var_diff::type_diff): The var_diff::priv::type_diff_ data member
	is now a weak pointer, so make this accessor convert it to a
	shared pointer.
	(corpus_diff::priv::children_): Turn this into a vector of diff*,
	rather than a vector of diff_sptr.
	(corpus_diff::children_nodes): Adjust.
	(corpus_diff::append_child_node): Make sure the child node is kept
	alive.  Only add the naked pointer to the child node to the vector
	of children.
	(category_propagation_visitor::visit_end): Adjust.
	(suppression_categorization_visitor::visit_end): Adjust.
	(redundancy_marking_visitor::{visit_begin, visit_end}): Adjust.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2016-05-22 23:20:13 +02:00
..
abg-comp-filter.h Bug 17649 Avoid endless looping on diff graph with cycles 2015-02-21 15:16:48 +01:00
abg-comparison.h Plug leak of diffs of member variables of class type 2016-05-22 23:20:13 +02:00
abg-config.h Add --version option to several libabigail tools 2015-11-16 12:54:10 +01:00
abg-corpus.h Implement string interning for Libabigail 2016-02-24 15:13:20 +01:00
abg-diff-utils.h Constify some diff-utils functor operators 2015-09-21 10:46:06 +02:00
abg-dwarf-reader.h Add some apidoc to dwarf_reader 2016-05-06 18:18:07 +02:00
abg-fwd.h Split suppression engine off of abg-comparison.{cc,h} 2016-05-08 12:29:57 +02:00
abg-hash.h Update copyright years 2015-01-07 17:52:10 +01:00
abg-ini.h Support source_location_not_in and source_location_not_regexp suppressions 2015-09-16 20:54:40 +02:00
abg-interned-str.h Implement string interning for Libabigail 2016-02-24 15:13:20 +01:00
abg-ir.h Remove circular ref from class_decl::priv::definition_of_declaration 2016-05-22 23:20:13 +02:00
abg-libxml-utils.h Update copyright years 2015-01-07 17:52:10 +01:00
abg-libzip-utils.h Update copyright years 2015-01-07 17:52:10 +01:00
abg-reader.h Introduce the concept of environment 2015-09-07 23:35:29 +02:00
abg-sptr-utils.h Plug leak of regex_t in suppression engine 2016-05-22 23:20:13 +02:00
abg-suppression.h Implement a [suppress_file] suppression directive 2016-05-08 12:39:26 +02:00
abg-tools-utils.h Bug 19867 - abipkgdiff skips symbolic links 2016-03-25 13:52:02 +01:00
abg-traverse.h Canonicalize types either early or late after TU reading 2015-02-18 21:32:37 +01:00
abg-version.h.in Add --version option to several libabigail tools 2015-11-16 12:54:10 +01:00
abg-viz-common.h Update copyright years 2015-01-07 17:52:10 +01:00
abg-viz-dot.h Update copyright years 2015-01-07 17:52:10 +01:00
abg-viz-svg.h Update copyright years 2015-01-07 17:52:10 +01:00
abg-workers.h Make API documentation of thread pools visible 2016-04-27 23:58:50 +02:00
abg-writer.h Update copyright years 2015-01-07 17:52:10 +01:00
Makefile.am Split suppression engine off of abg-comparison.{cc,h} 2016-05-08 12:29:57 +02:00