[Bug default/27562] New: [dwz] Verify that conditional fields of struct dw_die are only accessed when available

vries at gcc dot gnu.org sourceware-bugzilla@sourceware.org
Thu Mar 11 14:07:06 GMT 2021


https://sourceware.org/bugzilla/show_bug.cgi?id=27562

            Bug ID: 27562
           Summary: [dwz] Verify that conditional fields of struct dw_die
                    are only accessed when available
           Product: dwz
           Version: unspecified
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: default
          Assignee: nobody at sourceware dot org
          Reporter: vries at gcc dot gnu.org
                CC: dwz at sourceware dot org
  Target Milestone: ---

The fields until die_parent in struct dw_die are available unconditionally.

But after die_parent, some are only available if die_collapsed_child == 0, and
others only if die_toplevel == 1.

We need to be able to instrument accesses to the conditionally available
fields, such that it's checked whether the field is indeed available.

F.i. something like this:
...
diff --git a/dwz.c b/dwz.c
index 5975cc7..5f8db49 100644
--- a/dwz.c
+++ b/dwz.c
@@ -1175,6 +1175,22 @@ struct dw_die
   dw_die_ref die_nextdup;
 };

+static inline dw_die_ref FORCE_INLINE
+get_die_nextdup (dw_die_ref die)
+{
+  assert (die->die_toplevel);
+  return die->die_nextdup;
+}
+
+static inline void FORCE_INLINE
+set_die_nextdup (dw_die_ref die, dw_die_ref val)
+{
+  assert (die->die_toplevel);
+  die->die_nextdup = val;
+}
+
+#define die_nextdup poisoned_die_nextdup
+
 #include "iterators.h"

 /* Return CU structure pointer for a DIE.  In order to save memory,
@@ -4771,7 +4787,7 @@ die_eq_1 (dw_cu_ref cu1, dw_cu_ref cu2,
       if (!die2->die_op_type_referenced)
        die2->die_remove = 1;
       obstack_ptr_grow (&ob, die2);
-      if (likely (die2->die_nextdup == NULL))
+      if (likely (get_die_nextdup (die2) == NULL))
        {
          die2->die_dup = die1;
          die2->die_nextdup = die1->die_nextdup;
...

-- 
You are receiving this mail because:
You are on the CC list for the bug.


More information about the Dwz mailing list