Bug 24188 - Assertion failed while analysing a Fortran binary
authorDodji Seketeli <dodji@redhat.com>
Fri, 8 Feb 2019 08:48:40 +0000 (09:48 +0100)
committerDodji Seketeli <dodji@redhat.com>
Fri, 8 Feb 2019 09:43:59 +0000 (10:43 +0100)
While analysing a Fortran binary the DWARF reader performs DIE
de-duplication.  During that process, the compare_dies function
stumbles accross the a DIE of the DW_TAG_string_type kind.  And it
doesn't know how to compare those DIEs.  And this leads to an abort of
the abipkgdiff program, in particular.

DW_TAG_string_type DIEs do have a DW_AT_string_length attribute which
value is a location expression that does not resolve to a constant
value.  In general, we cannot evaluate those expressions in a static
context like in Libabigail because we lack things like register values
which are dynamic in nature.

So, I decided for now to consider that two DW_TAG_string_type seen at
different DWARF offsets are considered to be different for now.  This
pessimises DIEs de-duplication for types that contain
DW_TAG_string_type as their subtypes, but at least this is a basic
support for DW_TAG_string_type.

Tested with the RPMs on which abipkgdiff was failing.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
* src/abg-dwarf-reader.cc (compare_as_type_dies): Handle
DW_TAG_string_type DIEs here.
(compare_dies): Handle DW_TAG_string_type DIEs by using
compare_as_type_dies.
* tests/data/test-diff-pkg/netcdf-fortran-debuginfo-4.4.4-10.fc29.x86_64.rpm:
New test RPM.
* tests/data/test-diff-pkg/netcdf-fortran-debuginfo-4.4.4-11.fc30.x86_64.rpm:
Likewise.
* tests/data/test-diff-pkg/netcdf-fortran-mpich-4.4.4-10.fc29.x86_64-4.4.4-11.fc30.x86_64-report-0.txt:
New expected test reference output.
* tests/data/test-diff-pkg/netcdf-fortran-mpich-4.4.4-10.fc29.x86_64.rpm:
New test RPM.
* tests/data/test-diff-pkg/netcdf-fortran-mpich-4.4.4-11.fc30.x86_64.rpm:
Likewise.
* tests/data/test-diff-pkg/netcdf-fortran-mpich-debuginfo-4.4.4-10.fc29.x86_64.rpm:
Likewise.
* tests/data/test-diff-pkg/netcdf-fortran-mpich-debuginfo-4.4.4-11.fc30.x86_64.rpm:
Likewise.
* tests/data/test-diff-pkg/netcdf-fortran-mpich-devel-4.4.4-10.fc29.x86_64.rpm:
Likewise.
* tests/data/test-diff-pkg/netcdf-fortran-mpich-devel-4.4.4-11.fc30.x86_64.rpm:
Likewise.
* tests/data/Makefile.am: Add the new test input material above to
source distribution.
* tests/test-diff-pkg.cc (in_out_spec): Add the new test RPMs
above to the set of RPMs to use as test input.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
12 files changed:
src/abg-dwarf-reader.cc
tests/data/Makefile.am
tests/data/test-diff-pkg/netcdf-fortran-debuginfo-4.4.4-10.fc29.x86_64.rpm [new file with mode: 0644]
tests/data/test-diff-pkg/netcdf-fortran-debuginfo-4.4.4-11.fc30.x86_64.rpm [new file with mode: 0644]
tests/data/test-diff-pkg/netcdf-fortran-mpich-4.4.4-10.fc29.x86_64-4.4.4-11.fc30.x86_64-report-0.txt [new file with mode: 0644]
tests/data/test-diff-pkg/netcdf-fortran-mpich-4.4.4-10.fc29.x86_64.rpm [new file with mode: 0644]
tests/data/test-diff-pkg/netcdf-fortran-mpich-4.4.4-11.fc30.x86_64.rpm [new file with mode: 0644]
tests/data/test-diff-pkg/netcdf-fortran-mpich-debuginfo-4.4.4-10.fc29.x86_64.rpm [new file with mode: 0644]
tests/data/test-diff-pkg/netcdf-fortran-mpich-debuginfo-4.4.4-11.fc30.x86_64.rpm [new file with mode: 0644]
tests/data/test-diff-pkg/netcdf-fortran-mpich-devel-4.4.4-10.fc29.x86_64.rpm [new file with mode: 0644]
tests/data/test-diff-pkg/netcdf-fortran-mpich-devel-4.4.4-11.fc30.x86_64.rpm [new file with mode: 0644]
tests/test-diff-pkg.cc

index ab286f2a474e17adf96e57f037ed5da26f252a60..5dd1d4f0ca6e633d8c15bbf3a3b978f1b6ada698 100644 (file)
@@ -11406,6 +11406,16 @@ compare_as_type_dies(Dwarf_Die *l, Dwarf_Die *r)
   ABG_ASSERT(die_is_type(l));
   ABG_ASSERT(die_is_type(r));
 
+  if (dwarf_tag(l) == DW_TAG_string_type
+      && dwarf_tag(r) == DW_TAG_string_type
+      && dwarf_dieoffset(l) != dwarf_dieoffset(r))
+    // For now, we cannot compare DW_TAG_string_type because of its
+    // string_length attribute that is a location descriptor that is
+    // not necessarily a constant.  So it's super hard to evaluate it
+    // in a libabigail context.  So for now, we just say that all
+    // DW_TAG_string_type DIEs are different, by default.
+    return false;
+
   uint64_t l_size = 0, r_size = 0;
   die_size_in_bits(l, l_size);
   die_size_in_bits(r, r_size);
@@ -11475,6 +11485,7 @@ compare_dies(const read_context& ctxt, Dwarf_Die *l, Dwarf_Die *r,
   switch (l_tag)
     {
     case DW_TAG_base_type:
+    case DW_TAG_string_type:
       if (!compare_as_type_dies(l, r)
          || !compare_as_decl_dies(l, r))
        result = false;
@@ -11821,7 +11832,6 @@ compare_dies(const read_context& ctxt, Dwarf_Die *l, Dwarf_Die *r,
     case DW_TAG_compile_unit:
     case DW_TAG_namespace:
     case DW_TAG_module:
-    case DW_TAG_string_type:
     case DW_TAG_constant:
     case DW_TAG_partial_unit:
     case DW_TAG_imported_unit:
index ac42d78a84206b6e5160c3c45e7b57f3a0fe8de6..27058563485e080f20eed03a55234757340ed130 100644 (file)
@@ -1452,6 +1452,15 @@ test-diff-pkg/GtkAda-gl-2.24.2-29.fc29.x86_64.rpm \
 test-diff-pkg/GtkAda-gl-2.24.2-30.fc30.x86_64.rpm \
 test-diff-pkg/GtkAda-gl-debuginfo-2.24.2-29.fc29.x86_64.rpm \
 test-diff-pkg/GtkAda-gl-debuginfo-2.24.2-30.fc30.x86_64.rpm \
+test-diff-pkg/netcdf-fortran-debuginfo-4.4.4-10.fc29.x86_64.rpm \
+test-diff-pkg/netcdf-fortran-debuginfo-4.4.4-11.fc30.x86_64.rpm \
+test-diff-pkg/netcdf-fortran-mpich-4.4.4-10.fc29.x86_64.rpm \
+test-diff-pkg/netcdf-fortran-mpich-4.4.4-11.fc30.x86_64.rpm \
+test-diff-pkg/netcdf-fortran-mpich-debuginfo-4.4.4-10.fc29.x86_64.rpm \
+test-diff-pkg/netcdf-fortran-mpich-debuginfo-4.4.4-11.fc30.x86_64.rpm \
+test-diff-pkg/netcdf-fortran-mpich-devel-4.4.4-10.fc29.x86_64.rpm \
+test-diff-pkg/netcdf-fortran-mpich-devel-4.4.4-11.fc30.x86_64.rpm \
+test-diff-pkg/netcdf-fortran-mpich-4.4.4-10.fc29.x86_64-4.4.4-11.fc30.x86_64-report-0.txt \
 \
 test-fedabipkgdiff/dbus-glib-0.104-3.fc23.x86_64.rpm \
 test-fedabipkgdiff/dbus-glib-debuginfo-0.104-3.fc23.x86_64.rpm \
diff --git a/tests/data/test-diff-pkg/netcdf-fortran-debuginfo-4.4.4-10.fc29.x86_64.rpm b/tests/data/test-diff-pkg/netcdf-fortran-debuginfo-4.4.4-10.fc29.x86_64.rpm
new file mode 100644 (file)
index 0000000..79e329e
Binary files /dev/null and b/tests/data/test-diff-pkg/netcdf-fortran-debuginfo-4.4.4-10.fc29.x86_64.rpm differ
diff --git a/tests/data/test-diff-pkg/netcdf-fortran-debuginfo-4.4.4-11.fc30.x86_64.rpm b/tests/data/test-diff-pkg/netcdf-fortran-debuginfo-4.4.4-11.fc30.x86_64.rpm
new file mode 100644 (file)
index 0000000..281f4ef
Binary files /dev/null and b/tests/data/test-diff-pkg/netcdf-fortran-debuginfo-4.4.4-11.fc30.x86_64.rpm differ
diff --git a/tests/data/test-diff-pkg/netcdf-fortran-mpich-4.4.4-10.fc29.x86_64-4.4.4-11.fc30.x86_64-report-0.txt b/tests/data/test-diff-pkg/netcdf-fortran-mpich-4.4.4-10.fc29.x86_64-4.4.4-11.fc30.x86_64-report-0.txt
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/tests/data/test-diff-pkg/netcdf-fortran-mpich-4.4.4-10.fc29.x86_64.rpm b/tests/data/test-diff-pkg/netcdf-fortran-mpich-4.4.4-10.fc29.x86_64.rpm
new file mode 100644 (file)
index 0000000..8497c3e
Binary files /dev/null and b/tests/data/test-diff-pkg/netcdf-fortran-mpich-4.4.4-10.fc29.x86_64.rpm differ
diff --git a/tests/data/test-diff-pkg/netcdf-fortran-mpich-4.4.4-11.fc30.x86_64.rpm b/tests/data/test-diff-pkg/netcdf-fortran-mpich-4.4.4-11.fc30.x86_64.rpm
new file mode 100644 (file)
index 0000000..fdd2c33
Binary files /dev/null and b/tests/data/test-diff-pkg/netcdf-fortran-mpich-4.4.4-11.fc30.x86_64.rpm differ
diff --git a/tests/data/test-diff-pkg/netcdf-fortran-mpich-debuginfo-4.4.4-10.fc29.x86_64.rpm b/tests/data/test-diff-pkg/netcdf-fortran-mpich-debuginfo-4.4.4-10.fc29.x86_64.rpm
new file mode 100644 (file)
index 0000000..e7e3b28
Binary files /dev/null and b/tests/data/test-diff-pkg/netcdf-fortran-mpich-debuginfo-4.4.4-10.fc29.x86_64.rpm differ
diff --git a/tests/data/test-diff-pkg/netcdf-fortran-mpich-debuginfo-4.4.4-11.fc30.x86_64.rpm b/tests/data/test-diff-pkg/netcdf-fortran-mpich-debuginfo-4.4.4-11.fc30.x86_64.rpm
new file mode 100644 (file)
index 0000000..f3501a0
Binary files /dev/null and b/tests/data/test-diff-pkg/netcdf-fortran-mpich-debuginfo-4.4.4-11.fc30.x86_64.rpm differ
diff --git a/tests/data/test-diff-pkg/netcdf-fortran-mpich-devel-4.4.4-10.fc29.x86_64.rpm b/tests/data/test-diff-pkg/netcdf-fortran-mpich-devel-4.4.4-10.fc29.x86_64.rpm
new file mode 100644 (file)
index 0000000..5a89dcb
Binary files /dev/null and b/tests/data/test-diff-pkg/netcdf-fortran-mpich-devel-4.4.4-10.fc29.x86_64.rpm differ
diff --git a/tests/data/test-diff-pkg/netcdf-fortran-mpich-devel-4.4.4-11.fc30.x86_64.rpm b/tests/data/test-diff-pkg/netcdf-fortran-mpich-devel-4.4.4-11.fc30.x86_64.rpm
new file mode 100644 (file)
index 0000000..7e325a2
Binary files /dev/null and b/tests/data/test-diff-pkg/netcdf-fortran-mpich-devel-4.4.4-11.fc30.x86_64.rpm differ
index 8b4b2a795c147bec80d509f7988a03daadb76b01..403d1e8b2d29b3fb0926b41693171f3c36cece08 100644 (file)
@@ -577,6 +577,20 @@ static InOutSpec in_out_specs[] =
     "data/test-diff-pkg/GtkAda-gl-2.24.2-29.fc29.x86_64--2.24.2-30.fc30.x86_64-report-0.txt",
     "output/test-diff-pkg/GtkAda-gl-2.24.2-29.fc29.x86_64--2.24.2-30.fc30.x86_64-report-0.txt"
   },
+  {
+    "data/test-diff-pkg/netcdf-fortran-mpich-4.4.4-10.fc29.x86_64.rpm",
+    "data/test-diff-pkg/netcdf-fortran-mpich-4.4.4-11.fc30.x86_64.rpm",
+    "--fail-no-dbg",
+    "",
+    "data/test-diff-pkg/netcdf-fortran-mpich-debuginfo-4.4.4-10.fc29.x86_64.rpm,"
+    "data/test-diff-pkg/netcdf-fortran-debuginfo-4.4.4-10.fc29.x86_64.rpm",
+    "data/test-diff-pkg/netcdf-fortran-mpich-debuginfo-4.4.4-11.fc30.x86_64.rpm,"
+    "data/test-diff-pkg/netcdf-fortran-debuginfo-4.4.4-11.fc30.x86_64.rpm",
+    "data/test-diff-pkg/netcdf-fortran-mpich-devel-4.4.4-10.fc29.x86_64.rpm",
+    "data/test-diff-pkg/netcdf-fortran-mpich-devel-4.4.4-11.fc30.x86_64.rpm",
+    "data/test-diff-pkg/netcdf-fortran-mpich-4.4.4-10.fc29.x86_64-4.4.4-11.fc30.x86_64-report-0.txt",
+    "output/test-diff-pkg/netcdf-fortran-mpich-4.4.4-10.fc29.x86_64-4.4.4-11.fc30.x86_64-report-0.txt"
+  },
 #endif //WITH_RPM
 
 #ifdef WITH_DEB