From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 115178 invoked by alias); 17 Nov 2019 16:45:56 -0000 Mailing-List: contact dwz-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Post: List-Help: List-Subscribe: Sender: dwz-owner@sourceware.org Received: (qmail 115166 invoked by uid 89); 17 Nov 2019 16:45:56 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Checked: by ClamAV 0.100.3 on sourceware.org X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.1 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,SPF_PASS autolearn=ham version=3.3.1 spammy=triggers, otoh, OTOH X-Spam-Status: No, score=-25.1 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,SPF_PASS autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on sourceware.org X-Spam-Level: X-HELO: mx1.suse.de X-Virus-Scanned: by amavisd-new at test-mx.suse.de Date: Tue, 01 Jan 2019 00:00:00 -0000 From: Tom de Vries To: dwz@sourceware.org, jakub@redhat.com Subject: [committed] Fix assertion failure in create_import_tree Message-ID: <20191117164549.GA4988@delia> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.10.1 (2018-07-13) X-SW-Source: 2019-q4/txt/msg00055.txt.bz2 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 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;