From patchwork Tue Jan 26 03:54:13 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dodji Seketeli X-Patchwork-Id: 41816 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 59FFE3851C2E; Tue, 26 Jan 2021 03:54:23 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 59FFE3851C2E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1611633263; bh=FOMSuRw/cInTvUzv4iaQbJuxlZxqFs3dEUGmTphg5Xs=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Help: List-Subscribe:From:Reply-To:From; b=Vw+9hYDYVEzERbeI+73X9mI+/6Gy/tbM2t691CQ+6HnGSZk2oKYj5bg/qcUqTIhBa uwkH9ZHZn42hfwyY16YaIddWhXJcn3tyCKVJty2ZmR8Xx4FpwuqmHI2fQDH/kTaHv2 6uriN+RG0omy+akxEilNmO7rLWng3xqlhDk2vZI4= 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 [63.128.21.124]) by sourceware.org (Postfix) with ESMTP id 210C23851C2E for ; Tue, 26 Jan 2021 03:54:20 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 210C23851C2E Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-600-SjMbmWWOMRSuNYPmIHh5KA-1; Mon, 25 Jan 2021 22:54:18 -0500 X-MC-Unique: SjMbmWWOMRSuNYPmIHh5KA-1 Received: by mail-wm1-f72.google.com with SMTP id x20so912647wmc.0 for ; Mon, 25 Jan 2021 19:54:17 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:organization:date:message-id :user-agent:mime-version; bh=FOMSuRw/cInTvUzv4iaQbJuxlZxqFs3dEUGmTphg5Xs=; b=H+KTp/X+rq1V/LF9/9UIEKP+XSVy/Ck52LWaxyXt28SvVFyAN1Sy5b99XBQgeO+4oE EFNwVXempS/85ATWQW5HMH/OzyrJR6qwfR4lzrLdWSUBn5PDd1BGeOzC+2THAUUzMBlY PbKhWvh+Ut57RJS6aen1/gdHnVXPylbSWRGtKIfwJDqftt3DzF0zKeHBKWrNDNRGmkwJ Z9mljohtvWF1LK1ZY21+ndiEXPPehYZEYPLauiNVe2rLzytcOQIP4KMkAWNU5IeiJxxr N0jN4DyUbcW6g9cBYjIiF7nXSU4pB8b8e/bPGFNhaOexVLsoGrxA7yr/cI8qtXtPLXPb fFJQ== X-Gm-Message-State: AOAM533MYu0rwO6GP2EWWqK2igBo6w+stMlWvyINYBjCPsudBNq6kylX /GNd9F68FbA0NMl046ZhaR1nB6zSYO9C96t0eFfvdxgVdyDU4Y8Q8yEddiXQIGxcSe/Sit2/+b9 KlSWn67Gfs4QBEFXdhg9TAO776NLQ/2Wm0zhMNSdpMpztw7Yl/s9i9fRQ8yPVYkMB3fDj X-Received: by 2002:a1c:9ad5:: with SMTP id c204mr2785238wme.65.1611633256585; Mon, 25 Jan 2021 19:54:16 -0800 (PST) X-Google-Smtp-Source: ABdhPJz4EmX4m/bzSoXAxiFe2yXAiKHnu0uMskrU+3jsCP/V+iedzKrv1P532vR1hyDn9FDmclIyhQ== X-Received: by 2002:a1c:9ad5:: with SMTP id c204mr2785218wme.65.1611633256199; Mon, 25 Jan 2021 19:54:16 -0800 (PST) Received: from localhost (91-166-131-65.subs.proxad.net. [91.166.131.65]) by smtp.gmail.com with ESMTPSA id o13sm26869178wrh.88.2021.01.25.19.54.14 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Jan 2021 19:54:15 -0800 (PST) Received: by localhost (Postfix, from userid 1000) id A3900581CAC; Tue, 26 Jan 2021 04:54:13 +0100 (CET) To: libabigail@sourceware.org Subject: [PATCH] Bug 27236 - Pointer comparison wrongly fails because of typedef change Organization: Red Hat / France X-Operating-System: Fedora 34 X-URL: http://www.redhat.com Date: Tue, 26 Jan 2021 04:54:13 +0100 Message-ID: <87sg6ogxp6.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.2 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_LOW, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) 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@sourceware.org Sender: "Libabigail" Hello, Suppose we have a type struct S and a type T defined as: typedef struct S T; Today, Libabigail considers that the two pointers "struct S*" and "T*" are different. The problem is that this can cause spurious change reports (as reported by (abidw --abidiff) in binaries where we have the same type defined more than once, each time using a different various around this theme. This patch make libabigail to now consider that "struct S*" and "T*" are equal. It does the same for references and arrays. * src/abg-ir.cc (equals): In the overloads for pointer_type_def, reference_type_def and array_type_def, compare the pointed-to-type modulo typedefs. * tests/data/test-diff-dwarf/test42-PR21296-clanggcc-report0.txt: Adjust. * tests/data/test-diff-pkg/libICE-1.0.6-1.el6.x86_64.rpm--libICE-1.0.9-2.el7.x86_64.rpm-report-0.txt: Adjust. * tests/data/test-diff-pkg/spice-server-0.12.4-19.el7.x86_64-0.12.8-1.el7.x86_64-report-2.txt: Adjust. Signed-off-by: Dodji Seketeli Applied to master. --- src/abg-ir.cc | 12 +++++++++--- .../test42-PR21296-clanggcc-report0.txt | 2 -- ...4.rpm--libICE-1.0.9-2.el7.x86_64.rpm-report-0.txt | 2 +- ....4-19.el7.x86_64-0.12.8-1.el7.x86_64-report-2.txt | 11 +---------- 4 files changed, 11 insertions(+), 16 deletions(-) diff --git a/src/abg-ir.cc b/src/abg-ir.cc index 51e0c131..6d7a60a6 100644 --- a/src/abg-ir.cc +++ b/src/abg-ir.cc @@ -14101,7 +14101,9 @@ pointer_type_def::pointer_type_def(const type_base_sptr& pointed_to, bool equals(const pointer_type_def& l, const pointer_type_def& r, change_kind* k) { - bool result = (l.get_pointed_to_type() == r.get_pointed_to_type()); + // Compare the pointed-to-types modulo the typedefs they might have + bool result = (peel_typedef_type(l.get_pointed_to_type()) + == peel_typedef_type(r.get_pointed_to_type())); if (!result) if (k) { @@ -14406,7 +14408,9 @@ equals(const reference_type_def& l, const reference_type_def& r, change_kind* k) return false; } - bool result = (l.get_pointed_to_type() == r.get_pointed_to_type()); + // Compare the pointed-to-types modulo the typedefs they might have + bool result = (peel_typedef_type(l.get_pointed_to_type()) + == (peel_typedef_type(r.get_pointed_to_type()))); if (!result) if (k) { @@ -15226,7 +15230,9 @@ equals(const array_type_def& l, const array_type_def& r, change_kind* k) return false; } - if (l.get_element_type() != r.get_element_type()) + // Compare the element types modulo the typedefs they might have + if (peel_typedef_type(l.get_element_type()) + != peel_typedef_type(r.get_element_type())) { result = false; if (k) diff --git a/tests/data/test-diff-dwarf/test42-PR21296-clanggcc-report0.txt b/tests/data/test-diff-dwarf/test42-PR21296-clanggcc-report0.txt index 41114db3..61491027 100644 --- a/tests/data/test-diff-dwarf/test42-PR21296-clanggcc-report0.txt +++ b/tests/data/test-diff-dwarf/test42-PR21296-clanggcc-report0.txt @@ -55,8 +55,6 @@ Variables changes summary: 0 Removed, 0 Changed, 0 Added variable [C] 'function std::remove_reference::type&& std::move(STR&)' has some indirect sub-type changes: 'function std::remove_reference::type&& std::move(STR&) {_ZSt4moveIR3STREONSt16remove_referenceIT_E4typeEOS3_}' now becomes 'function std::remove_reference::type&& std::move(STR&) {_ZSt4moveIR3STREONSt16remove_referenceIT_E4typeEOS3_}' return type changed: - in referenced type 'typedef std::remove_reference::type': - typedef name changed from std::remove_reference::type to std::remove_reference::type [C] 'function void tpl >(std::tuple)' has some indirect sub-type changes: 'function void tpl >(std::tuple) {_Z3tplISt5tupleIJO3STREEEvT_}' now becomes 'function void tpl >(std::tuple) {_Z3tplISt5tupleIJO3STREEEvT_}' diff --git a/tests/data/test-diff-pkg/libICE-1.0.6-1.el6.x86_64.rpm--libICE-1.0.9-2.el7.x86_64.rpm-report-0.txt b/tests/data/test-diff-pkg/libICE-1.0.6-1.el6.x86_64.rpm--libICE-1.0.9-2.el7.x86_64.rpm-report-0.txt index 59202ee4..2172e1c4 100644 --- a/tests/data/test-diff-pkg/libICE-1.0.6-1.el6.x86_64.rpm--libICE-1.0.9-2.el7.x86_64.rpm-report-0.txt +++ b/tests/data/test-diff-pkg/libICE-1.0.6-1.el6.x86_64.rpm--libICE-1.0.9-2.el7.x86_64.rpm-report-0.txt @@ -15,7 +15,7 @@ underlying type '_IceConn*' changed: in pointed to type 'struct _IceConn' at ICEconn.h:131:1: type size hasn't changed - 2 data member changes (3 filtered): + 2 data member changes (2 filtered): type of 'IceListenObj _IceConn::listen_obj' changed: underlying type '_IceListenObj*' changed: in pointed to type 'struct _IceListenObj' at ICElibint.h:120:1: diff --git a/tests/data/test-diff-pkg/spice-server-0.12.4-19.el7.x86_64-0.12.8-1.el7.x86_64-report-2.txt b/tests/data/test-diff-pkg/spice-server-0.12.4-19.el7.x86_64-0.12.8-1.el7.x86_64-report-2.txt index 550ef6f3..5463d5e1 100644 --- a/tests/data/test-diff-pkg/spice-server-0.12.4-19.el7.x86_64-0.12.8-1.el7.x86_64-report-2.txt +++ b/tests/data/test-diff-pkg/spice-server-0.12.4-19.el7.x86_64-0.12.8-1.el7.x86_64-report-2.txt @@ -303,16 +303,7 @@ type of 'CommonChannel CursorChannel::common' changed, as reported earlier type of 'QXLInstance* RedWorker::qxl' changed: in pointed to type 'typedef QXLInstance' at spice-qxl.h:34:1: - underlying type 'struct QXLInstance' at spice.h:259:1 changed: - type size hasn't changed - 1 data member change: - type of 'QXLState* QXLInstance::st' changed: - in pointed to type 'typedef QXLState' at spice-qxl.h:35:1: - underlying type 'struct QXLState' at reds.h:93:1 changed: - type size hasn't changed - 1 data member change: - type of 'RedDispatcher* QXLState::dispatcher' changed: - pointed to type 'struct RedDispatcher' changed, as being reported + underlying type 'struct QXLInstance' changed, as being reported type of 'RedDispatcher* RedWorker::red_dispatcher' changed: in pointed to type 'typedef RedDispatcher': entity changed from 'typedef RedDispatcher' to compatible type 'struct RedDispatcher'