Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package kcrash for openSUSE:Factory checked in at 2021-08-16 10:07:39 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/kcrash (Old) and /work/SRC/openSUSE:Factory/.kcrash.new.1899 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "kcrash" Mon Aug 16 10:07:39 2021 rev:94 rq:912121 version:5.85.0 Changes: -------- --- /work/SRC/openSUSE:Factory/kcrash/kcrash.changes 2021-07-16 00:01:07.869209484 +0200 +++ /work/SRC/openSUSE:Factory/.kcrash.new.1899/kcrash.changes 2021-08-16 10:11:34.607099155 +0200 @@ -1,0 +2,11 @@ +Fri Aug 6 12:11:52 UTC 2021 - Christophe Giboudeaux <[email protected]> + +- Update to 5.85.0 + * New feature release + * For more details please see: + * https://kde.org/announcements/frameworks/5/5.85.0 +- Changes since 5.84.0: + * Support static builds + * fix lifetime of MetadataINIWriter + +------------------------------------------------------------------- Old: ---- kcrash-5.84.0.tar.xz kcrash-5.84.0.tar.xz.sig New: ---- kcrash-5.85.0.tar.xz kcrash-5.85.0.tar.xz.sig ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ kcrash.spec ++++++ --- /var/tmp/diff_new_pack.QYTjYx/_old 2021-08-16 10:11:35.231098423 +0200 +++ /var/tmp/diff_new_pack.QYTjYx/_new 2021-08-16 10:11:35.235098418 +0200 @@ -17,7 +17,7 @@ %define lname libKF5Crash5 -%define _tar_path 5.84 +%define _tar_path 5.85 # Full KF5 version (e.g. 5.33.0) %{!?_kf5_version: %global _kf5_version %{version}} # Last major and minor KF5 version (e.g. 5.33) @@ -25,7 +25,7 @@ # Only needed for the package signature condition %bcond_without lang Name: kcrash -Version: 5.84.0 +Version: 5.85.0 Release: 0 Summary: An application crash handler License: LGPL-2.1-or-later ++++++ kcrash-5.84.0.tar.xz -> kcrash-5.85.0.tar.xz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kcrash-5.84.0/CMakeLists.txt new/kcrash-5.85.0/CMakeLists.txt --- old/kcrash-5.84.0/CMakeLists.txt 2021-07-02 23:59:35.000000000 +0200 +++ new/kcrash-5.85.0/CMakeLists.txt 2021-07-28 03:04:39.000000000 +0200 @@ -1,11 +1,11 @@ cmake_minimum_required(VERSION 3.16) -set(KF_VERSION "5.84.0") # handled by release scripts -set(KF_DEP_VERSION "5.84.0") # handled by release scripts +set(KF_VERSION "5.85.0") # handled by release scripts +set(KF_DEP_VERSION "5.85.0") # handled by release scripts project(KCrash VERSION ${KF_VERSION}) include(FeatureSummary) -find_package(ECM 5.84.0 NO_MODULE) +find_package(ECM 5.85.0 NO_MODULE) set_package_properties(ECM PROPERTIES TYPE REQUIRED DESCRIPTION "Extra CMake Modules." URL "https://commits.kde.org/extra-cmake-modules") feature_summary(WHAT REQUIRED_PACKAGES_NOT_FOUND FATAL_ON_MISSING_REQUIRED_PACKAGES) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kcrash-5.84.0/KF5CrashConfig.cmake.in new/kcrash-5.85.0/KF5CrashConfig.cmake.in --- old/kcrash-5.84.0/KF5CrashConfig.cmake.in 2021-07-02 23:59:35.000000000 +0200 +++ new/kcrash-5.85.0/KF5CrashConfig.cmake.in 2021-07-28 03:04:39.000000000 +0200 @@ -5,6 +5,14 @@ include(CMakeFindDependencyMacro) find_dependency(Qt5Core @REQUIRED_QT_VERSION@) +if (NOT @BUILD_SHARED_LIBS@) + find_dependency(KF5CoreAddons REQUIRED) + find_dependency(KF5WindowSystem REQUIRED) + + if (@X11_FOUND@) + find_dependency(Qt5X11Extras REQUIRED) + endif() +endif() include("${CMAKE_CURRENT_LIST_DIR}/KF5CrashTargets.cmake") @PACKAGE_INCLUDE_QCHTARGETS@ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kcrash-5.84.0/autotests/metadatatest.cpp new/kcrash-5.85.0/autotests/metadatatest.cpp --- old/kcrash-5.84.0/autotests/metadatatest.cpp 2021-07-02 23:59:35.000000000 +0200 +++ new/kcrash-5.85.0/autotests/metadatatest.cpp 2021-07-28 03:04:39.000000000 +0200 @@ -24,13 +24,14 @@ MetadataINIWriter iniWriter(iniFile.toLocal8Bit()); writer = &iniWriter; #endif - Metadata data("BEFEHL", writer); + Metadata data("BEFEHL"); + data.setAdditionalWriter(writer); data.add("--ABC", "FOO"); data.addBool("--Meow"); data.close(); const int argc = data.argc; QCOMPARE(argc, 4); - QCOMPARE(data.argv.at(0), QStringLiteral("BEFEHL")); // make sure we do stringy comparision + QCOMPARE(data.argv.at(0), QStringLiteral("BEFEHL")); // make sure we do stringy comparison QCOMPARE(data.argv.at(1), QStringLiteral("--ABC")); QCOMPARE(data.argv.at(2), QStringLiteral("FOO")); QCOMPARE(data.argv.at(3), QStringLiteral("--Meow")); @@ -50,7 +51,7 @@ void testNoFile() { // Doesn't explode without writer - Metadata data("BEFEHL", nullptr); + Metadata data("BEFEHL"); data.add("--ABC", "FOO"); data.close(); const int argc = data.argc; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kcrash-5.84.0/src/kcrash.cpp new/kcrash-5.85.0/src/kcrash.cpp --- old/kcrash-5.84.0/src/kcrash.cpp 2021-07-02 23:59:35.000000000 +0200 +++ new/kcrash-5.85.0/src/kcrash.cpp 2021-07-28 03:04:39.000000000 +0200 @@ -467,18 +467,20 @@ // If someone is telling me to stop while I'm already crashing, then I should resume crashing signal(SIGTERM, &crashOnSigTerm); - // NB: metadata writing ought to happen before closing FDs to reduce synchronization problems with dbus. - MetadataWriter *writer = nullptr; + // NB: all metadata writing ought to happen before closing FDs to reduce synchronization problems with dbus. + + // WARNING: do not forget to increase Metadata::argv's size when adding more potential arguments! + Metadata data(s_drkonqiPath.get()); #ifdef Q_OS_LINUX - if (!s_metadataPath.isEmpty()) { - MetadataINIWriter ini(s_metadataPath); - // Add the canonical exe path so the coredump daemon has more data points to map metdata to journald entry. + // The ini is required to be scoped here, as opposed to the conditional scope, so its lifetime is the same as + // the regular data instance! + MetadataINIWriter ini(s_metadataPath); + if (ini.isWritable()) { + // Add the canonical exe path so the coredump daemon has more data points to map metadata to journald entry. ini.add("--exe", s_appFilePath.get(), MetadataWriter::BoolValue::No); - writer = &ini; + data.setAdditionalWriter(&ini); } #endif - // WARNING: do not forget to increase Metadata::argv's size when adding more potential arguments! - Metadata data(s_drkonqiPath.get(), writer); const QByteArray platformName = QGuiApplication::platformName().toUtf8(); if (!platformName.isEmpty()) { diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kcrash-5.84.0/src/metadata.cpp new/kcrash-5.85.0/src/metadata.cpp --- old/kcrash-5.84.0/src/metadata.cpp 2021-07-02 23:59:35.000000000 +0200 +++ new/kcrash-5.85.0/src/metadata.cpp 2021-07-28 03:04:39.000000000 +0200 @@ -21,13 +21,21 @@ #ifdef Q_OS_LINUX MetadataINIWriter::MetadataINIWriter(const QByteArray &path) : MetadataWriter() - , fd(::open(path.constData(), O_WRONLY | O_CREAT | O_NONBLOCK | O_TRUNC | O_CLOEXEC, S_IRUSR | S_IWUSR)) { + if (path.isEmpty()) { + return; + } + + fd = ::open(path.constData(), O_WRONLY | O_CREAT | O_NONBLOCK | O_TRUNC | O_CLOEXEC, S_IRUSR | S_IWUSR); if (fd == -1) { fprintf(stderr, "Failed to open metadata file: %s\n", strerror(errno)); - } else { + } else if (fd >= 0) { + writable = true; const char *header = "[KCrash]\n"; write(fd, header, strlen(header)); + } else { + fprintf(stderr, "MetadataINIWriter: Unexpected fd %d\n", fd); + Q_UNREACHABLE(); } } @@ -36,6 +44,7 @@ if (fd >= 0 && ::close(fd) == -1) { fprintf(stderr, "Failed to close metadata file: %s\n", strerror(errno)); } + writable = false; } void MetadataINIWriter::add(const char *key, const char *value, BoolValue boolValue) @@ -59,11 +68,14 @@ Q_ASSERT(lineLength <= iniLine.max_size()); // is not truncated41 write(fd, iniLine.data(), lineLength); } + +bool MetadataINIWriter::isWritable() const +{ + return writable; +} #endif -Metadata::Metadata(const char *cmd, MetadataWriter *writer) - : MetadataWriter() - , m_writer(writer) +Metadata::Metadata(const char *cmd) { // NB: cmd may be null! Just because we create metadata doesn't mean we'll execute drkonqi (we may only need the // backing writers) @@ -71,6 +83,15 @@ argv.at(argc++) = cmd; } +void Metadata::setAdditionalWriter(MetadataWriter *writer) +{ + // Once set the writer oughtn't be reset as we have no use case for this and should we get one in the future + // it'll need at least review of the existing code to handle writer switching correctly. + Q_ASSERT(m_writer == nullptr); + Q_ASSERT(writer != nullptr); + m_writer = writer; +} + void Metadata::add(const char *key, const char *value) { add(key, value, BoolValue::No); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kcrash-5.84.0/src/metadata_p.h new/kcrash-5.85.0/src/metadata_p.h --- old/kcrash-5.84.0/src/metadata_p.h 2021-07-02 23:59:35.000000000 +0200 +++ new/kcrash-5.85.0/src/metadata_p.h 2021-07-28 03:04:39.000000000 +0200 @@ -32,7 +32,7 @@ }; #ifdef Q_OS_LINUX -// This writes the metdata file. Only really useful on Linux for now as this needs +// This writes the metadata file. Only really useful on Linux for now as this needs // cleanup by a helper daemon later. Also, this is only ever useful when coredump is in use. class MetadataINIWriter : public MetadataWriter { @@ -43,7 +43,11 @@ void add(const char *key, const char *value, BoolValue boolValue) override; void close() override; + // open or not, all functions are generally save to call without checking this + [[nodiscard]] bool isWritable() const; + private: + bool writable = false; int fd = -1; std::array<char, 1024> iniLine{}; // arbitrary max size @@ -57,9 +61,12 @@ class Metadata : public MetadataWriter { public: - Metadata(const char *cmd, MetadataWriter *writer); + explicit Metadata(const char *cmd); ~Metadata() override = default; + // Add an additional writer that should receive write calls as well. Do not call this after having called add. + void setAdditionalWriter(MetadataWriter *writer); + void add(const char *key, const char *value); void addBool(const char *key);
