public inbox for dwz@sourceware.org
 help / color / mirror / Atom feed
* [committed] Fix assertion failure in create_import_tree
@ 2019-01-01  0:00 Tom de Vries
  0 siblings, 0 replies; only message in thread
From: Tom de Vries @ 2019-01-01  0:00 UTC (permalink / raw)
  To: dwz, jakub

Hi,

When building with -DDEBUG_VERIFY_EDGES a function verify_edges becomes
available, which can be used in create_import_tree.

Calling verify_edges here in create_import_tree:
...
@@ -6249,6 +6250,7 @@ create_import_tree (void)
   for (; puidx < npus + ncus; puidx++)
     ipus[puidx]->idx = puidx;
   last_pu = ipus[npus - 1];
+  verify_edges (ipus, npus, ncus);
   /* Now, for the above constructed bipartite graph, find K x,2 components
      where x >= 5 (for DWARF3 and above or ptr_size 4, for DWARF2 and
      ptr_size 8 it can be even x == 4) and add a new PU node, where all
@@ -6407,6 +6409,7 @@ create_import_tree (void)
            }
        }
     }
+  verify_edges (ipus, npus, ncus);
   /* Try to merge PUs which have the same set of referrers if
      beneficial, or if one PU has a subset of referrers of the
      other, attempt to replace all the incoming edges from the
...
doesn't give any errors in the dwz testsuite (and in the external one).

OTOH, calling verify_edges one step later:
...
@@ -6633,6 +6636,7 @@ create_import_tree (void)
       for (icu = ipu->next; icu; icu = icu->next)
        icu->seen = false;
     }
+  verify_edges (ipus, npus, ncus);
   /* Create DW_TAG_partial_unit (and containing dw_cu structures).  */
   if (fi_multifile)
     {
...
gives us:
...
$ cp hello 1; dwz 1
dwz: dwz.c:6042: verify_edges_1: Assertion `e2' failed.
...

The assertion failure triggers because a PU 0 has an incoming edge from PU 0
(which doesn't make sense), without a corresponding outgoing edge:
...
idx: 0
cu: 0x0
incoming: 0
incoming: 4
...

Also a PU 1 has an outgoing edge to PU 0, but PU 0 has no corresponding
incoming edge:
...
idx: 1
cu: 0x1
incoming: 2
incoming: 3
outgoing: 0
...

Fix this by replacing the nonsensical incoming self-edge on PU 0 with one
matching the outgoing PU 1 -> PU 0 edge:
...
idx: 0
cu: 0x0
incoming: 1
incoming: 4
...

Committed to trunk.

Thanks,
- Tom

Fix assertion failure in create_import_tree

2019-11-17  Tom de Vries  <tdevries@suse.de>

	PR dwz/25166
	* dwz.c (create_import_tree): Fix import tree transformation.

---
 dwz.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/dwz.c b/dwz.c
index 9f37fd0..9c0a73e 100644
--- a/dwz.c
+++ b/dwz.c
@@ -6620,7 +6620,7 @@ create_import_tree (void)
 		  assert (*ep == NULL || (*ep)->icu != ipusub);
 		  e4 = edge_freelist;
 		  edge_freelist = edge_freelist->next;
-		  e4->icu = ipusup;
+		  e4->icu = ipusub;
 		  e4->next = *ep;
 		  *ep = e4;
 		  ipusup->incoming_count -= ipusub->incoming_count - 1;

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2019-11-17 16:45 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-01-01  0:00 [committed] Fix assertion failure in create_import_tree Tom de Vries

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).