From patchwork Wed Oct 20 14:25:36 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dodji Seketeli X-Patchwork-Id: 46442 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 AB372385800B for ; Wed, 20 Oct 2021 14:25:47 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org AB372385800B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1634739947; bh=1wn+176YqPQiEXCrRiNiWMM776kf3KHWCziYAt+kYPo=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Help: List-Subscribe:From:Reply-To:From; b=ZGRYITaefs76irCnHX7EqJgIpqLHd3odIKpozjr10a4irvZd2YhZ0a52+GD3sR1c6 /OpAypF2bnSmmaOxPtsbwPrcrVchEtjXESXKuDglqDIRW1gRbXaowJW4H2m0kf5FA3 UQtFBePmst1kBlYRq6Bl3hFj9gb8nYkPHZ/A1XYk= 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 4A8143858412 for ; Wed, 20 Oct 2021 14:25:42 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 4A8143858412 Received: from mail-qt1-f199.google.com (mail-qt1-f199.google.com [209.85.160.199]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-27-bcPyLiuANRqngvTWuH-7kw-1; Wed, 20 Oct 2021 10:25:40 -0400 X-MC-Unique: bcPyLiuANRqngvTWuH-7kw-1 Received: by mail-qt1-f199.google.com with SMTP id 100-20020aed30ed000000b002a6b3dc6465so2211276qtf.13 for ; Wed, 20 Oct 2021 07:25:40 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:organization:date:message-id :user-agent:mime-version; bh=1wn+176YqPQiEXCrRiNiWMM776kf3KHWCziYAt+kYPo=; b=JcGh40NVqxN3Yu5hqtclAkeW5B3c7Y0CS4xbVmSKwWXFiRFM043doC93JC2YpWEjmg OHegvn5qhI4ojS6yjl79s8DWXOlWRA876pV7qdtJNMiF8pAdmnuHXO/FE2fIDAEEzcgL +E7zUIUQwLoYqbcdhwI+4C0CkJVkWJiOkD/JDy5GpSs5k50NvHC0z6VvcQCd+TX0jRo6 fizIK/KrlWsgCFqqM2oaVhuEfshagD6KG/gK0AYGafuQE+3FoAVENNW6LRNFRcpLD64d YJJCogYSooPMFj7aNGy116n9OOKN6kufPnXwYoxVhvKA3DvoL9qxadRUhIAl3KwYsJwo U/lw== X-Gm-Message-State: AOAM532H0pQwEN6bM5xHuRWJ8upvFfZZiOqQCOeUSBXwV0Ah5lh15uDT bpcUDDjHUB2JPplL7ev2/uY3foxvyCUdIxqEWnTskywEunvNDVDs4x6DIloxmeIEYjoAMBtC/Y+ cVfRCYQpHph7uRQcOFw9oZOLzLSJJoHivCeqjb0Iaw1w7DN1QIxQaAOwPU3ezld2e8KDL X-Received: by 2002:a37:a93:: with SMTP id 141mr251016qkk.443.1634739939889; Wed, 20 Oct 2021 07:25:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzsbT0a+ZLNV0AViJ9czePRK0Z8dMaPBZ97U9ak1/r7R/7iJIXh7E+UQlilVV1KwhotClRI5A== X-Received: by 2002:a37:a93:: with SMTP id 141mr250982qkk.443.1634739939488; Wed, 20 Oct 2021 07:25:39 -0700 (PDT) Received: from localhost ([88.120.130.27]) by smtp.gmail.com with ESMTPSA id w185sm1081714qkd.30.2021.10.20.07.25.38 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Oct 2021 07:25:38 -0700 (PDT) Received: by localhost (Postfix, from userid 1000) id EE4455802BD; Wed, 20 Oct 2021 16:25:36 +0200 (CEST) To: libabigail@sourceware.org Subject: [PATCH, applied] PR28365 - Assert on empty typedef on webkit2gtk3-jsc-2.32.3-1.fc34.x86_64 Organization: Red Hat / France X-Operating-System: Fedora 36 X-URL: http://www.redhat.com Date: Wed, 20 Oct 2021 16:25:36 +0200 Message-ID: <87pmrzai3j.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, KAM_NUMSUBJECT, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) 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 doing self-comparison check of /usr/lib64/libjavascriptcoregtk-4.0.so.18.18.7 from webkit2gtk3-jsc-2.32.3-1.fc34.x86_64, reading back the abixml file fails because an empty typedef is used as the element type of an array. The empty typedef is there (in a transient manner) because the typedef is being built. First an empty typedef is built and then its underlying type is built. During the construction of the underlying type however (an enum), the empty typedef itself is used (as the naming typedef of the enum). But because its empty, an assert is violated during the construction of an array which element type is the (empty) typedef. A snake eating its own (half-baked) tail, so to speak. The patch fixes the issue by constructing the underlying (enum) type first. Once its constructed, then it's used to construct the typedef which is thus never empty, even in a transient manner. The patch adjusts the building of enums so that the naming typedef is built only once the enum itself is fully constructed. This breaks the vicious cycle exposed above. The offending RPM is too big to be added to the test suite. Which argues (yet again) for the implementation of a separate test suite that runs libabigail tests on a huge pile of RPMs without having to embed them in the tarball. We really ought to start that project. * src/abg-reader.cc (build_enum_type_decl): Set the naming typedef only after the enum is created and keyed. (build_typedef_decl): Build the underlying type of the typedef first. Signed-off-by: Dodji Seketeli Applied to master --- src/abg-reader.cc | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/src/abg-reader.cc b/src/abg-reader.cc index 712b0c1a..bf08b2e7 100644 --- a/src/abg-reader.cc +++ b/src/abg-reader.cc @@ -4470,9 +4470,9 @@ build_enum_type_decl(read_context& ctxt, t->set_is_anonymous(is_anonymous); t->set_is_artificial(is_artificial); t->set_is_declaration_only(is_decl_only); - maybe_set_naming_typedef(ctxt, node, t); if (ctxt.push_and_key_type_decl(t, id, add_to_current_scope)) { + maybe_set_naming_typedef(ctxt, node, t); ctxt.map_xml_node_to_decl(node, t); return t; } @@ -4529,19 +4529,14 @@ build_typedef_decl(read_context& ctxt, type_id = CHAR_STR(s); ABG_ASSERT(!type_id.empty()); - // Create the typedef type /before/ the underlying type. After the - // creation, the type is 'keyed' using ctxt.push_and_key_type_decl. - // This means that the type can be retrieved from its type ID. This - // is so that if the underlying type indirectly (needs to) use(s) - // this very same typedef type (via recursion) then that is made - // possible. - typedef_decl_sptr t(new typedef_decl(name, ctxt.get_environment(), loc)); + type_base_sptr underlying_type(ctxt.build_or_get_type_decl(type_id, true)); + ABG_ASSERT(underlying_type); + + typedef_decl_sptr t(new typedef_decl(name, underlying_type, loc)); maybe_set_artificial_location(ctxt, node, t); ctxt.push_and_key_type_decl(t, id, add_to_current_scope); ctxt.map_xml_node_to_decl(node, t); - type_base_sptr underlying_type(ctxt.build_or_get_type_decl(type_id, true)); - ABG_ASSERT(underlying_type); - t->set_underlying_type(underlying_type); + return t; }