mirror of
git://sourceware.org/git/libabigail.git
synced 2024-12-19 16:30:04 +00:00
49db3f838c
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> |
||
---|---|---|
.. | ||
abg-comp-filter.h | ||
abg-comparison.h | ||
abg-config.h | ||
abg-corpus.h | ||
abg-diff-utils.h | ||
abg-dwarf-reader.h | ||
abg-fwd.h | ||
abg-hash.h | ||
abg-ini.h | ||
abg-interned-str.h | ||
abg-ir.h | ||
abg-libxml-utils.h | ||
abg-libzip-utils.h | ||
abg-reader.h | ||
abg-sptr-utils.h | ||
abg-suppression.h | ||
abg-tools-utils.h | ||
abg-traverse.h | ||
abg-version.h.in | ||
abg-viz-common.h | ||
abg-viz-dot.h | ||
abg-viz-svg.h | ||
abg-workers.h | ||
abg-writer.h | ||
Makefile.am |