From patchwork Tue Oct 3 12:45:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dodji Seketeli X-Patchwork-Id: 77021 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 9BEAD382FAFE for ; Tue, 3 Oct 2023 12:45:30 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9BEAD382FAFE DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1696337130; bh=y48a0a57ZT60tpNsxKHUg42eLFUTOVkUIKOlM9Lrl5g=; h=To:Subject:References:Date:In-Reply-To:List-Id:List-Unsubscribe: List-Archive:List-Help:List-Subscribe:From:Reply-To:Cc:From; b=TpwkxQHfECQ5ylQVqn0kPUA44J6iAJC2ErKcy2w/VpRfAxHJknxf2Vu/Hu7R0SPKi J0VP7gHQpZ2e1WPzWAI4na8peH0Lja7CKrUcq/4bbTnTLRPknHSCZxKnNIdtWcUQD4 CzhxamHeqEhIaxOuJaD7+2+WsIT7yaTeVUcHAGek= 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 91699385B522 for ; Tue, 3 Oct 2023 12:45:24 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 91699385B522 Received: from mail-qk1-f198.google.com (mail-qk1-f198.google.com [209.85.222.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-135-wvhXUvEDMU-6j-XuT5s4vQ-1; Tue, 03 Oct 2023 08:45:13 -0400 X-MC-Unique: wvhXUvEDMU-6j-XuT5s4vQ-1 Received: by mail-qk1-f198.google.com with SMTP id af79cd13be357-7740c0e88ffso114802385a.1 for ; Tue, 03 Oct 2023 05:45:13 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696337112; x=1696941912; h=mime-version:user-agent:message-id:in-reply-to:date:references :organization:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=y48a0a57ZT60tpNsxKHUg42eLFUTOVkUIKOlM9Lrl5g=; b=KgWXEWn7hX2S1Ph+/pZAnpKzSZHZhs2lV2Y7jJCJZ6epqzlwC4f6Tn+0Qt8IzHN+QD JpvUfeAdqyNhcbeEpBwIq6pAyU9tgCxiEfpsd7arEpW6N5ZKMiUiioHsIR4sZCHgoLK4 +rsFop8EbwzHv11VCZiSVEH7NJg9FKjhcQ61b2O6Luu0iWndIL5bDAAw5H7j5kkCA38J IrcRCMu0mCIQwzsQiyWib6KdJqxMGSNc0/GVy29OpRYv11DO29g3Uq40XvPytjDRB/Vu ne+Dz+VkysDRF5Mptz/bd7QtHfl4dKmLdcIbYFeoyKF904bZHEvymJMjYpqD4N5zLYay ncRw== X-Gm-Message-State: AOJu0Yx2Ue5YSOh2n3Kw/bQnfu8ExRFdxPU5f8vA1As6ZXs9HLILZ0FI r20/Ul99LkptLd9AiJHmyKne7IqzSTG2Jal2Tc72LZMhxegspzWdeos9ncfPKVDmMUJSRHQGHVI QZlpjoh8XhDr4VLzNlqtvlcnuAD4e X-Received: by 2002:a37:ef13:0:b0:774:1992:15c9 with SMTP id j19-20020a37ef13000000b00774199215c9mr14870983qkk.42.1696337112289; Tue, 03 Oct 2023 05:45:12 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFZX2XRzAtF5OtCHzT/n+KgN/ysGJfRv0tKGSdlM21QdYwysdk52UV5/K7iBhjPA1of4ICS7w== X-Received: by 2002:a37:ef13:0:b0:774:1992:15c9 with SMTP id j19-20020a37ef13000000b00774199215c9mr14870965qkk.42.1696337111921; Tue, 03 Oct 2023 05:45:11 -0700 (PDT) Received: from localhost ([88.120.130.27]) by smtp.gmail.com with ESMTPSA id vr2-20020a05620a55a200b007758aad4b64sm420619qkn.9.2023.10.03.05.45.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Oct 2023 05:45:11 -0700 (PDT) Received: by localhost (Postfix, from userid 1000) id 4FED4B6E87; Tue, 3 Oct 2023 14:45:09 +0200 (CEST) To: libabigail@sourceware.org Subject: [PATCH 1/4] For WIP branch check-uapi-support:abg-comparison[-priv]: Detect incompatible unreachable type changes Organization: Red Hat / France References: <874jj7hp6e.fsf@redhat.com> X-Operating-System: CentOS Stream release 9 X-URL: http://www.redhat.com Date: Tue, 03 Oct 2023 14:45:09 +0200 In-Reply-To: <874jj7hp6e.fsf@redhat.com> (Dodji Seketeli's message of "Tue, 03 Oct 2023 14:21:29 +0200") Message-ID: <87zg0zg9ii.fsf@redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux) MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-11.9 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_H4, RCVD_IN_MSPIKE_WL, 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.30 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 Cc: dodji@redhat.com Errors-To: libabigail-bounces+patchwork=sourceware.org@sourceware.org Sender: "Libabigail" Hello, corpus_diff::has_incompatible_changes fails to detect when an unreachable enum has an incompatible enum change. This is because corpus_diff::has_incompatible_changes doesn't look at corpus_diff::priv::changed_unreachable_types_[sorted_] to see if changes in the unreachable types held by these data members are incompatible or not. While looking at this, I noted that corpus_diff::priv::apply_filters_and_compute_diff_stats doesn't categorize the diffs in corpus_diff::priv::changed_unreachable_types_, so it's not possible to look at the categories of the changes held by that data member to see if they are incompatible or not. This patch thus categorizes the diff nodes held by corpus_diff::priv::changed_unreachable_types_ and makes corpus_diff::has_incompatible_changes look at those diff nodes to detect if they are incompatible. * src/abg-comparison-priv.h (corpus_diff::priv::changed_unreachable_types): Declare ... * src/abg-comparison.cc (corpus_diff::priv::changed_unreachable_types): ... new function. (corpus_diff::priv::apply_filters_and_compute_diff_stats): Walk the nodes returned by corpus corpus_diff:priv::changed_unreachable_types() and apply the filters (including categorization filters) to them. (corpus_diff::has_incompatible_changes): Now that diff nodes returned by corpus_diff::priv::changed_unreachable_types are categorized, look at their change categories to see if they are incompatible or not. Signed-off-by: Dodji Seketeli OK for branch check-uapi-support? --- src/abg-comparison-priv.h | 3 +++ src/abg-comparison.cc | 54 +++++++++++++++++++++++++++++++-------- 2 files changed, 46 insertions(+), 11 deletions(-) diff --git a/src/abg-comparison-priv.h b/src/abg-comparison-priv.h index 481fc9c6..9802e78f 100644 --- a/src/abg-comparison-priv.h +++ b/src/abg-comparison-priv.h @@ -1159,6 +1159,9 @@ struct corpus_diff::priv size_t &num_filtered_removed, size_t &num_filtered_changed); + const string_diff_sptr_map& + changed_unreachable_types() const; + const vector& changed_unreachable_types_sorted() const; diff --git a/src/abg-comparison.cc b/src/abg-comparison.cc index 1cfc0952..1207729c 100644 --- a/src/abg-comparison.cc +++ b/src/abg-comparison.cc @@ -10129,6 +10129,14 @@ corpus_diff::priv::count_unreachable_types(size_t &num_added, ++num_filtered_changed; } +/// Get the map of diff nodes representing changed unreachable types. +/// +/// @return the map of diff nodes representing changed unreachable +/// types. +const string_diff_sptr_map& +corpus_diff::priv::changed_unreachable_types() const +{return changed_unreachable_types_;} + /// Get the sorted vector of diff nodes representing changed /// unreachable types. /// @@ -10239,14 +10247,11 @@ corpus_diff::priv::apply_filters_and_compute_diff_stats(diff_stats& stat) // walk the changed unreachable types to apply categorization // filters - for (diff_sptrs_type::const_iterator i = - changed_unreachable_types_sorted().begin(); - i != changed_unreachable_types_sorted().end(); - ++i) - { - diff_sptr diff = *i; - ctxt->maybe_apply_filters(diff); - } + for (auto& diff : changed_unreachable_types_sorted()) + ctxt->maybe_apply_filters(diff); + + for (auto& entry : changed_unreachable_types()) + ctxt->maybe_apply_filters(entry.second); if (get_context()->do_log()) { @@ -11194,7 +11199,8 @@ corpus_diff::has_incompatible_changes() const const diff_stats& stats = const_cast(this)-> apply_filters_and_suppressions_before_reporting(); - return (soname_changed() || architecture_changed() + bool has_incompatible_changes = + (soname_changed() || architecture_changed() || stats.net_num_func_removed() != 0 || (stats.num_func_with_virtual_offset_changes() != 0 // If all reports about functions with sub-type changes @@ -11205,8 +11211,34 @@ corpus_diff::has_incompatible_changes() const || stats.net_num_vars_removed() != 0 || stats.net_num_removed_func_syms() != 0 || stats.net_num_removed_var_syms() != 0 - || stats.net_num_removed_unreachable_types() != 0 - || stats.net_num_changed_unreachable_types() != 0); + || stats.net_num_removed_unreachable_types() != 0); + + // If stats.net_num_changed_unreachable_types() != 0 then walk the + // corpus_diff::priv::changed_unreachable_types_, and see if there + // is one that is harmful by bitwise and-ing their category with + // abigail::comparison::get_default_harmful_categories_bitmap(). + if (!has_incompatible_changes + && stats.net_num_changed_unreachable_types()) + { + // The changed unreachable types can carry harmful changes. + // Let's figure if they actually do. + + diff_context_sptr ctxt = context(); + for (auto &entry : priv_->changed_unreachable_types()) + { + diff_sptr dif = entry.second; + + // Let's see if any of the categories of this diff node + // belong to the "harmful" ones. + if (dif->get_category() & get_default_harmful_categories_bitmap()) + { + has_incompatible_changes |= true; + break; + } + } + } + + return has_incompatible_changes; } /// Test if the current instance of @ref corpus_diff carries subtype