Add assert in partition_found_dups With the reproducer from PR26252 we get: ... $ dwz -m 3 --odr 1 2 dwz: 1: DWARF compression not beneficial - old size 317760 new size 317760 dwz: dwz.c:12431: write_die: \ Assertion `value && refdcu->cu_kind != CU_ALT' failed. Aborted (core dumped) ... The assertion fails when writing out the contribution of file 2 to the multifile. It's trying to write out a copy of this DIE: ... <3><9f3e>: Abbrev Number: 149 (DW_TAG_subprogram) <9f40> DW_AT_name : _M_access > <9f44> DW_AT_decl_file : 11 <9f45> DW_AT_decl_line : 92 <9f46> DW_AT_decl_column : 7 <9f47> DW_AT_type : <0x1a2a5> <9f4b> DW_AT_declaration : 1 <9f4b> DW_AT_object_pointer: <0x9f5c> <9f4f> DW_AT_sibling : <0x9f62> ... and specifically, for the DW_AT_type attribute it attempts to write out the reference to the copy of the DIE at 0x1a2a5: ... <1><1a2a5>: Abbrev Number: 9 (DW_TAG_reference_type) <1a2a6> DW_AT_byte_size : 8 <1a2a7> DW_AT_type : <0x27cd9> ... There is no copy of that DIE, because it has a bad checksum: ... 1a2a5 X d27b2f2a d27b2f2a reference_type (type: 27cd9 structure_type) ... which means that its toplevel DIE 0x9edc: ... <2><9edc>: Abbrev Number: 182 (DW_TAG_union_type) <9ede> DW_AT_name : _Any_data ... should also have a bad checksum, but it doesn't: ... 9edc O 9d6524b4 9d6524b4 _Any_data union_type ... while without --odr, it does: ... 9edc X d8f947f3 5100c9e1 _Any_data union_type ... Add an assert partition_found_dups such that we can catch the problem of the checksum much earlier: ... static void partition_found_dups (dw_die_ref die, struct obstack *vec) { + assert (die->die_ck_state == CK_KNOWN); ... which means we can reproduce with just one file: ... $ dwz 2 --odr dwz: dwz.c:7372: partition_found_dups: \ Assertion `die->die_ck_state == CK_KNOWN' failed. Aborted (core dumped) ... 2021-02-18 Tom de Vries * dwz.c (partition_found_dups): Assert that die->die_ck_state == CK_KNOWN. --- dwz.c | 1 + 1 file changed, 1 insertion(+) diff --git a/dwz.c b/dwz.c index d037e1e..0b751fc 100644 --- a/dwz.c +++ b/dwz.c @@ -7393,6 +7393,7 @@ partition_cmp (const void *p, const void *q) static void partition_found_dups (dw_die_ref die, struct obstack *vec) { + assert (die->die_ck_state == CK_KNOWN); obstack_ptr_grow (vec, die); if (unlikely (verify_dups_p)) verify_dups (die, true);