public inbox for libabigail@sourceware.org
 help / color / mirror / Atom feed
From: Dodji Seketeli <dodji@redhat.com>
To: libabigail@sourceware.org
Subject: [PATCH, applied] ir: Fix cycle detection for union types
Date: Fri, 10 Mar 2023 09:46:38 +0100	[thread overview]
Message-ID: <87ttytngcx.fsf@redhat.com> (raw)

Hello,

It seems the commit below (in libabigail 2.1) broke the cycle
detection during union types comparison.

commit 4bc513a8ae4436625e8641125e0dd0d75d398af2
Author: Dodji Seketeli <dodji@redhat.com>
Date:   Thu Sep 8 19:09:33 2022 +0200

    Fix IR comparison result caching and canonical type propagation tracking

This patch fixes that.

	* src/abg-ir.cc (CACHE_COMPARISON_RESULT_AND_RETURN): Define new
	macro.
	(equals): In the overload for unions, detect cycles right
	away. Also, do not use mark_types_as_being_compared and
	return_comparison_result as that would indirectly call
	environment::priv::unmark_as_being_compared one too many, thus
	breaking the cycle detection machinery.  Rather, just cache the
	result of comparing the type as a class_or_union and return, using
	CACHE_COMPARISON_RESULT_AND_RETURN.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Applied to master.
---
 src/abg-ir.cc | 21 ++++++++++++++++-----
 1 file changed, 16 insertions(+), 5 deletions(-)

diff --git a/src/abg-ir.cc b/src/abg-ir.cc
index 015aa2b3..047b755d 100644
--- a/src/abg-ir.cc
+++ b/src/abg-ir.cc
@@ -1104,6 +1104,18 @@ return_comparison_result(T& l, T& r, bool value,
       l.get_environment().priv_->cache_type_comparison_result(l, r, res); \
       return res;							\
     } while (false)
+
+/// Cache the result of a comparison between too artifacts (l & r) and
+/// return immediately.
+///
+/// @param value the value to cache.
+#define CACHE_COMPARISON_RESULT_AND_RETURN(value)			\
+  do									\
+    {									\
+      l.get_environment().priv_->cache_type_comparison_result(l, r, value); \
+      return value;							\
+    } while (false)
+
 /// Getter of all types types sorted by their pretty representation.
 ///
 /// @return a sorted vector of all types sorted by their pretty
@@ -24935,6 +24947,9 @@ union_decl::~union_decl()
 bool
 equals(const union_decl& l, const union_decl& r, change_kind* k)
 {
+
+  RETURN_TRUE_IF_COMPARISON_CYCLE_DETECTED(l, r);
+
   {
     // First of all, let's see if these two types haven't already been
     // compared.  If so, and if the result of the comparison has been
@@ -24945,15 +24960,11 @@ equals(const union_decl& l, const union_decl& r, change_kind* k)
       return result;
   }
 
-#define RETURN(value) CACHE_AND_RETURN_COMPARISON_RESULT(value)
-
   bool result = equals(static_cast<const class_or_union&>(l),
 		       static_cast<const class_or_union&>(r),
 		       k);
 
-  mark_types_as_being_compared(l, r);
-
-  RETURN(result);
+  CACHE_COMPARISON_RESULT_AND_RETURN(result);
 }
 
 /// Copy a method of a @ref union_decl into a new @ref
-- 
2.39.2


-- 
		Dodji


                 reply	other threads:[~2023-03-10  8:46 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87ttytngcx.fsf@redhat.com \
    --to=dodji@redhat.com \
    --cc=libabigail@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).