Created attachment 13310 [details] Shared library I see the following assert: $ ./dwz --odr libvclplug_genlo.so-7.1.1.2-0.x86_64.debug dwz: dwz.c:8826: remove_import_edges: Assertion `i == cucount' failed. Aborted (core dumped)
With --no-import-optimize, we run instead into: ... $ dwz ./libvclplug_genlo.so.debug -o libvclplug_genlo.so.debug.z -lnone --odr --no-import-optimize dwz: /home/vries/dwz/dwz.git/dwz.c:12685: write_die: Assertion `IMPLIES (cu->cu_kind == CU_PU, die_cu (refd)->cu_kind == CU_PU)' failed. Aborted ...
(In reply to Tom de Vries from comment #1) > With --no-import-optimize, we run instead into: > ... > $ dwz ./libvclplug_genlo.so.debug -o libvclplug_genlo.so.debug.z -lnone > --odr --no-import-optimize > dwz: /home/vries/dwz/dwz.git/dwz.c:12685: write_die: Assertion `IMPLIES > (cu->cu_kind == CU_PU, die_cu (refd)->cu_kind == CU_PU)' failed. > Aborted > ... Fixed by: ... diff --git a/dwz.c b/dwz.c index 54b4bda..fcbc3aa 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; ... But that doesn't fix the assert reported in comment 0.
(In reply to Martin Liska from comment #0) > Created attachment 13310 [details] > Shared library > > I see the following assert: > > $ ./dwz --odr libvclplug_genlo.so-7.1.1.2-0.x86_64.debug > dwz: dwz.c:8826: remove_import_edges: Assertion `i == cucount' failed. > Aborted (core dumped) That's triggered in phase 2. When using --devel-verify-edges, we get an assert at the end of phase 1: ... $ ./dwz ./libvclplug_genlo.so.debug -o libvclplug_genlo.so.debug.z -lnone --odr --devel-verify-edges dwz: dwz.c:8923: verify_edges_1: Assertion `count == 0 || e1->icu->idx > last_idx' failed. Aborted (core dumped) ...
OK, that's due to: ... idx: 48 cu: 0xbc incoming: 200 incoming: 201 incoming: 201 incoming: 203 incoming: 204 incoming: 208 ... There are two incoming edges from the same CU. So, one CU is importing the same PU twice. We can see this in the output if we do --no-import-optimize: ... <1><4742f>: Abbrev Number: 51 (DW_TAG_imported_unit) <47430> DW_AT_import : <0x7f02> [Abbrev Number: 18 (DW_TAG_partial_unit)] <1><47434>: Abbrev Number: 51 (DW_TAG_imported_unit) <47435> DW_AT_import : <0x7f02> [Abbrev Number: 18 (DW_TAG_partial_unit)] ...
Tentative patch: ... @@ -9130,11 +9135,18 @@ create_import_tree (void) ipu->cu = pu; pu->u1.cu_icu = ipu; assert (rdie->die_toplevel); + dw_die_ref firstdie = NULL; + dw_cu_ref firstdiecu = NULL; for (die = rdie->die_nextdup, prev_cu = NULL; die; die = die->die_nextdup) { dw_cu_ref diecu = die_cu (die); - if (diecu == prev_cu) + if (firstdie == NULL) + { + firstdie = die; + firstdiecu = die_cu (firstdie); + } + if (diecu == prev_cu || (die != firstdie && diecu == firstdiecu)) continue; ipu->incoming_count++; size += 1 + (diecu->cu_version == 2 ? ptr_size : 4); @@ -9144,11 +9156,18 @@ create_import_tree (void) obstack_alloc (&ob2, ipu->incoming_count * sizeof (*ipu->incoming)); + firstdie = NULL; + firstdiecu = NULL; for (die = rdie->die_nextdup, i = 0, prev_cu = NULL; die; die = die->die_nextdup) { dw_cu_ref diecu = die_cu (die); - if (diecu == prev_cu) + if (firstdie == NULL) + { + firstdie = die; + firstdiecu = die_cu (firstdie); + } + if (diecu == prev_cu || (die != firstdie && diecu == firstdiecu)) continue; icu = diecu->u1.cu_icu; if (icu == NULL) ...
Fixed by commits: https://sourceware.org/git/?p=dwz.git;a=commit;h=f765cd976583d98fcbc9b562671007653c651272 https://sourceware.org/git/?p=dwz.git;a=commit;h=4e7ce44a4f7d0e12a029a7a2f115ccf48746d686