public inbox for dwz@sourceware.org
 help / color / mirror / Atom feed
From: "vries at gcc dot gnu.org" <sourceware-bugzilla@sourceware.org>
To: dwz@sourceware.org
Subject: [Bug default/27562] New: [dwz] Verify that conditional fields of struct dw_die are only accessed when available
Date: Thu, 11 Mar 2021 14:07:06 +0000	[thread overview]
Message-ID: <bug-27562-11298@http.sourceware.org/bugzilla/> (raw)

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.

             reply	other threads:[~2021-03-11 14:07 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-11 14:07 vries at gcc dot gnu.org [this message]
2021-03-11 14:07 ` [Bug default/27562] " vries at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-27562-11298@http.sourceware.org/bugzilla/ \
    --to=sourceware-bugzilla@sourceware.org \
    --cc=dwz@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).