The Git repository of the Libabigail Project
Go to file
Dodji Seketeli 88c6e080b6 Bug 29857 - Better detect comparison cycles in type graph
When comparing two aggregates A and B, it can happen that has a
sub-type of A is itself; similarly for B.  This is a cycle in the type
graph, obviously.  Also, A and B are said to be recursive types.

Structally comparing two recursive types (i.e, comparing them
member-wise) can lead to an endless loop.

So, during type canonicalization, comparison cycles must be detected
to avoid those endless loop.

This is currently done in the equals() overload for class_decl,
union_decl, class_or_union as well as function_type.  Those are the
aggregate types that are subject to these cycles when comparing
recursive types.

Currently, detecting comparison cycles is based on
ir::environment::priv::mark_as_being_compared(),
ir::environment::priv::priv::unmark_as_being_compared(),
ir::environment::priv::comparison_started() considering the pair of
pointer to aggregate types being currently compared.  If that pair
appears more than once in the stack of aggregates being compared a
cycle is detected.

But then, watching the stack of aggregates during the analsysis of the
/usr/lib64/libgs.so.9 binary from the ghostscript-9.52-5.oe1.x86_64
package from https://sourceware.org/bugzilla/show_bug.cgi?id=29857 it
appears that the stack of aggregates (structs) was growing endlessly,
when comparing the "struct gs_memory_s" type, and the same struct
gs_memory_s aggregate was appearing several times on the right-hand
side of the comparison stack.  Clearly, this is a comparison cycle.

The gs_memory struct is appearing several times as the right hand side
operand in the stack of operands being compared, even though no pair
of operands being compared was present more than once.

This prompted me to use another heuristic to detect comparison cycles:
If the same aggregate type is appearing several times on either the
left or right hand side of the comparison stack then a cycle is
detected.

This fixes the cycle detection failure above and comparing the two
binaries completes in ~ 43 minutes on my laptop, with a non optimized
libabigail build.

	* src/abg-ir-priv.h (class_set_type, fn_set_type): Define new typedefs.
	* src/abg-ir.cc (environment::priv::{left_classes_being_compared_,
	right_classes_being_compared_, left_fn_types_being_compared_,
	right_fn_types_being_compared_}): Define new data members.
	(environment::priv::{classes_being_compared_,
	fn_types_being_compared_}): Erase data members.
	(environment::priv::{dump_classes_being_compared,
	dump_fn_types_being_compared}): Erase member functions.
	(environment::priv::{mark_as_being_compared,
	unmark_as_being_compared, comparison_started}): Change this to use
	the left-hand-side and right-hand-side comparison stack introduced
	above.
	(dump_classes_being_compared, dump_fn_types_being_compared):
	Remove functions.

Signed-off-by: Dodji Seketeli <dodji@seketeli.org>
2022-12-19 17:52:10 +01:00
.github Adding missing newline to build-container workflow 2022-05-17 09:46:16 +02:00
autoconf-archive Replace individual license references with SPDX Identifiers 2020-12-02 11:44:13 +01:00
bash-completion Re-license the project to Apache v2 With LLVM Exception 2020-12-02 11:49:13 +01:00
doc dwarf-reader: Leverage ODR & DWZ 2022-11-30 17:17:15 +01:00
docker Add github actions to support workflows 2022-05-17 00:13:40 +02:00
include Bug 29857 - dwarf-reader: Resolve decl-only unions 2022-12-19 17:52:10 +01:00
m4 Delete ltsugar.m4 and pkg.m4 files from m4/ 2015-01-06 09:54:45 +01:00
relicensing-scripts Bug 27512 - Remove broken zip-archive support 2021-03-19 10:52:57 +01:00
scripts Re-license the project to Apache v2 With LLVM Exception 2020-12-02 11:49:13 +01:00
src Bug 29857 - Better detect comparison cycles in type graph 2022-12-19 17:52:10 +01:00
tests Bug 29857 - dwarf-reader: Resolve decl-only unions 2022-12-19 17:52:10 +01:00
tools dwarf-reader: Leverage ODR & DWZ 2022-11-30 17:17:15 +01:00
.clang-format Tweak clang-format configuration 2021-10-19 12:59:18 +02:00
.gitignore .gitignore: Add libabigail-?.* *.orig files 2019-05-22 14:34:23 +02:00
.mailmap Add '.mailmap' 2021-12-17 20:12:20 +01:00
abigail.m4 Re-license the project to Apache v2 With LLVM Exception 2020-12-02 11:49:13 +01:00
ABIXML-FORMAT-VERSIONS Bug 28450 - Fix cloned member function handling in DWARF 2021-11-12 18:31:28 +01:00
AUTHORS Initial AUTHORS and README 2013-02-28 13:25:20 +01:00
ChangeLog Update ChangeLog for 2.1 release. 2022-09-25 06:11:19 +02:00
COMMIT-LOG-GUIDELINES Update the COMMIT-LOG-GUIDELINES file 2016-05-22 23:20:12 +02:00
COMPILING Improve some grammar 2022-02-25 11:24:20 +01:00
configure.ac Use xz as the default tarball compression format 2022-11-18 13:06:09 +01:00
CONTRIBUTING Improve some grammar 2022-02-25 11:24:20 +01:00
default.abignore Re-license the project to Apache v2 With LLVM Exception 2020-12-02 11:49:13 +01:00
gen-changelog.py Replace individual license references with SPDX Identifiers 2020-12-02 11:44:13 +01:00
install-sh Replace individual license references with SPDX Identifiers 2020-12-02 11:44:13 +01:00
libabigail.pc.in Make libxml2 a private dependency wrt pkconfig 2013-08-22 17:41:29 +02:00
license-change-2020.txt Add a license-change-2020.txt file 2020-12-02 11:50:22 +01:00
LICENSE.txt Add the LICENSE.txt file 2020-12-02 11:49:33 +01:00
ltmain.sh Replace individual license references with SPDX Identifiers 2020-12-02 11:44:13 +01:00
Makefile.am Use xz as the default tarball compression format 2022-11-18 13:06:09 +01:00
NEWS Update NEWS file for 2.1 2022-09-25 07:45:51 +02:00
README Improve some grammar 2022-02-25 11:24:20 +01:00
README-DOCKER.md Add github actions to support workflows 2022-05-17 00:13:40 +02:00
release-text-template.txt Update the release text template after 1.0 2017-11-22 15:55:43 +01:00
update-copyright.sh Update year in copyright notice 2022-06-21 12:58:57 +02:00
VISIBILITY Improve some grammar 2022-02-25 11:24:20 +01:00

This is the Application Binary Interface Generic Analysis and
Instrumentation Library.

It aims at constructing, manipulating, serializing and de-serializing
ABI-relevant artifacts.

The set of artifacts that we are intersted is made of quantities like
types, variable, functions and declarations of a given library or
program.  For a given library or program this set of quantities is
called an ABI corpus.

This library aims at (among other things) providing a way to compare
two ABI Corpora (apparently the plural of corpus is copora, heh,
that's cool), provide detailed information about their differences,
and help build tools to infer interesting conclusions about these
differences.

You are welcome to contribute to this project after reading the files
CONTRIBUTING and COMMIT-LOG-GUIDELINES files in the source tree.

Communicating with the maintainers of this project -- including
sending patches to be include to the source code -- happens via email
at libabigail@sourceware.org.