public inbox for dwz@sourceware.org
 help / color / mirror / Atom feed
From: Tom de Vries <tdevries@suse.de>
To: dwz@sourceware.org, jakub@redhat.com, mark@klomp.org
Subject: [committed] Fix another reference from PU to CU for odr
Date: Tue, 16 Mar 2021 16:54:25 +0100	[thread overview]
Message-ID: <20210316155424.GA32231@delia> (raw)

Hi,

When using the test-case from PR27578 with --no-import-optimize, we run into:
...
$ dwz libvclplug_genlo.so.debug -o libvclplug_genlo.so.debug.z \
    -lnone --odr --no-import-optimize
dwz: dwz.c:12700: write_die: \
  Assertion `IMPLIES (cu->cu_kind == CU_PU, \
                      die_cu (refd)->cu_kind == CU_PU)' failed.
Aborted (core dumped)
...

The assert is triggered when trying to write out the reference to the DIE at
2f5e for DW_AT_type:
...
 <1><2e8c>: Abbrev Number: 76 (DW_TAG_structure_type)
    <2e8d>   DW_AT_name        : (indirect string, offset: 0x5f592): SalXLib
    <2e91>   DW_AT_byte_size   : 320
 ...
 <2><2ed9>: Abbrev Number: 22 (DW_TAG_member)
    <2eda>   DW_AT_name        : (indirect string, offset: 0x56c9b): aReadFDS_
    <2ede>   DW_AT_decl_file   : 33
    <2edf>   DW_AT_decl_line   : 173
    <2ee0>   DW_AT_decl_column : 21
    <2ee1>   DW_AT_type        : <0x2f5e>
    <2ee5>   DW_AT_data_member_location: 48
    <2ee6>   DW_AT_accessibility: 2     (protected)
...

The corresponding duplicate chain (with some annotations manually added) is:
...
duplicate chain:
Compilation Unit @ offset 0x44:
 2d01 O 9f6a4268(29178f4e) 9f6a4268 SalXLib structure_type DECL
 2e8c O 9f6a4268(87d059e8) 9f6a4268 SalXLib structure_type DEF
 40a6 O 9f6a4268(87d059e8) 9f6a4268 SalXLib structure_type DEF
Compilation Unit @ offset 0xfaf6:
 419be O 9f6a4268(29178f4e) 9f6a4268 SalXLib structure_type DECL
 50e56 O 9f6a4268(29178f4e) 9f6a4268 SalXLib structure_type DECL
 6063a O 9f6a4268(29178f4e) 9f6a4268 SalXLib structure_type DECL
Compilation Unit @ offset 0x1bb0f:
...

The duplicate chain is created by split_dups, which merged all the DECLs with
one duplicate chain containing only DEFs.

When doing the test for merged_singleton on this duplicate chain, it returns
NULL, because there are two DEFs.  However, the DEFs are from the same CU, and
the type for aReadFDS_ is 0x2f5e for both DEFs.  Consequently, there is no
duplicate chain for 0x2f5e, and we need to force a singleton duplicate chain.

Fix this by making merged_singleton return the first DEF.

Committed to trunk.

Thanks,
- Tom

Fix another reference from PU to CU for odr

2021-03-16  Tom de Vries  <tdevries@suse.de>

	PR dwz/27578
	* dwz.c (merged_singleton): Handle DEFs in the same CU.

---
 dwz.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/dwz.c b/dwz.c
index 54b4bda..11c9114 100644
--- a/dwz.c
+++ b/dwz.c
@@ -8433,7 +8433,12 @@ merged_singleton (dw_die_ref die)
       {
       case ODR_DEF:
 	if (res)
-	  return NULL;
+	  {
+	    if (die_cu (res) == die_cu (d))
+	      continue;
+	    else
+	      return NULL;
+	  }
 	else
 	  res = d;
 	break;

                 reply	other threads:[~2021-03-16 15:54 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20210316155424.GA32231@delia \
    --to=tdevries@suse.de \
    --cc=dwz@sourceware.org \
    --cc=jakub@redhat.com \
    --cc=mark@klomp.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).