Bug 21629 - equivalent DIEs must be of the same DIE source
authorDodji Seketeli <dodji@redhat.com>
Fri, 23 Jun 2017 11:18:40 +0000 (13:18 +0200)
committerDodji Seketeli <dodji@redhat.com>
Tue, 4 Jul 2017 14:45:31 +0000 (16:45 +0200)
A prerequisite to represent the relationship "DIE 'D' has canonical
DIE C", is that D and C come from the same DIE source.  A DIE source
being either the main debug info file, the alternate debug info file
(both having DIEs in their .debug_info section), or a .debug_type
section.

This prerequisite is a result of the design of the current
libabigail's DWARF reader.

Unfortunately the code that compares DIEs and that updates the
canonical DIEs of the compared DIEs (in case the two DIEs are
equivalent) sometimes fails to honour that prerequisite, causing other
troubles down the road.

This patch fixes that by ensuring that equivalent DIEs must be of the
same DIE source.

The patch doesn't embed a regression test as this problem was
discovered using the
https://pagure.io/libabigail-selfcheck/blob/master/f/selfcheck.py
testing framework

* src/abg-dwarf-reader.cc (compare_dies): Don't propagate
a canonical DIE to a DIE that comes from a different source.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
src/abg-dwarf-reader.cc

index d9d7634fe632aa7d4749c15a1c69ef15420c2dcb..ac3fb1bc51ea610b63b9c188c9ed0466d8d890ac 100644 (file)
@@ -11411,7 +11411,14 @@ compare_dies(const read_context& ctxt, Dwarf_Die *l, Dwarf_Die *r,
       //
       // In case 'r' has no canonical DIE, then compute it, and then
       // propagate that canonical DIE to 'r'.
-      if (!l_has_canonical_die_offset)
+      die_source l_source = NO_DEBUG_INFO_DIE_SOURCE,
+       r_source = NO_DEBUG_INFO_DIE_SOURCE;
+      assert(ctxt.get_die_source(l, l_source));
+      assert(ctxt.get_die_source(r, r_source));
+      if (!l_has_canonical_die_offset
+         // A DIE can be equivalent only to another DIE of the same
+         // source.
+         && l_source == r_source)
        {
          if (!r_has_canonical_die_offset)
            ctxt.compute_canonical_die_offset(r, r_canonical_die_offset,