[2/2,RFC] dwarf-reader: Don't propagate canonical type upon aggregate redundancy

Message ID 87sfs3jpm0.fsf@redhat.com
State New
Headers
Series [1/2,/,RFC] Bug 26646 - unexpected declaration-only types (part 2) |

Commit Message

Dodji Seketeli Feb. 28, 2022, 9:40 a.m. UTC
  Hello Giuliano,

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>
---
 src/abg-dwarf-reader.cc | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
  

Comments

Dodji Seketeli March 4, 2022, 10:53 a.m. UTC | #1
Dodji Seketeli via Libabigail <libabigail@sourceware.org> a écrit:

[...]

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

Applied to master for now.

I'll work on a more global solution, similarly to what's done in the IR
canonicalizer soon.

Cheers,
  

Patch

diff --git a/src/abg-dwarf-reader.cc b/src/abg-dwarf-reader.cc
index 05a7e4d6..58f0607e 100644
--- a/src/abg-dwarf-reader.cc
+++ b/src/abg-dwarf-reader.cc
@@ -10240,6 +10240,7 @@  compare_dies(const read_context& ctxt,
     return l_canonical_die_offset == r_canonical_die_offset;
 
   bool result = true;
+  bool aggregate_redundancy_detected = false;
 
   switch (l_tag)
     {
@@ -10353,7 +10354,11 @@  compare_dies(const read_context& ctxt,
       {
 	if (has_offset_pair(aggregates_being_compared,
 			    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))
 	  result = false;
 	else
@@ -10481,6 +10486,7 @@  compare_dies(const read_context& ctxt,
 			    die_offset(r)))
 	  {
 	    result = true;
+	    aggregate_redundancy_detected = true;
 	    break;
 	  }
 	else if (l_tag == DW_TAG_subroutine_type)
@@ -10676,6 +10682,7 @@  compare_dies(const read_context& ctxt,
     }
 
   if (result == true
+      && !aggregate_redundancy_detected
       && update_canonical_dies_on_the_fly
       && is_canonicalizeable_type_tag(l_tag))
     {