From patchwork Thu Dec 29 11:21:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dodji Seketeli X-Patchwork-Id: 62475 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 439FE3858C2C for ; Thu, 29 Dec 2022 11:21:13 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 439FE3858C2C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1672312873; bh=Vw8IotXSe63m/9qwc9AlUqbwscj5tLEjdMw2I7C6U6E=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Help: List-Subscribe:From:Reply-To:From; b=V+U22VL6j1IRXu7XxbPk6WuAK+PgD1JEHzuwhZSXfkxuKs1ja6IUJUYkHPTfPDUR9 uI5OEcuMBfxDBldii62yaWlgG4eCQvx/Bj2acSjciH+nkh9ANMd2kPZjPU4d0pyacc EzjqM/b+AbY91+dFF0kErMnzeLNu6+8Yf1M2MaRo= 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.133.124]) by sourceware.org (Postfix) with ESMTPS id EBF323858D35 for ; Thu, 29 Dec 2022 11:21:07 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org EBF323858D35 Received: from mail-qk1-f199.google.com (mail-qk1-f199.google.com [209.85.222.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-414-6TbYaDKmNPWb15bBzJOu4A-1; Thu, 29 Dec 2022 06:21:06 -0500 X-MC-Unique: 6TbYaDKmNPWb15bBzJOu4A-1 Received: by mail-qk1-f199.google.com with SMTP id az39-20020a05620a172700b006ff85c3b19eso12719986qkb.18 for ; Thu, 29 Dec 2022 03:21:06 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=Vw8IotXSe63m/9qwc9AlUqbwscj5tLEjdMw2I7C6U6E=; b=DIRgv1zpkXqCAhqqY7dWfqh2B+HBPqEvYJ6gvQ7QuP+qSuZp6Ar0XV+cSbawRhqb06 33U0+0/yzUqCq5rtWMUMuAt7xJkKsI5EJCuSTC5BqqGwlFVAxC/89es4nSFXSIEh4hji dkrVTmfZgf643l4Sb+XfjGyZHwbZXRv6ut+tTD8pqlZzwb5Zsqgn8rYcxXIm2cmDbI5A nqRgYfi7dfCjK6sqjt9M984f85M8pKaCbeS3nRXh3oueEoyc0dqbkpW14tYkT0ypnTN8 Y+y/BYqN5+9pWBG/+hweDmTQXN8aDxizo+azQeFKG2QOQW3HcykmQ+mtgWzaapajcL+D 1o+A== X-Gm-Message-State: AFqh2kpSdGFQ4PQbsPVZT3ZUaw9viD99pP5AVCYeiP2gK3EsVpR8vcre +xVOSeKTlbZD37CLKHjUC5vcHyyGfHN4DDlam+pBju0eM+g7gr1rQqEY/RwlwlLSdVHCmJTuZa8 T5Bkv3kl4y/FXgjLgji3uFXCBtaPcypobX9cyehp2tyFRktJwqzrKL/AdwJaRAnvN4LA4 X-Received: by 2002:a0c:e6c2:0:b0:4d7:45fb:f5ac with SMTP id l2-20020a0ce6c2000000b004d745fbf5acmr33173524qvn.23.1672312865883; Thu, 29 Dec 2022 03:21:05 -0800 (PST) X-Google-Smtp-Source: AMrXdXtUqcOU7WRUAVjpfijr4LXXSJh9e1IXMHLAaqmFFW/+J+gIPiMIEcHF+6MRRwyOZ9xL85E+Jw== X-Received: by 2002:a0c:e6c2:0:b0:4d7:45fb:f5ac with SMTP id l2-20020a0ce6c2000000b004d745fbf5acmr33173504qvn.23.1672312865562; Thu, 29 Dec 2022 03:21:05 -0800 (PST) Received: from localhost ([88.120.130.27]) by smtp.gmail.com with ESMTPSA id az10-20020a05620a170a00b006fbbdc6c68fsm12853526qkb.68.2022.12.29.03.21.05 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Dec 2022 03:21:05 -0800 (PST) Received: by localhost (Postfix, from userid 1000) id 49A88A2E7E; Thu, 29 Dec 2022 12:21:01 +0100 (CET) To: libabigail@sourceware.org Subject: [PATCH, applied] ir: Bug 29934 - Fix propagated canonical type confirmation Organization: Red Hat / France X-Operating-System: CentOS Stream release 9 X-URL: http://www.redhat.com Date: Thu, 29 Dec 2022 12:21:01 +0100 Message-ID: <878riqbgma.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.6 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, When canonicalization a type T, it can happen that one subtype S of T compares equal to a type S' where S' is already canonicalized. In that case, we can deduce that the canonical type of S equals the canonical type of S', even if we are currently in the process of canonicalizing T. In other words, the canonical type of S' is "propagated to S", in the process of canonicalizing T. This optimization is called "canonical type propagation" and is meant to spead up the overall canonicalization process. However, in some cases, the propagated canonical type can be "cancelled" for the optimization to be correct. In those cases, the propagated canonical type is set to nil. When analysing the binary libdovecot-sieve.so from the problem reported at https://sourceware.org/bugzilla/show_bug.cgi?id=29934, we encounter a case where a function type's propagated type is erroneously cancelled. That leaves the canonical type of that function type not set and that later violates the assert ABG_ASSERT(is_non_canonicalized_type(t)) in abigail::ir::hash_as_canonical_type_or_constant. I tracked this down to return_comparison_result which fails to confirm a case of propagated canonical type and thus, some of them can end up being erroneously cancelled. Fixed thus. * src/abg-ir.cc (return_comparison_result): A type whose canonical type has been propagated must have its canonical type confirmed if that type is not recursive and is not dependant on any recursive type. In that case, the canonical type will never be cancelled. Signed-off-by: Dodji Seketeli --- src/abg-ir.cc | 31 +++++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/src/abg-ir.cc b/src/abg-ir.cc index 08fc3ad0..f32e8d1f 100644 --- a/src/abg-ir.cc +++ b/src/abg-ir.cc @@ -1040,15 +1040,30 @@ return_comparison_result(T& l, T& r, bool value, // eventually fails. env.priv_->add_to_types_with_non_confirmed_propagated_ct(is_type(&r)); } - else if (value == true && env.priv_->right_type_comp_operands_.empty()) + else if (value == true + && (// The type is neither recursive nor dependant on a + // recursive type ... + (!env.priv_->is_recursive_type(&r) + && !is_type(&r)->priv_->depends_on_recursive_type() + && is_type(&r)->priv_->canonical_type_propagated() + && !is_type(&r)->priv_->propagated_canonical_type_confirmed()) + || + // ... or the comparison stack is empty, meaning, + // comparing r & l is completely done. + env.priv_->right_type_comp_operands_.empty())) { - // The type provided in the 'r' argument is the type that is - // being canonicalized; 'r' is not a mere subtype being - // compared, it's the whole type being canonicalized. And - // its canonicalization has just succeeded. So let's - // confirm the "canonical type propagation" of all the - // sub-types that were compared during the comparison of - // 'r'. + // Either: + // + // A/ 'r' is neither recursive nor dependant on a + // recursive type + // + // B/ Or the type provided in the 'r' argument is the type + // that is being canonicalized; 'r' is not a mere subtype + // being compared, it's the whole type being canonicalized. + // And its canonicalization has just succeeded. + // + // In both cases, let's confirm the canonical type resulting + // from the "canonical type propagation" optimization. env.priv_->confirm_ct_propagation(&r); } else if (value == false)