libabigail/tools
Dodji Seketeli dbae53ec30 Bug 31646: Fix type suppression tactics for webkit2gtk3
By default, using abidw --abidiff on the binary
/usr/lib64/libwebkit2gtk-4.0.so.37 on the ppc64le platform takes more
than 50GB of RAM and ooms on my system.  That is why a number of
suppression specifications have been put in place in the
default.abignore file that is installed by default on the system.
With that suppression specification however, abidw --abidiff hits an
assert and crashes.

That is because the suppression specification rule below is too eager
and thus removes parameters from some function's signature, in the
final internal representation:

    [suppress_type]
      soname_regexp = libwebkit2?gtk-.*\\.so.*
      name_regexp = (^std::.*|WebCore::.*|WebKit::.*)
      drop = true

An example of function signature that got changed (in the IR) because
of this suppression specification is:

This function signature:

    WebKitAuthenticationScheme
    webkit_authentication_request_get_scheme(WebKitAuthenticationRequest*)

becomes (after applying the suppression specification above):

    void
    webkit_authentication_request_get_scheme()

Woops.  That is not good.

To address that problem, this patch changes that suppression
specification to make libabigail transform those types into opaque
types.  An opaque struct, class or enum is essentially a
declaration-only type of the same kind and name.

So the suppression specification above becomes:

    [suppress_type]
      # Drop all standard c++ types on the floor like before.
      soname_regexp = libwebkit2?gtk-.*\\.so.*
      name_regexp = ^std::.*
      drop = true

    [suppress_type]
      # Transform all C++ types in the WebCore and WebKit namespaces into
      # opaque types.  These are essentially internal types of libwebkit2
      # anyway.  This greatly reduces the size of the in-memory working set.
      label = libabigail::OPAQUE_TYPE_LABEL
      soname_regexp = libwebkit2?gtk-.*\\.so.*
      name_regexp = (WebCore::.*|WebKit::.*)
      drop = true

Notice the introduction of the new special label
"libabigail::OPAQUE_TYPE_LABEL".  This new special label is what makes
the suppression engine of libabigail transform a type (that matches
that suppression specification) into an opaque type, rather than
dropping it on the floor.

The patch then adapts the code of the suppression engine to detect
this special label for the purpose of transforming types into opaque
types.  The patch normalizes the use of the term "opaque type" instead
of "private type" that was used previously in the code.

The patch fixes a bug in the code of get_opaque_version_of_type that
prevents this function from working on types with no location
information.

While working on this, I have noticed that the abipkgdiff has a bug
that was making it ignore suppression specifications provided via the
--suppression option.  The patch fixes that.

I have noticed that abipkgdiff --self-check completely ignores all
suppression specifications provided either via --suppression or
indirectly via devel packages.  The patch fixes that.

Last but not least, fedabipkgdiff --self-compare completely ignores
suppression specifications too!  The patch fixes that as well.

With all those fixes, the system now takes around 7GB of RAM and ~ 30
minutes to complete the analysis of the webkit2gtk3 package, using a
non-optimized libabigail build.

The command I use is:

    $ time tools/fedabipkgdiff --debug --self-compare --abipkgdiff build/tools/abipkgdiff --suppressions default.abignore -a --from fc39 webkit2gtk3

    [...]

    [DEBUG] Result from run_abipkgdiff: 0, in: 0:29:00.088735
    [DEBUG] Result from self_compare_rpms_from_distro: 0, in: 0:29:20.721748

    real	29m20,846s
    user	29m4,561s
    sys	        2m41,611s
    $

The culprit package was webkit2gtk3-2.40.1-1.fc36.ppc64le.rpm.

To reproduce the issue on that package, I do:

    $ time ~/git/libabigail/rhbz2273891/build/tools/abipkgdiff --self-check --suppr ~/git/libabigail/rhbz2273891/default.abignore --d1 webkit2gtk3-debuginfo-2.40.1-1.fc36.ppc64le.rpm --devel1 webkit2gtk3-devel-2.40.1-1.fc36.ppc64le.rpm webkit2gtk3-2.40.1-1.fc36.ppc64le.rpm

    ==== SELF CHECK SUCCEEDED for 'libwebkit2gtk-4.0.so.37.63.2' ====
    ==== SELF CHECK SUCCEEDED for 'WebKitWebDriver' ====
    ==== SELF CHECK SUCCEEDED for 'WebKitNetworkProcess' ====
    ==== SELF CHECK SUCCEEDED for 'WebKitWebProcess' ====

    real	8m25,895s
    user	8m46,433s
    sys	        0m15,683s
    $

	* default.abignore: Split the libwebkit2gtk suppression
	specification for types whose names match the regexp
	^std::.*|WebCore::.*|WebKit::.* into two.  One that drops type
	with names being ^std::.* and another one that turns type being
	WebCore::.*|WebKit::.* into opaque types.
	* doc/manuals/libabigail-concepts.rst: Add documentation for the
	new special label libabigail::OPAQUE_TYPE_LABEL that transforms
	types matching a [suppress_type] into opaque types.
	* include/abg-suppression.h (is_opaque_type_suppr_spec): Renamed
	is_private_type_suppr_spec into this.
	(get_opaque_types_suppr_spec_label): Renamed
	get_private_types_suppr_spec_label.
	* src/abg-comparison.cc (diff::is_suppressed): Adjust.
	* src/abg-dwarf-reader.cc (type_is_suppressed): Adjust. Change the
	name of the type_is_private parameter into type_is_opaque.
	(get_opaque_version_of_type): Do not return early if the type has
	no associated location.  What was I thinking.
	(build_ir_node_from_die): For enums, struct and classes adjust
	call to type_is_suppressed.
	* src/abg-suppression.cc (type_suppression::suppresses_diff):
	Adjust to using is_opaque_type_suppr_spec and
	get_opaque_version_of_type in lieu of is_private_type_suppr_spec
	and get_private_types_suppr_spec_label.
	(get_opaque_types_suppr_spec_label): Rename
	get_private_types_suppr_spec_label into this.  Also, rename the
	name of the special label that specifies opaque types from
	"Artificial private types suppression specification" to
	"libabigail::OPAQUE_TYPE_LABEL".
	(is_opaque_type_suppr_spec): Rename is_private_type_suppr_spec
	into this.
	(is_type_suppressed): Rename the "type_is_private" parameter into
	"type_is_opaque".
	* src/abg-tools-utils.cc (handle_file_entry): Adjust to using
	get_opaque_types_suppr_spec_label rather than
	get_private_types_suppr_spec_label.
	* tools/abipkgdiff.cc (compare): Use the supprs variable where all
	the suppression specifications got accumulated, not just the
	priv_types_supprs1.
	(compare_to_self): Add a suppression specifications variable for
	private types.  Add those private types specs to the user-provided
	ones.
	* tools/fedabipkgdiff (abipkgdiff): In the self comparison mode,
	take into account devel packages and suppression specifications.
	Pass those to the abipkgdiff tool's invocation.
	* tests/data/test-diff-suppr/PR31646/test-PR31646-result-[1-3].txt:
	New reference test output files.
	* tests/data/test-diff-suppr/PR31646/test-PR31646-v{0,1}.cc:
	Source code of binary inputs below.
	* tests/data/test-diff-suppr/PR31646/test-PR31646-v{0,1}.o: Binary
	input files.
	* tests/data/test-diff-suppr/PR31646/test-PR31646.2.abignore:
	Suppression specification file.
	* tests/data/test-diff-suppr/PR31646/test-PR31646.abignore:
	Likewise.
	* tests/data/Makefile.am: Add the new test material above to
	source distribution.
	* tests/test-diff-suppr.cc (in_out_specs): Add the new test input
	to this harness.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2024-04-16 17:46:19 +02:00
..
.gitignore
abicompat.cc abicompat: Fix exit code in weak mode 2024-03-15 20:22:17 +01:00
abidb abidb: drop the TODO items from the python script 2024-03-22 14:17:29 -04:00
abidiff.cc abidiff: Fix indentation of help string 2024-03-29 16:52:00 +01:00
abidw.cc Emit & read undefined interfaces to & from ABIXML 2024-03-14 16:27:14 +01:00
abilint.cc abilint: Alphabetically sort programs options 2023-12-01 15:43:41 +01:00
abipkgdiff.cc Bug 31646: Fix type suppression tactics for webkit2gtk3 2024-04-16 17:46:19 +02:00
abisym.cc Update copyright year for 2023 2023-01-01 18:19:30 +01:00
binilint.cc Update copyright year for 2023 2023-01-01 18:19:30 +01:00
fedabipkgdiff Bug 31646: Fix type suppression tactics for webkit2gtk3 2024-04-16 17:46:19 +02:00
kmidiff.cc comparison: Add a mode to not apply filters on interface sub-graphs 2023-03-02 18:31:43 +01:00
Makefile.am abidb: Introduce a tool to manage the ABI of a Linux distribution 2024-03-22 17:18:17 +01:00