[00/16] Fixing various issues found while working on PR30309

Message ID 87il8mglc1.fsf@redhat.com
Headers
Series Fixing various issues found while working on PR30309 |

Message

Dodji Seketeli Sept. 7, 2023, 1:32 p.m. UTC
  Hello,

While working on the problem report 30309 at
https://sourceware.org/bugzilla/show_bug.cgi?id=30309, I found several
smaller related issues that could be addressed independently from the
reported problem itself.  As the initial issue still needs more care,
I think it's worthwhile to merge the following patches into the main
line the source code.

Please note that the original issue is being handled in the branch
"canonicalize-types-in-order" at
https://sourceware.org/git/?p=libabigail.git;a=shortlog;h=refs/heads/users/dodji/canonicalize-types-in-order.

I am thus merging the patches that follows this message into the main
branches, from the "canonicalize-types-in-order" branch.

Dodji Seketeli (16):
  reader: fix indentation
  tools-utils: Fix indentation
  dwarf-reader,ir: Make logging a property of the middle end
  dwarf-reader: Fix some logging
  abipkgdiff: Initialize libxml2 to use it in a multi-thread context
  tools-utils: Avoid endless loop
  {dwarf,elf}reader: Don't consider no symbol table as an error
  abipkgdiff: Avoid comparing binaries that are outside of the package
  ir: Add missing ABG_RETURN in the comparison engine
  ir: Add fn types to type lookup maps
  ir: Fix forgetting canonicalizing some function types
  ir: Avoid forgetting potential seemingly duplicated member functions
  ir: Really avoid canonicalizing decl-only classes
  ir: Use non qualified typedef name for type canonicalization
  ir: Fix qualification as non-confirmed propagated canonical types
  dwarf-reader: Do not re-use typedefs in a scope

 include/abg-fwd.h                             |     8 +-
 include/abg-ir.h                              |    11 +-
 include/abg-tools-utils.h                     |     1 +
 src/abg-dwarf-reader.cc                       |    38 +-
 src/abg-elf-reader.cc                         |     8 +-
 src/abg-ir-priv.h                             |    21 +-
 src/abg-ir.cc                                 |   328 +-
 src/abg-reader.cc                             |    76 +-
 src/abg-tools-utils.cc                        |    40 +-
 tests/data/Makefile.am                        |     2 +
 .../test-abidiff/test-PR18791-report0.txt     |    13 -
 tests/data/test-annotate/libtest23.so.abi     |   453 +-
 .../test-annotate/libtest24-drop-fns-2.so.abi |   598 +-
 .../test-annotate/libtest24-drop-fns.so.abi   |   598 +-
 .../data/test-annotate/test15-pr18892.so.abi  | 14179 ++--
 .../data/test-annotate/test17-pr19027.so.abi  |  2162 +-
 ...st18-pr19037-libvtkRenderingLIC-6.1.so.abi |  8862 +--
 ...19-pr19023-libtcmalloc_and_profiler.so.abi |  7403 +-
 ...st20-pr19025-libvtkParallelCore-6.1.so.abi | 10938 +--
 .../data/test-annotate/test21-pr19092.so.abi  |    88 +-
 .../test42-PR21296-clanggcc-report0.txt       |    14 +-
 .../test31-pr18535-libstdc++-report-0.txt     |    31 +-
 .../test31-pr18535-libstdc++-report-1.txt     |    31 +-
 .../data/test-diff-filter/test41-report-0.txt |    30 +-
 .../symlink-dir-test1-report1.txt             |     0
 .../symlink-dir-test1-report1.txt             |     0
 .../PR22015-libboost_iostreams.so.abi         |  2291 +-
 .../test-read-dwarf/PR22122-libftdc.so.abi    | 14659 ++--
 .../data/test-read-dwarf/PR25007-sdhci.ko.abi |  8778 +--
 tests/data/test-read-dwarf/libtest23.so.abi   |   447 +-
 .../libtest24-drop-fns-2.so.abi               |   586 +-
 .../test-read-dwarf/libtest24-drop-fns.so.abi |   586 +-
 .../test-read-dwarf/test-libaaudio.so.abi     |     8 +-
 .../test-read-dwarf/test-libandroid.so.abi    | 12052 ++--
 tests/data/test-read-dwarf/test0.hash.abi     |     4 +-
 tests/data/test-read-dwarf/test1.hash.abi     |    10 +-
 .../test-read-dwarf/test10-pr18818-gcc.so.abi |  3136 +-
 .../test-read-dwarf/test11-pr18828.so.abi     | 11668 ++--
 .../test-read-dwarf/test12-pr18844.so.abi     | 24630 ++++---
 .../test-read-dwarf/test15-pr18892.so.abi     | 13995 ++--
 .../test-read-dwarf/test16-pr18904.so.abi     | 16831 ++---
 .../test-read-dwarf/test17-pr19027.so.abi     |  2132 +-
 ...st18-pr19037-libvtkRenderingLIC-6.1.so.abi |  8768 +--
 ...19-pr19023-libtcmalloc_and_profiler.so.abi |  7127 +-
 ...st20-pr19025-libvtkParallelCore-6.1.so.abi | 10671 +--
 .../test-read-dwarf/test21-pr19092.so.abi     |    82 +-
 .../test22-pr19097-libstdc++.so.6.0.17.so.abi | 57411 ++++++++--------
 .../test9-pr18818-clang.so.abi                |  3545 +-
 .../test28-without-std-fns-ref.xml            |   350 +-
 .../test28-without-std-vars-ref.xml           |   348 +-
 tests/test-diff-pkg.cc                        |    32 +-
 tools/abipkgdiff.cc                           |    27 +-
 52 files changed, 121298 insertions(+), 124809 deletions(-)
 create mode 100644 tests/data/test-diff-pkg-ctf/symlink-dir-test1-report1.txt
 create mode 100644 tests/data/test-diff-pkg/symlink-dir-test1-report1.txt
  

Comments

Dodji Seketeli Sept. 7, 2023, 2:07 p.m. UTC | #1
Hello,

is_non_canonicalized_type uses is_declaration_only_class_or_union_type
to detect decl-only classes, but it doesn't differentiate between
decl-only classes that are associated to a class definition and those
that are not.

We want to avoid canonicalizing decl-only classes that are not
associated to any class definition.

This patch fixes the invocation of
is_declaration_only_class_or_union_type to express the above
assertion.

This fix uncovered another self-comparison issue that was being
expressed when running the command below:

    $ abidw --abidiff tests/data/test-types-stability/PR27086-libstdc++.so.6.0.26

That one was due to an error in method_decl::set_linkage_name which
was making classes contain the wrong overloads of methods.  The patch
fixes that error too.

	* include/abg-fwd.h (is_pointer_to_decl_only_class_or_union_type)
	(is_reference_to_decl_only_class_or_union_type)
	(is_typedef_to_decl_only_class_or_union_type): Remove declarations.
	(is_typedef_ptr_or_ref_to_decl_only_class_or_union_type): Declare
	new function.
	* src/abg-ir.cc (is_pointer_to_decl_only_class_or_union_type)
	(is_reference_to_decl_only_class_or_union_type)
	(is_typedef_to_decl_only_class_or_union_type): Remove definitions.
	(is_typedef_ptr_or_ref_to_decl_only_class_or_union_type): Define
	new function.
	(is_non_canonicalized_type): Change the invocation of
	is_declaration_only_class_or_union_type to make it look through
	decl-only types.  Use
	is_typedef_ptr_or_ref_to_decl_only_class_or_union_type in lieu of
	is_{pointer,reference,typedef}_to_decl_only_class_or_union_type
	that got removed.
	(method_decl::set_linkage_name): Remove the mapping between the
	method and the old linkage name, only if the old name is different
	from the new name.  Duh.
	* tests/data/test-annotate/libtest23.so.abi: Adjust.
	* tests/data/test-annotate/test15-pr18892.so.abi: Likewise.
	* tests/data/test-annotate/test17-pr19027.so.abi: Likewise.
	* tests/data/test-annotate/test18-pr19037-libvtkRenderingLIC-6.1.so.abi:
	Likewise.
	* tests/data/test-annotate/test19-pr19023-libtcmalloc_and_profiler.so.abi:
	Likewise.
	* tests/data/test-annotate/test20-pr19025-libvtkParallelCore-6.1.so.abi:
	Likewise.
	* tests/data/test-annotate/test21-pr19092.so.abi: Likewise.
	* tests/data/test-read-dwarf/PR22015-libboost_iostreams.so.abi:
	Likewise.
	* tests/data/test-read-dwarf/PR22122-libftdc.so.abi: Likewise.
	* tests/data/test-read-dwarf/PR25007-sdhci.ko.abi: Likewise.
	* tests/data/test-read-dwarf/libtest23.so.abi: Likewise.
	* tests/data/test-read-dwarf/test-libaaudio.so.abi: Likewise.
	* tests/data/test-read-dwarf/test-libandroid.so.abi: Likewise.
	* tests/data/test-read-dwarf/test10-pr18818-gcc.so.abi: Likewise.
	* tests/data/test-read-dwarf/test11-pr18828.so.abi: Likewise.
	* tests/data/test-read-dwarf/test12-pr18844.so.abi: Likewise.
	* tests/data/test-read-dwarf/test15-pr18892.so.abi: Likewise.
	* tests/data/test-read-dwarf/test16-pr18904.so.abi: Likewise.
	* tests/data/test-read-dwarf/test17-pr19027.so.abi: Likewise.
	* tests/data/test-read-dwarf/test18-pr19037-libvtkRenderingLIC-6.1.so.abi:
	Likewise.
	* tests/data/test-read-dwarf/test19-pr19023-libtcmalloc_and_profiler.so.abi:
	Likewise.
	* tests/data/test-read-dwarf/test20-pr19025-libvtkParallelCore-6.1.so.abi:
	Likewise.
	* tests/data/test-read-dwarf/test21-pr19092.so.abi: Likewise.
	* tests/data/test-read-dwarf/test22-pr19097-libstdc++.so.6.0.17.so.abi:
	Likewise.
	* tests/data/test-read-dwarf/test9-pr18818-clang.so.abi: Likewise.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Applied to master.
---
 include/abg-fwd.h                             |     8 +-
 src/abg-ir.cc                                 |    68 +-
 tests/data/test-annotate/libtest23.so.abi     |   363 +-
 .../data/test-annotate/test15-pr18892.so.abi  |    55 -
 .../data/test-annotate/test17-pr19027.so.abi  |   934 +-
 ...st18-pr19037-libvtkRenderingLIC-6.1.so.abi |  5832 +--
 ...19-pr19023-libtcmalloc_and_profiler.so.abi |  7483 ++--
 ...st20-pr19025-libvtkParallelCore-6.1.so.abi |  7566 ++--
 .../data/test-annotate/test21-pr19092.so.abi  |    88 +-
 .../PR22015-libboost_iostreams.so.abi         |   682 +-
 .../test-read-dwarf/PR22122-libftdc.so.abi    | 13186 +++----
 .../data/test-read-dwarf/PR25007-sdhci.ko.abi |  8778 ++---
 tests/data/test-read-dwarf/libtest23.so.abi   |   358 +-
 .../test-read-dwarf/test-libaaudio.so.abi     |     4 +-
 .../test-read-dwarf/test-libandroid.so.abi    |  1544 +-
 .../test-read-dwarf/test10-pr18818-gcc.so.abi |  1391 +-
 .../test-read-dwarf/test11-pr18828.so.abi     | 11160 +++---
 .../test-read-dwarf/test12-pr18844.so.abi     | 23647 ++++++------
 .../test-read-dwarf/test15-pr18892.so.abi     |    42 -
 .../test-read-dwarf/test16-pr18904.so.abi     | 15271 ++++----
 .../test-read-dwarf/test17-pr19027.so.abi     |   894 +-
 ...st18-pr19037-libvtkRenderingLIC-6.1.so.abi |  5738 +--
 ...19-pr19023-libtcmalloc_and_profiler.so.abi |  7239 ++--
 ...st20-pr19025-libvtkParallelCore-6.1.so.abi |  7277 ++--
 .../test-read-dwarf/test21-pr19092.so.abi     |    82 +-
 .../test22-pr19097-libstdc++.so.6.0.17.so.abi | 31278 ++++++++--------
 .../test9-pr18818-clang.so.abi                |  2691 +-
 27 files changed, 76386 insertions(+), 77273 deletions(-)

The file is too large for the mailing list so I am attaching it gzipped.
  
Dodji Seketeli Sept. 7, 2023, 2:08 p.m. UTC | #2
Hello,

While looking into fixing self-comparison errors for the gcc-gnat
package[1], I stumbled upon the fact that a typedef that is defined in
the global scope is different from a typedef defined in a scope, even
if they both point to the same underlying type.  This is a spurious
difference that feeds a spurious explosion of the number of canonical
types, for no reason.  It can lead to spurious self-comparison errors
down the road.  Sadly, fixing this issue is not enough to fix the
self-comparison error in [1].

[1]: The command is:

    $ fedabipkgdiff --self-compare  -a --from fc37 gcc-gnat

	* include/abg-ir.h (reference_type_def::{pointed_to_type_,
	is_lvalue_}): Remove these data members.
	(reference_type_def::priv_): Add a unique data member.
	(typedef_decl::get_qualified_name): Add new virtual member
	functions.
	* src/abg-ir.cc (get_decl_name_for_comparison): If the decl we are
	comparing is a typedef, only consider its non-qualified name.
	(get_type_name): For internal purposes, the type name of a typedef
	is its non-qualified name.
	(pointer_type_def::get_qualified_name): For internal purposes, if
	the pointed-to name is a typedef, use the non-qualified name of
	the typedef.
	(reference_type_def::priv): Define new data type.
	(reference_type_def::reference_type_def): Initialize the new
	reference_type_def::priv_ data member and adjust to the move of
	the reference_type_def::pointed_to_type_ data member to
	reference_type_def::priv::pointed_to_type_.
	(reference_type_def::{s,g}et_pointed_to_type): Adjust.
	(reference_type_def::is_lvalue): Likewise.
	(reference_type_def::get_qualified_name): Support caching
	qualified names for internal and non-internal purposes.
	(typedef_decl::get_pretty_representation): For internal purposes,
	use non-qualified typedef name.
	(typedef_decl::get_qualified_name): Define the two overloads for
	this virtual member function.
	(function_decl::get_pretty_representation): Use the
	'qualified_name' parameter.  Also, rather than systematically
	using the qualified name of the return type, use get_type_name
	instead that knows when to use qualified names and when not to.
	(qualified_name_setter::do_update):
	* tests/data/test-abidiff/test-PR18791-report0.txt: Adjust.
	* tests/data/test-annotate/libtest23.so.abi: Likewise.
	* tests/data/test-annotate/libtest24-drop-fns-2.so.abi: Likewise.
	* tests/data/test-annotate/libtest24-drop-fns.so.abi: Likewise.
	* tests/data/test-annotate/test15-pr18892.so.abi: Likewise.
	* tests/data/test-annotate/test17-pr19027.so.abi: Likewise.
	* tests/data/test-annotate/test18-pr19037-libvtkRenderingLIC-6.1.so.abi:
	Likewise.
	* tests/data/test-annotate/test19-pr19023-libtcmalloc_and_profiler.so.abi:
	Likewise.
	* tests/data/test-annotate/test20-pr19025-libvtkParallelCore-6.1.so.abi:
	Likewise.
	* tests/data/test-diff-dwarf/test42-PR21296-clanggcc-report0.txt:
	Likewise.
	* tests/data/test-read-dwarf/PR22015-libboost_iostreams.so.abi:
	Likewise.
	* tests/data/test-read-dwarf/PR22122-libftdc.so.abi: Likewise.
	* tests/data/test-read-dwarf/libtest23.so.abi: Likewise.
	* tests/data/test-read-dwarf/libtest24-drop-fns-2.so.abi:
	Likewise.
	* tests/data/test-read-dwarf/libtest24-drop-fns.so.abi: Likewise.
	* tests/data/test-read-dwarf/test-libaaudio.so.abi: Likewise.
	* tests/data/test-read-dwarf/test-libandroid.so.abi: Likewise.
	* tests/data/test-read-dwarf/test0.hash.abi: Likewise.
	* tests/data/test-read-dwarf/test1.hash.abi: Likewise.
	* tests/data/test-read-dwarf/test10-pr18818-gcc.so.abi: Likewise.
	* tests/data/test-read-dwarf/test11-pr18828.so.abi: Likewise.
	* tests/data/test-read-dwarf/test12-pr18844.so.abi: Likewise.
	* tests/data/test-read-dwarf/test15-pr18892.so.abi: Likewise.
	* tests/data/test-read-dwarf/test16-pr18904.so.abi: Likewise.
	* tests/data/test-read-dwarf/test17-pr19027.so.abi: Likewise.
	* tests/data/test-read-dwarf/test18-pr19037-libvtkRenderingLIC-6.1.so.abi:
	Likewise.
	* tests/data/test-read-dwarf/test19-pr19023-libtcmalloc_and_profiler.so.abi:
	Likewise.
	* tests/data/test-read-dwarf/test20-pr19025-libvtkParallelCore-6.1.so.abi:
	Likewise.
	* tests/data/test-read-dwarf/test22-pr19097-libstdc++.so.6.0.17.so.abi:
	Likewise.
	* tests/data/test-read-dwarf/test9-pr18818-clang.so.abi: Likewise.
	* tests/data/test-read-write/test28-without-std-fns-ref.xml:
	Likewise.
	* tests/data/test-read-write/test28-without-std-vars-ref.xml:
	Likewise.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Applied to master.
---
 include/abg-ir.h                              |    11 +-
 src/abg-ir.cc                                 |   182 +-
 .../test-abidiff/test-PR18791-report0.txt     |    13 -
 tests/data/test-annotate/libtest23.so.abi     |   132 +-
 .../test-annotate/libtest24-drop-fns-2.so.abi |   598 +-
 .../test-annotate/libtest24-drop-fns.so.abi   |   598 +-
 .../data/test-annotate/test15-pr18892.so.abi  | 14124 +++---
 .../data/test-annotate/test17-pr19027.so.abi  |  1238 +-
 ...st18-pr19037-libvtkRenderingLIC-6.1.so.abi |  4426 +-
 ...19-pr19023-libtcmalloc_and_profiler.so.abi |  3824 +-
 ...st20-pr19025-libvtkParallelCore-6.1.so.abi |  6670 ++-
 .../test42-PR21296-clanggcc-report0.txt       |    14 +-
 .../PR22015-libboost_iostreams.so.abi         |  2305 +-
 .../test-read-dwarf/PR22122-libftdc.so.abi    | 14743 +++---
 tests/data/test-read-dwarf/libtest23.so.abi   |   131 +-
 .../libtest24-drop-fns-2.so.abi               |   586 +-
 .../test-read-dwarf/libtest24-drop-fns.so.abi |   586 +-
 .../test-read-dwarf/test-libaaudio.so.abi     |     4 +-
 .../test-read-dwarf/test-libandroid.so.abi    | 10274 ++--
 tests/data/test-read-dwarf/test0.hash.abi     |     4 +-
 tests/data/test-read-dwarf/test1.hash.abi     |    10 +-
 .../test-read-dwarf/test10-pr18818-gcc.so.abi |  2902 +-
 .../test-read-dwarf/test11-pr18828.so.abi     |  9501 ++--
 .../test-read-dwarf/test12-pr18844.so.abi     | 23913 +++++----
 .../test-read-dwarf/test15-pr18892.so.abi     | 13953 +++---
 .../test-read-dwarf/test16-pr18904.so.abi     | 13513 +++--
 .../test-read-dwarf/test17-pr19027.so.abi     |  1248 +-
 ...st18-pr19037-libvtkRenderingLIC-6.1.so.abi |  4403 +-
 ...19-pr19023-libtcmalloc_and_profiler.so.abi |  3750 +-
 ...st20-pr19025-libvtkParallelCore-6.1.so.abi |  6651 ++-
 .../test22-pr19097-libstdc++.so.6.0.17.so.abi | 41099 ++++++++--------
 .../test9-pr18818-clang.so.abi                |  2628 +-
 .../test28-without-std-fns-ref.xml            |   350 +-
 .../test28-without-std-vars-ref.xml           |   348 +-
 34 files changed, 89416 insertions(+), 95316 deletions(-)

The file is too large for the mailing list so I am attaching it gzipped.
  
Dodji Seketeli Sept. 7, 2023, 2:10 p.m. UTC | #3
Hello,

Sometimes, two typedefs of the same name can appear at the same scope
but point to different types, in DWARF.  Unbelievable but true.  In
those case, we do not want to re-use the typedef, obviously, as we can
possibly misrepresent the type graph in that case.

This fixes one self-comparison issue for the x86_64 sub-package of the
gcc-gnat package that is tested by doing:

    $ fedabipkgdiff --self-compare  -a --from fc37 gcc-gnat

	* src/abg-dwarf-reader.cc (build_ir_node_from_die): Do not re-use
	a typedef from a given scope.
	* src/abg-reader.cc (build_typedef_type): Do not re-use typedefs
	with the same ID.
	* tests/data/test-annotate/test18-pr19037-libvtkRenderingLIC-6.1.so.abi:
	Adjust.
	* tests/data/test-annotate/test20-pr19025-libvtkParallelCore-6.1.so.abi:
	Likewise.
	* tests/data/test-diff-filter/test31-pr18535-libstdc++-report-0.txt:
	Likewise.
	* tests/data/test-diff-filter/test31-pr18535-libstdc++-report-1.txt:
	Likewise.
	* tests/data/test-diff-filter/test41-report-0.txt: Likewise.
	* tests/data/test-read-dwarf/PR22122-libftdc.so.abi: Likewise.
	* tests/data/test-read-dwarf/test-libandroid.so.abi: Likewise.
	* tests/data/test-read-dwarf/test10-pr18818-gcc.so.abi: Likewise.
	* tests/data/test-read-dwarf/test11-pr18828.so.abi: Likewise.
	* tests/data/test-read-dwarf/test12-pr18844.so.abi: Likewise.
	* tests/data/test-read-dwarf/test16-pr18904.so.abi: Likewise.
	* tests/data/test-read-dwarf/test18-pr19037-libvtkRenderingLIC-6.1.so.abi:
	Likewise.
	* tests/data/test-read-dwarf/test20-pr19025-libvtkParallelCore-6.1.so.abi:
	Likewise.
	* tests/data/test-read-dwarf/test22-pr19097-libstdc++.so.6.0.17.so.abi:
	Likewise.
	* tests/data/test-read-dwarf/test9-pr18818-clang.so.abi: Likewise.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Applied to master.
---
 src/abg-dwarf-reader.cc                       |    10 +-
 src/abg-reader.cc                             |     7 -
 ...st18-pr19037-libvtkRenderingLIC-6.1.so.abi |  8830 ++--
 ...st20-pr19025-libvtkParallelCore-6.1.so.abi | 10776 ++---
 .../test31-pr18535-libstdc++-report-0.txt     |    31 +-
 .../test31-pr18535-libstdc++-report-1.txt     |    31 +-
 .../data/test-diff-filter/test41-report-0.txt |    30 +-
 .../test-read-dwarf/PR22122-libftdc.so.abi    |  6150 +--
 .../test-read-dwarf/test-libandroid.so.abi    |  4862 ++-
 .../test-read-dwarf/test10-pr18818-gcc.so.abi |  2933 +-
 .../test-read-dwarf/test11-pr18828.so.abi     |  1239 +-
 .../test-read-dwarf/test12-pr18844.so.abi     |  3798 +-
 .../test-read-dwarf/test16-pr18904.so.abi     | 12355 +++---
 ...st18-pr19037-libvtkRenderingLIC-6.1.so.abi |  8789 ++--
 ...st20-pr19025-libvtkParallelCore-6.1.so.abi | 10651 ++---
 .../test22-pr19097-libstdc++.so.6.0.17.so.abi | 35982 ++++++++--------
 .../test9-pr18818-clang.so.abi                |   736 +-
 17 files changed, 55160 insertions(+), 52050 deletions(-)

The file is too large for the mailing list so I am attaching it gzipped.