From patchwork Tue Jan 26 17:21:14 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dodji Seketeli X-Patchwork-Id: 41821 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 41C7E385802A; Tue, 26 Jan 2021 17:21:27 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 41C7E385802A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1611681687; bh=OSQyYsyQ33UBuG/wuqZEwUrH5C8jWyMhNC+hl9TcTZI=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Help: List-Subscribe:From:Reply-To:From; b=ulL2SAUP3kq3+Fegh9M2BIQJXQHmNluxMfumZQsgEKHBy05Nw81JT1tK2EYrgN1sP 1m2hJr+1la2P3jBf1bKSdsRSwXo+VOwncQzb4d9EFgxl3GDbMaatDkbchxOyJKZi8y gYaWm/p7G++XsCp3TOdUOXP65HjmcNZZHadq3tbA= 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 32345385802A for ; Tue, 26 Jan 2021 17:21:24 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 32345385802A Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-584-gGdJuVXuPFSrWBtvEztMzQ-1; Tue, 26 Jan 2021 12:21:20 -0500 X-MC-Unique: gGdJuVXuPFSrWBtvEztMzQ-1 Received: by mail-wm1-f70.google.com with SMTP id z188so1628584wme.1 for ; Tue, 26 Jan 2021 09:21:19 -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=OSQyYsyQ33UBuG/wuqZEwUrH5C8jWyMhNC+hl9TcTZI=; b=LwJ7/OBVfAFktDgpacxagAKiycKtWw1Pq8m6n+/G7AH8B6b+y0UF4K+tHw6Uogt3s3 7IcKGLi3AKy73+NASn6705hUwZwNeyJbI9XXa1W0reSOPc77DZZrSuFQcyp9KhFyOGjo rd/8ebQX6Lo+QMYqWlc7DrkgRpYLUut8CB7nuRYl0kBnwwcRoea6E9KejJv8kFsWdpVm 6Sh8LLAPVHdMxcE2MSXY9QXzw2C9LwDFBCknb0bZpeHesiBYDHE6TECOPSunscGwYIg9 RROW1BSXQ0Qipg8ej8fmm16eGPpiLoVqWPAtHQyVX7Axw0pRqfL5H/IOb+bFMOK41CSn 8Vyg== X-Gm-Message-State: AOAM5334Cr7mA3CcUMMNmGkJIQKWKHhksLrNcEGAx+abr5Gp1EdERJVC Kg2rAd9fVrb6oSRjVK2ad+UOFrtH/dZkDtAEzbU8iN4WuoDux+75zSS2QR1kaAam4qOw4ix4ZnC CjWfNGaON6sFEu0nzDEqkNiwoj3EZLlw0AlCIL7eSslvbAJ333ltuzWb3JQ37olWDCbIy X-Received: by 2002:a05:600c:19c8:: with SMTP id u8mr667312wmq.59.1611681678238; Tue, 26 Jan 2021 09:21:18 -0800 (PST) X-Google-Smtp-Source: ABdhPJxo9UCAUPx+j+DJm/fdZAKawx/hOLdr8gLWbSU3QWSa2xCTMLTXprj4qFC8N5XHGs/Va2olZQ== X-Received: by 2002:a05:600c:19c8:: with SMTP id u8mr667285wmq.59.1611681677858; Tue, 26 Jan 2021 09:21:17 -0800 (PST) Received: from localhost (91-166-131-65.subs.proxad.net. [91.166.131.65]) by smtp.gmail.com with ESMTPSA id d5sm25870796wrs.21.2021.01.26.09.21.16 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Jan 2021 09:21:16 -0800 (PST) Received: by localhost (Postfix, from userid 1000) id 117FD581CAC; Tue, 26 Jan 2021 18:21:14 +0100 (CET) To: libabigail@sourceware.org Subject: [PATCH] Bug 27232 - fedabipkgdiff fails on gawk from Fedora 33 Organization: Red Hat / France X-Operating-System: Fedora 34 X-URL: http://www.redhat.com Date: Tue, 26 Jan 2021 18:21:14 +0100 Message-ID: <87ft2nhawl.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.0 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_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, When running fedabipkgdiff on the gawk-5.1.0-2.fc33.aarch64.rpm package we get this error message: Error encountered while running fedabipkgdiff with error message: That is not a very useful error message to say the least. The issue is that abipkgdiff returns with an "unknown error" which is due to the fact that the gawk package contains a directory that is owned by root. As abipkgdiff tries to write temporary files into that directory, it fails to do so. The patch now writes the temporary ABIXML file into a sub-directory that is not owned the package where we should have write privileges. It also improves error reporting. * tools/abipkgdiff.cc (options::pkg{1,2}): Add new data members to store the packages to compare and have them available for the various functions that may need them down the road. (package::create_abi_file_path): Add new function. (compare_to_self): Use the new package::create_abi_file_path to create the path to the ABI file in a directory not owned by the package. That should increase our chances of having the rights to write that one. Make sure to emit error message when the comparison against self fails. ({compare_task, self_compare_task}::perform): During the process of comparison if an internal error happens, report it. Cleanup the existing reporting a little bit. (pkg_extraction_task::perform): Fix comment. * tests/data/test-diff-pkg/libxfce4ui-devel-4.12.1-8.fc27.ppc64-self-report-0.txt: Adjust. Signed-off-by: Dodji Seketeli Applied to master. --- ...evel-4.12.1-8.fc27.ppc64-self-report-0.txt | 4 +- tools/abipkgdiff.cc | 96 +++++++++++++------ 2 files changed, 67 insertions(+), 33 deletions(-) diff --git a/tests/data/test-diff-pkg/libxfce4ui-devel-4.12.1-8.fc27.ppc64-self-report-0.txt b/tests/data/test-diff-pkg/libxfce4ui-devel-4.12.1-8.fc27.ppc64-self-report-0.txt index 311aca77..61169111 100644 --- a/tests/data/test-diff-pkg/libxfce4ui-devel-4.12.1-8.fc27.ppc64-self-report-0.txt +++ b/tests/data/test-diff-pkg/libxfce4ui-devel-4.12.1-8.fc27.ppc64-self-report-0.txt @@ -1,4 +1,4 @@ abipkgdiff: Could not find alternate debug info file: ../../../../.dwz/libxfce4ui-4.12.1-8.fc27.ppc64 -==== Error happened during processing of libxfce4uiglade.so: ==== +==== Error happened during processing of 'libxfce4uiglade.so' ==== could not find alternate debug info -==== End of error for libxfce4uiglade.so ==== +==== End of error for 'libxfce4uiglade.so' ==== diff --git a/tools/abipkgdiff.cc b/tools/abipkgdiff.cc index c2badadb..05e180de 100644 --- a/tools/abipkgdiff.cc +++ b/tools/abipkgdiff.cc @@ -152,6 +152,10 @@ using abigail::xml_writer::create_write_context; using abigail::xml_writer::write_context_sptr; using abigail::xml_writer::write_corpus; +class package; + +/// Convenience typedef for a shared pointer to a @ref package. +typedef shared_ptr package_sptr; /// The options passed to the current program. class options @@ -202,6 +206,8 @@ public: vector suppression_paths; vector kabi_whitelist_paths; suppressions_type kabi_suppressions; + package_sptr pkg1; + package_sptr pkg2; options(const string& program_name) : prog_name(program_name), @@ -302,11 +308,6 @@ struct abi_diff } }; -class package; - -/// Convenience typedef for a shared pointer to a @ref package. -typedef shared_ptr package_sptr; - /// Abstracts a package. class package { @@ -649,6 +650,34 @@ public: sorted_strings_common_prefix(elf_file_paths(), common_paths_prefix()); } + /// Create the path of an ABI file to be associated with a given + /// binary. + /// + /// @param elf_file_path the path to the binary to consider. + /// + /// @param abi_file_path the resulting ABI file path. This is set + /// iff the function return true. + /// + /// @return true if the ABI file path could be constructed and the + /// directory tree containing it could be created. In that case, + /// the resulting ABI file path is set to the @p abi_file_path + /// output parameter. + bool + create_abi_file_path(const string &elf_file_path, + string &abi_file_path) const + { + string abi_path, dir, parent; + if (!abigail::tools_utils::string_suffix(elf_file_path, + extracted_dir_path(), + abi_path)) + return false; + abi_path = extracted_dir_path() + "/abixml" + abi_path + ".abi"; + if (!abigail::tools_utils::ensure_parent_dir_created(abi_path)) + return false; + abi_file_path = abi_path; + return true; + } + /// Erase the content of the temporary extraction directory that has /// been populated by the @ref extract_package() function; /// @@ -1547,10 +1576,16 @@ compare_to_self(const elf_file& elf, corpus_sptr reread_corp; string abi_file_path; { - abi_file_path = elf.path + ".abi"; + if (!opts.pkg1->create_abi_file_path(elf.path, abi_file_path)) + { + if (opts.verbose) + emit_prefix("abipkgdiff", cerr) + << "Could not create the directory tree to store the abi for '" + << elf.path + << "'\n"; + } ofstream of(abi_file_path.c_str(), std::ios_base::trunc); - { const abigail::xml_writer::write_context_sptr c = abigail::xml_writer::create_write_context(env.get(), of); @@ -1645,6 +1680,7 @@ compare_to_self(const elf_file& elf, << "Comparison against self " << (s == abigail::tools_utils::ABIDIFF_OK ? "SUCCEEDED" : "FAILED") << '\n'; + return s; } @@ -1887,8 +1923,8 @@ public: {} /// The job performed by the current task, which is to extract its - /// packages in sequence. This is job is to be performed in - /// parallel with other jobs of other tasks. + /// packages in sequence. This job is to be performed in parallel + /// with other jobs of other tasks. virtual void perform() { @@ -1996,19 +2032,16 @@ public: { string diagnostic = abigail::dwarf_reader::status_to_diagnostic_string(detailed_status); + if (diagnostic.empty()) + diagnostic = + "Unknown error. Please run the tool again with --verbose\n"; - if (!diagnostic.empty()) - { - string name = args->elf1.name; - - pretty_output += - "==== Error happened during processing of " + name + ": ====\n"; - - pretty_output += diagnostic; - - pretty_output += - "==== End of error for " + name + " ====\n"; - } + string name = args->elf1.name; + pretty_output += + "==== Error happened during processing of '" + name + "' ====\n"; + pretty_output += diagnostic; + pretty_output += + "==== End of error for '" + name + "' ====\n"; } } }; // end class compare_task @@ -2066,18 +2099,17 @@ public: string diagnostic = abigail::dwarf_reader::status_to_diagnostic_string(detailed_status); - if (!diagnostic.empty()) - { - string name = args->elf1.name; - - pretty_output += - "==== Error happened during self check of " + name + ": ====\n"; + if (diagnostic.empty()) + diagnostic = + "Unknown error. Please run the tool again with --verbose\n"; - pretty_output += diagnostic; + string name = args->elf1.name; + pretty_output += + "==== Error happened during self check of '" + name + "' ====\n"; + pretty_output += diagnostic; + pretty_output += + "==== SELF CHECK FAILED for '" + name + "' ====\n"; - pretty_output += - "==== SELF CHECK FAILED for " + name + " ====\n"; - } } } }; // end class self_compare @@ -3430,6 +3462,8 @@ main(int argc, char* argv[]) package_sptr first_package(new package(opts.package1, "package1")); package_sptr second_package(new package(opts.package2, "package2")); + opts.pkg1 = first_package; + opts.pkg2 = second_package; for (vector::const_iterator p = opts.debug_packages1.begin(); p != opts.debug_packages1.end();