From patchwork Fri Mar 10 08:46:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dodji Seketeli X-Patchwork-Id: 66204 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 162C53858428 for ; Fri, 10 Mar 2023 08:46:49 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 162C53858428 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1678438009; bh=SBr9fk4Kl7xLKLvQiWbCa1D/M14TS5M1DuFePbpHkMw=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Help: List-Subscribe:From:Reply-To:From; b=Sgase2DGZikCdNaJXi9fI09NWgNEAp/pdpWnyVQTP7fR7EG7ys2YRNmzl1qhXO1ix FrYjZZv5+ZEEaZALTmFeWCl4824kP/L6HOiZYaP1vEVIbfDHuN+5+W5TJ5/aaWH63j sjqdEM2ok1Tq8eQNQuWzWj12Q9g6YqvXsZIcHshw= X-Original-To: libabigail@sourceware.org Delivered-To: libabigail@sourceware.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id 1B3863858C5E for ; Fri, 10 Mar 2023 08:46:44 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 1B3863858C5E Received: from mail-qt1-f197.google.com (mail-qt1-f197.google.com [209.85.160.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-343-mDRh03X-PmWC1s1dHGdxPg-1; Fri, 10 Mar 2023 03:46:41 -0500 X-MC-Unique: mDRh03X-PmWC1s1dHGdxPg-1 Received: by mail-qt1-f197.google.com with SMTP id k19-20020ac86053000000b003bd0d4e3a50so2537287qtm.9 for ; Fri, 10 Mar 2023 00:46:41 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678438001; h=mime-version:user-agent:message-id:date:organization:subject:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=SBr9fk4Kl7xLKLvQiWbCa1D/M14TS5M1DuFePbpHkMw=; b=tyjySEQcyqP5fRt2N7P3CFKEKANPeM3CTOIUuqEoqs2Vjf7Jm656ExaOvzeFskCKxZ wSsuJ9zNd9oOCjgBtR4NTkjE8EQGCqW/hpP8Pb0PdUq8xF/Sp/xbDwQFMDW6tgrks91m a9c+VczAXPNDmcLbfbphsGPEqW60KdmUDrHzXeP73OdyIcNjA3xMC5e7nM96ZXAz9/MU STtTzmxicchzgmSJt1uqDwf1OX3jrMErWIed5PJ/vVZh1B7dI9/IytGxqL2YcPfmFei0 bw8BlUb7qf0AxAWHJx12jAck9J9b2oHhFO8k1U4wvBYkJ3V1OKMc93UiyDYqGZShQ1ri 1SxA== X-Gm-Message-State: AO0yUKVHVRl7Yau3uy/rc0busdT2psnHLm3iwfiY76rV+1rhlJCJbezk fIiCWA1qBrmp7jgtxMCJK5+VUMIer36K/QxpSifc03tHLUVS4dQVxf6fRs1+0ugUhBdfZpkPZ48 FNhDwY4t+PFylscw/eWtf8z3mg0nclDTQTF9hxrGqZK89u4bFjRRENyfkiWZHK5Pst/w5TcYQMo fA X-Received: by 2002:ad4:5dcb:0:b0:56e:9551:197f with SMTP id m11-20020ad45dcb000000b0056e9551197fmr43022665qvh.2.1678438001010; Fri, 10 Mar 2023 00:46:41 -0800 (PST) X-Google-Smtp-Source: AK7set8hwEOoRuhSgPEL9sOl2d6jVKGYiNo13A6K1xfMe2dMC1qZpUC71jDeBy5jhfrZ4CCayK9jrA== X-Received: by 2002:ad4:5dcb:0:b0:56e:9551:197f with SMTP id m11-20020ad45dcb000000b0056e9551197fmr43022641qvh.2.1678438000591; Fri, 10 Mar 2023 00:46:40 -0800 (PST) Received: from localhost ([88.120.130.27]) by smtp.gmail.com with ESMTPSA id c26-20020a05620a0cfa00b0073b587194d0sm906380qkj.104.2023.03.10.00.46.40 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 Mar 2023 00:46:40 -0800 (PST) Received: by localhost (Postfix, from userid 1000) id 59B54581C79; Fri, 10 Mar 2023 09:46:38 +0100 (CET) To: libabigail@sourceware.org Subject: [PATCH, applied] ir: Fix cycle detection for union types Organization: Red Hat / France X-Operating-System: Fedora 38 X-URL: http://www.redhat.com Date: Fri, 10 Mar 2023 09:46:38 +0100 Message-ID: <87ttytngcx.fsf@redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-11.8 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libabigail@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Mailing list of the Libabigail project List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-Patchwork-Original-From: Dodji Seketeli via Libabigail From: Dodji Seketeli Reply-To: Dodji Seketeli Errors-To: libabigail-bounces+patchwork=sourceware.org@sourceware.org Sender: "Libabigail" Hello, It seems the commit below (in libabigail 2.1) broke the cycle detection during union types comparison. commit 4bc513a8ae4436625e8641125e0dd0d75d398af2 Author: Dodji Seketeli 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 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(l), static_cast(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