dwarf-reader: Don't propagate canonical type upon aggregate redundancy

This comes from trying to fix
https://sourceware.org/bugzilla/show_bug.cgi?id=26646.

During DIE comparison for the purpose of DIE canonicalization, we need
to detect a loop due to a recurring aggregate comparison.  Thus, the
compare_dies function returns true in when it detects that it's
comparing two aggregate that are already being compared.  In that
situation of "detected aggregate redundancy", even though the
comparison seemingly succeeds, no canonical type propagation should
happen.

This patch prevents canonical type propagation when compare_dies
return true to signal aggregate redundancy detection.

This addresses https://sourceware.org/bugzilla/show_bug.cgi?id=26646#c21.

	* src/abg-dwarf-reader.cc (compare_dies): Do not propagate
	canonical type when aggregate redundancy is detected.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
This commit is contained in:
Dodji Seketeli 2022-02-24 10:49:43 +01:00
parent bfd5570403
commit c696400f21

View File

@ -10236,6 +10236,7 @@ compare_dies(const read_context& ctxt,
return l_canonical_die_offset == r_canonical_die_offset; return l_canonical_die_offset == r_canonical_die_offset;
bool result = true; bool result = true;
bool aggregate_redundancy_detected = false;
switch (l_tag) switch (l_tag)
{ {
@ -10349,7 +10350,11 @@ compare_dies(const read_context& ctxt,
{ {
if (has_offset_pair(aggregates_being_compared, if (has_offset_pair(aggregates_being_compared,
die_offset(l), die_offset(r))) die_offset(l), die_offset(r)))
result = true; {
result = true;
aggregate_redundancy_detected = true;
break;
}
else if (!compare_as_decl_dies(l, r) || !compare_as_type_dies(l, r)) else if (!compare_as_decl_dies(l, r) || !compare_as_type_dies(l, r))
result = false; result = false;
else else
@ -10477,6 +10482,7 @@ compare_dies(const read_context& ctxt,
die_offset(r))) die_offset(r)))
{ {
result = true; result = true;
aggregate_redundancy_detected = true;
break; break;
} }
else if (l_tag == DW_TAG_subroutine_type) else if (l_tag == DW_TAG_subroutine_type)
@ -10672,6 +10678,7 @@ compare_dies(const read_context& ctxt,
} }
if (result == true if (result == true
&& !aggregate_redundancy_detected
&& update_canonical_dies_on_the_fly && update_canonical_dies_on_the_fly
&& is_canonicalizeable_type_tag(l_tag)) && is_canonicalizeable_type_tag(l_tag))
{ {