From 8ea90037a560324dc4e7fdc8f41c2c381f8cc9f7 Mon Sep 17 00:00:00 2001 From: Rex Dieter Date: Mon, 8 May 2017 12:09:21 -0500 Subject: [PATCH] backport recommended qtdbus patches --- ...etaType-s-custom-information-to-QDBu.patch | 391 ++++++++++++++++++ ...crashes-during-application-destructi.patch | 121 ++++++ qt5-qtbase.spec | 13 +- 3 files changed, 524 insertions(+), 1 deletion(-) create mode 100644 0001-Merge-the-QDBusMetaType-s-custom-information-to-QDBu.patch create mode 100644 0002-Fix-some-QtDBus-crashes-during-application-destructi.patch diff --git a/0001-Merge-the-QDBusMetaType-s-custom-information-to-QDBu.patch b/0001-Merge-the-QDBusMetaType-s-custom-information-to-QDBu.patch new file mode 100644 index 0000000..bc8ab42 --- /dev/null +++ b/0001-Merge-the-QDBusMetaType-s-custom-information-to-QDBu.patch @@ -0,0 +1,391 @@ +diff -up qtbase-opensource-src-5.7.1/src/dbus/qdbusconnection.cpp.0401 qtbase-opensource-src-5.7.1/src/dbus/qdbusconnection.cpp +--- qtbase-opensource-src-5.7.1/src/dbus/qdbusconnection.cpp.0401 2016-12-01 02:17:04.000000000 -0600 ++++ qtbase-opensource-src-5.7.1/src/dbus/qdbusconnection.cpp 2017-05-08 10:05:11.598990180 -0500 +@@ -190,6 +190,7 @@ void QDBusConnectionManager::run() + } + } + connectionHash.clear(); ++ customTypes.clear(); + + // allow deletion from any thread without warning + moveToThread(Q_NULLPTR); +diff -up qtbase-opensource-src-5.7.1/src/dbus/qdbusconnectionmanager_p.h.0401 qtbase-opensource-src-5.7.1/src/dbus/qdbusconnectionmanager_p.h +--- qtbase-opensource-src-5.7.1/src/dbus/qdbusconnectionmanager_p.h.0401 2017-05-08 10:05:11.598990180 -0500 ++++ qtbase-opensource-src-5.7.1/src/dbus/qdbusconnectionmanager_p.h 2017-05-08 10:07:07.082900037 -0500 +@@ -54,13 +54,14 @@ + #define QDBUSCONNECTIONMANAGER_P_H + + #include "qdbusconnection_p.h" ++#include "qdbusmetatype_p.h" + #include "private/qthread_p.h" + + #ifndef QT_NO_DBUS + + QT_BEGIN_NAMESPACE + +-class QDBusConnectionManager : public QDaemonThread ++class QDBusConnectionManager : public QDaemonThread, public QDBusMetaTypeId + { + Q_OBJECT + struct ConnectionRequestData; +diff -up qtbase-opensource-src-5.7.1/src/dbus/qdbusintegrator.cpp.0401 qtbase-opensource-src-5.7.1/src/dbus/qdbusintegrator.cpp +--- qtbase-opensource-src-5.7.1/src/dbus/qdbusintegrator.cpp.0401 2016-12-01 02:17:04.000000000 -0600 ++++ qtbase-opensource-src-5.7.1/src/dbus/qdbusintegrator.cpp 2017-05-08 10:05:11.599990188 -0500 +@@ -1036,7 +1036,6 @@ QDBusConnectionPrivate::QDBusConnectionP + qdbusThreadDebug = qdbusDefaultThreadDebug; + #endif + +- QDBusMetaTypeId::init(); + connect(this, &QDBusConnectionPrivate::dispatchStatusChanged, + this, &QDBusConnectionPrivate::doDispatch, Qt::QueuedConnection); + connect(this, &QDBusConnectionPrivate::spyHooksFinished, +diff -up qtbase-opensource-src-5.7.1/src/dbus/qdbusmetatype.cpp.0401 qtbase-opensource-src-5.7.1/src/dbus/qdbusmetatype.cpp +--- qtbase-opensource-src-5.7.1/src/dbus/qdbusmetatype.cpp.0401 2016-12-01 02:17:04.000000000 -0600 ++++ qtbase-opensource-src-5.7.1/src/dbus/qdbusmetatype.cpp 2017-05-08 10:05:11.600990196 -0500 +@@ -1,6 +1,7 @@ + /**************************************************************************** + ** + ** Copyright (C) 2016 The Qt Company Ltd. ++** Copyright (C) 2016 Intel Corporation. + ** Contact: https://www.qt.io/licensing/ + ** + ** This file is part of the QtDBus module of the Qt Toolkit. +@@ -39,19 +40,15 @@ + + #include "qdbusmetatype.h" + #include "qdbusmetatype_p.h" +- +-#include + #include "qdbus_symbols_p.h" + +-#include +-#include +-#include +-#include ++#include + + #include "qdbusargument_p.h" + #include "qdbusutil_p.h" + #include "qdbusunixfiledescriptor.h" + #ifndef QT_BOOTSTRAPPED ++#include "qdbusconnectionmanager_p.h" + #include "qdbusmessage.h" + #endif + +@@ -64,82 +61,72 @@ + + QT_BEGIN_NAMESPACE + +-class QDBusCustomTypeInfo +-{ +-public: +- QDBusCustomTypeInfo() : signature(), marshall(0), demarshall(0) +- { } +- +- // Suggestion: +- // change 'signature' to char* and make QDBusCustomTypeInfo a Movable type +- QByteArray signature; +- QDBusMetaType::MarshallFunction marshall; +- QDBusMetaType::DemarshallFunction demarshall; +-}; ++static void registerMarshallOperatorsNoLock(QVector &ct, int id, ++ QDBusMetaType::MarshallFunction mf, ++ QDBusMetaType::DemarshallFunction df); + + template +-inline static void registerHelper(T * = 0) ++inline static void registerHelper(QVector &ct) + { + void (*mf)(QDBusArgument &, const T *) = qDBusMarshallHelper; + void (*df)(const QDBusArgument &, T *) = qDBusDemarshallHelper; +- QDBusMetaType::registerMarshallOperators(qMetaTypeId(), ++ registerMarshallOperatorsNoLock(ct, qMetaTypeId(), + reinterpret_cast(mf), + reinterpret_cast(df)); + } + +-void QDBusMetaTypeId::init() ++QDBusMetaTypeId *QDBusMetaTypeId::instance() + { +- static QBasicAtomicInt initialized = Q_BASIC_ATOMIC_INITIALIZER(false); ++#ifdef QT_BOOTSTRAPPED ++ static QDBusMetaTypeId self; ++ return &self; ++#else ++ return QDBusConnectionManager::instance(); ++#endif ++} + +- // reentrancy is not a problem since everything else is locked on their own +- // set the guard variable at the end +- if (!initialized.load()) { +- // register our types with Qt Core (calling qMetaTypeId() does this implicitly) +- (void)message(); +- (void)argument(); +- (void)variant(); +- (void)objectpath(); +- (void)signature(); +- (void)error(); +- (void)unixfd(); ++QDBusMetaTypeId::QDBusMetaTypeId() ++{ ++ // register our types with Qt Core (calling qMetaTypeId() does this implicitly) ++ (void)message(); ++ (void)argument(); ++ (void)variant(); ++ (void)objectpath(); ++ (void)signature(); ++ (void)error(); ++ (void)unixfd(); + + #ifndef QDBUS_NO_SPECIALTYPES +- // and register Qt Core's with us +- registerHelper(); +- registerHelper(); +- registerHelper(); +- registerHelper(); +- registerHelper(); +- registerHelper(); +- registerHelper(); +- registerHelper(); +- registerHelper(); +- registerHelper(); +- registerHelper(); +- registerHelper(); +- registerHelper(); +- registerHelper(); +- +- qDBusRegisterMetaType >(); +- qDBusRegisterMetaType >(); +- qDBusRegisterMetaType >(); +- qDBusRegisterMetaType >(); +- qDBusRegisterMetaType >(); +- qDBusRegisterMetaType >(); +- qDBusRegisterMetaType >(); +- qDBusRegisterMetaType >(); +- qDBusRegisterMetaType >(); +- qDBusRegisterMetaType >(); +- qDBusRegisterMetaType >(); ++ // and register Qt Core's with us ++ registerHelper(customTypes); ++ registerHelper(customTypes); ++ registerHelper(customTypes); ++ registerHelper(customTypes); ++ registerHelper(customTypes); ++ registerHelper(customTypes); ++ registerHelper(customTypes); ++ registerHelper(customTypes); ++ registerHelper(customTypes); ++ registerHelper(customTypes); ++ registerHelper(customTypes); ++ registerHelper(customTypes); ++ registerHelper(customTypes); ++ registerHelper(customTypes); ++ ++ registerHelper >(customTypes); ++ registerHelper >(customTypes); ++ registerHelper >(customTypes); ++ registerHelper >(customTypes); ++ registerHelper >(customTypes); ++ registerHelper >(customTypes); ++ registerHelper >(customTypes); ++ registerHelper >(customTypes); ++ registerHelper >(customTypes); ++ registerHelper >(customTypes); ++ registerHelper >(customTypes); + #endif +- +- initialized.store(true); +- } + } + +-Q_GLOBAL_STATIC(QVector, customTypes) +-Q_GLOBAL_STATIC(QReadWriteLock, customTypesLock) +- + /*! + \class QDBusMetaType + \inmodule QtDBus +@@ -217,14 +204,22 @@ void QDBusMetaType::registerMarshallOper + DemarshallFunction df) + { + QByteArray var; +- QVector *ct = customTypes(); +- if (id < 0 || !mf || !df || !ct) ++ QDBusMetaTypeId *mgr = QDBusMetaTypeId::instance(); ++ if (id < 0 || !mf || !df || !mgr) + return; // error! + +- QWriteLocker locker(customTypesLock()); +- if (id >= ct->size()) +- ct->resize(id + 1); +- QDBusCustomTypeInfo &info = (*ct)[id]; ++ QWriteLocker locker(&mgr->customTypesLock); ++ QVector &ct = mgr->customTypes; ++ registerMarshallOperatorsNoLock(ct, id, mf, df); ++} ++ ++static void registerMarshallOperatorsNoLock(QVector &ct, int id, ++ QDBusMetaType::MarshallFunction mf, ++ QDBusMetaType::DemarshallFunction df) ++{ ++ if (id >= ct.size()) ++ ct.resize(id + 1); ++ QDBusCustomTypeInfo &info = ct[id]; + info.marshall = mf; + info.demarshall = df; + } +@@ -241,12 +236,16 @@ bool QDBusMetaType::marshall(QDBusArgume + + MarshallFunction mf; + { +- QReadLocker locker(customTypesLock()); +- QVector *ct = customTypes(); +- if (id >= ct->size()) ++ const QDBusMetaTypeId *mgr = QDBusMetaTypeId::instance(); ++ if (!mgr) ++ return false; // shutting down ++ ++ QReadLocker locker(&mgr->customTypesLock); ++ const QVector &ct = mgr->customTypes; ++ if (id >= ct.size()) + return false; // non-existent + +- const QDBusCustomTypeInfo &info = (*ct).at(id); ++ const QDBusCustomTypeInfo &info = ct.at(id); + if (!info.marshall) { + mf = 0; // make gcc happy + return false; +@@ -270,12 +269,16 @@ bool QDBusMetaType::demarshall(const QDB + + DemarshallFunction df; + { +- QReadLocker locker(customTypesLock()); +- QVector *ct = customTypes(); +- if (id >= ct->size()) ++ const QDBusMetaTypeId *mgr = QDBusMetaTypeId::instance(); ++ if (!mgr) ++ return false; // shutting down ++ ++ QReadLocker locker(&mgr->customTypesLock); ++ const QVector &ct = mgr->customTypes; ++ if (id >= ct.size()) + return false; // non-existent + +- const QDBusCustomTypeInfo &info = (*ct).at(id); ++ const QDBusCustomTypeInfo &info = ct.at(id); + if (!info.demarshall) { + df = 0; // make gcc happy + return false; +@@ -434,7 +437,11 @@ const char *QDBusMetaType::typeToSignatu + DBUS_TYPE_BYTE_AS_STRING; // ay + } + +- QDBusMetaTypeId::init(); ++ // try the database ++ QDBusMetaTypeId *mgr = QDBusMetaTypeId::instance(); ++ if (!mgr) ++ return Q_NULLPTR; // shutting down ++ + if (type == QDBusMetaTypeId::variant()) + return DBUS_TYPE_VARIANT_AS_STRING; + else if (type == QDBusMetaTypeId::objectpath()) +@@ -444,14 +451,13 @@ const char *QDBusMetaType::typeToSignatu + else if (type == QDBusMetaTypeId::unixfd()) + return DBUS_TYPE_UNIX_FD_AS_STRING; + +- // try the database +- QVector *ct = customTypes(); + { +- QReadLocker locker(customTypesLock()); +- if (type >= ct->size()) ++ QReadLocker locker(&mgr->customTypesLock); ++ const QVector &ct = mgr->customTypes; ++ if (type >= ct.size()) + return 0; // type not registered with us + +- const QDBusCustomTypeInfo &info = (*ct).at(type); ++ const QDBusCustomTypeInfo &info = ct.at(type); + + if (!info.signature.isNull()) + return info.signature; +@@ -468,8 +474,9 @@ const char *QDBusMetaType::typeToSignatu + QByteArray signature = QDBusArgumentPrivate::createSignature(type); + + // re-acquire lock +- QWriteLocker locker(customTypesLock()); +- info = &(*ct)[type]; ++ QWriteLocker locker(&mgr->customTypesLock); ++ QVector &ct = mgr->customTypes; ++ info = &ct[type]; + info->signature = signature; + } + return info->signature; +diff -up qtbase-opensource-src-5.7.1/src/dbus/qdbusmetatype_p.h.0401 qtbase-opensource-src-5.7.1/src/dbus/qdbusmetatype_p.h +--- qtbase-opensource-src-5.7.1/src/dbus/qdbusmetatype_p.h.0401 2016-12-01 02:17:04.000000000 -0600 ++++ qtbase-opensource-src-5.7.1/src/dbus/qdbusmetatype_p.h 2017-05-08 10:05:11.600990196 -0500 +@@ -1,6 +1,7 @@ + /**************************************************************************** + ** + ** Copyright (C) 2016 The Qt Company Ltd. ++** Copyright (C) 2016 Intel Corporation. + ** Contact: https://www.qt.io/licensing/ + ** + ** This file is part of the QtDBus module of the Qt Toolkit. +@@ -59,10 +60,27 @@ + #include + #include + ++#include ++#include ++#include ++ + #ifndef QT_NO_DBUS + + QT_BEGIN_NAMESPACE + ++class QDBusCustomTypeInfo ++{ ++public: ++ QDBusCustomTypeInfo() : signature(), marshall(0), demarshall(0) ++ { } ++ ++ // Suggestion: ++ // change 'signature' to char* and make QDBusCustomTypeInfo a Movable type ++ QByteArray signature; ++ QDBusMetaType::MarshallFunction marshall; ++ QDBusMetaType::DemarshallFunction demarshall; ++}; ++ + struct QDBusMetaTypeId + { + static int message(); // QDBusMessage +@@ -73,7 +91,14 @@ struct QDBusMetaTypeId + static int error(); // QDBusError + static int unixfd(); // QDBusUnixFileDescriptor + +- static void init(); ++ static void init() { instance(); } ++ static QDBusMetaTypeId *instance(); ++ ++ mutable QReadWriteLock customTypesLock; ++ QVector customTypes; ++ ++protected: ++ QDBusMetaTypeId(); + }; + + inline int QDBusMetaTypeId::message() +diff -up qtbase-opensource-src-5.7.1/src/dbus/qdbusmisc.cpp.0401 qtbase-opensource-src-5.7.1/src/dbus/qdbusmisc.cpp +--- qtbase-opensource-src-5.7.1/src/dbus/qdbusmisc.cpp.0401 2016-12-01 02:17:04.000000000 -0600 ++++ qtbase-opensource-src-5.7.1/src/dbus/qdbusmisc.cpp 2017-05-08 10:05:11.600990196 -0500 +@@ -144,8 +144,9 @@ int qDBusParametersForMethod(const QMeta + + int qDBusParametersForMethod(const QList ¶meterTypes, QVector& metaTypes, QString &errorMsg) + { +- QDBusMetaTypeId::init(); + metaTypes.clear(); ++ if (!QDBusMetaTypeId::instance()) ++ return -1; + + metaTypes.append(0); // return type + int inputCount = 0; diff --git a/0002-Fix-some-QtDBus-crashes-during-application-destructi.patch b/0002-Fix-some-QtDBus-crashes-during-application-destructi.patch new file mode 100644 index 0000000..8139a5d --- /dev/null +++ b/0002-Fix-some-QtDBus-crashes-during-application-destructi.patch @@ -0,0 +1,121 @@ +From 72700167cf051e5053f03bf4f4be391cd7514502 Mon Sep 17 00:00:00 2001 +From: Thiago Macieira +Date: Tue, 31 May 2016 17:33:03 -0300 +Subject: [PATCH 2/2] Fix some QtDBus crashes during application destruction + +It's possible that some code executes after QDBusConnectionManager is +destroyed and still tries to access QtDBus. Protect against such +crashes. + +Change-Id: I87e17314d8b24ae983b1fffd1453c13fbd3cf48e +--- + src/dbus/qdbusconnection.cpp | 12 ++++++++---- + src/dbus/qdbusintegrator.cpp | 3 +++ + src/dbus/qdbusserver.cpp | 12 ++++++++++-- + 3 files changed, 21 insertions(+), 6 deletions(-) + +diff --git a/src/dbus/qdbusconnection.cpp b/src/dbus/qdbusconnection.cpp +index 4187f19..aa14ac2 100644 +--- a/src/dbus/qdbusconnection.cpp ++++ b/src/dbus/qdbusconnection.cpp +@@ -418,7 +418,7 @@ void QDBusConnectionManager::createServer(const QString &address, void *server) + */ + QDBusConnection::QDBusConnection(const QString &name) + { +- if (name.isEmpty()) { ++ if (name.isEmpty() || _q_manager.isDestroyed()) { + d = 0; + } else { + QMutexLocker locker(&_q_manager()->mutex); +@@ -483,7 +483,7 @@ QDBusConnection &QDBusConnection::operator=(const QDBusConnection &other) + */ + QDBusConnection QDBusConnection::connectToBus(BusType type, const QString &name) + { +- if (!qdbus_loadLibDBus()) { ++ if (_q_manager.isDestroyed() || !qdbus_loadLibDBus()) { + QDBusConnectionPrivate *d = 0; + return QDBusConnection(d); + } +@@ -497,7 +497,7 @@ QDBusConnection QDBusConnection::connectToBus(BusType type, const QString &name) + QDBusConnection QDBusConnection::connectToBus(const QString &address, + const QString &name) + { +- if (!qdbus_loadLibDBus()) { ++ if (_q_manager.isDestroyed() || !qdbus_loadLibDBus()) { + QDBusConnectionPrivate *d = 0; + return QDBusConnection(d); + } +@@ -512,7 +512,7 @@ QDBusConnection QDBusConnection::connectToBus(const QString &address, + QDBusConnection QDBusConnection::connectToPeer(const QString &address, + const QString &name) + { +- if (!qdbus_loadLibDBus()) { ++ if (_q_manager.isDestroyed() || !qdbus_loadLibDBus()) { + QDBusConnectionPrivate *d = 0; + return QDBusConnection(d); + } +@@ -1167,6 +1167,8 @@ bool QDBusConnection::unregisterService(const QString &serviceName) + */ + QDBusConnection QDBusConnection::sessionBus() + { ++ if (_q_manager.isDestroyed()) ++ return QDBusConnection(Q_NULLPTR); + return QDBusConnection(_q_manager()->busConnection(SessionBus)); + } + +@@ -1179,6 +1181,8 @@ QDBusConnection QDBusConnection::sessionBus() + */ + QDBusConnection QDBusConnection::systemBus() + { ++ if (_q_manager.isDestroyed()) ++ return QDBusConnection(Q_NULLPTR); + return QDBusConnection(_q_manager()->busConnection(SystemBus)); + } + +diff --git a/src/dbus/qdbusintegrator.cpp b/src/dbus/qdbusintegrator.cpp +index 19f79e9..f8dc702 100644 +--- a/src/dbus/qdbusintegrator.cpp ++++ b/src/dbus/qdbusintegrator.cpp +@@ -299,6 +299,9 @@ static void qDBusNewConnection(DBusServer *server, DBusConnection *connection, v + Q_ASSERT(connection); + Q_ASSERT(data); + ++ if (!QDBusConnectionManager::instance()) ++ return; ++ + // keep the connection alive + q_dbus_connection_ref(connection); + QDBusConnectionPrivate *serverConnection = static_cast(data); +diff --git a/src/dbus/qdbusserver.cpp b/src/dbus/qdbusserver.cpp +index 027ce93..b1f9be2 100644 +--- a/src/dbus/qdbusserver.cpp ++++ b/src/dbus/qdbusserver.cpp +@@ -68,7 +68,11 @@ QDBusServer::QDBusServer(const QString &address, QObject *parent) + if (!qdbus_loadLibDBus()) + return; + +- emit QDBusConnectionManager::instance()->serverRequested(address, this); ++ QDBusConnectionManager *instance = QDBusConnectionManager::instance(); ++ if (!instance) ++ return; ++ ++ emit instance->serverRequested(address, this); + QObject::connect(d, SIGNAL(newServerConnection(QDBusConnectionPrivate*)), + this, SLOT(_q_newConnection(QDBusConnectionPrivate*)), Qt::QueuedConnection); + } +@@ -93,7 +97,11 @@ QDBusServer::QDBusServer(QObject *parent) + return; + } + +- emit QDBusConnectionManager::instance()->serverRequested(address, this); ++ QDBusConnectionManager *instance = QDBusConnectionManager::instance(); ++ if (!instance) ++ return; ++ ++ emit instance->serverRequested(address, this); + QObject::connect(d, SIGNAL(newServerConnection(QDBusConnectionPrivate*)), + this, SLOT(_q_newConnection(QDBusConnectionPrivate*)), Qt::QueuedConnection); + } +-- +2.9.3 + diff --git a/qt5-qtbase.spec b/qt5-qtbase.spec index 416a5d6..ef5eefe 100644 --- a/qt5-qtbase.spec +++ b/qt5-qtbase.spec @@ -66,7 +66,7 @@ BuildRequires: pkgconfig(libsystemd) Name: qt5-qtbase Summary: Qt5 - QtBase components Version: 5.7.1 -Release: 15%{?dist} +Release: 16%{?dist} # See LGPL_EXCEPTIONS.txt, for exception details License: LGPLv2 with exceptions or GPLv3 with exceptions @@ -139,6 +139,11 @@ Patch101: qt5-qtbase-5.8-QTBUG-56140.patch # gcc7 FTBFS fix Patch153: 0053-QMimeXMLProvider-add-missing-out-of-line-destructor.patch +## under review +# https://codereview.qt-project.org/#/c/180232/ +Patch401: 0001-Merge-the-QDBusMetaType-s-custom-information-to-QDBu.patch +Patch402: 0002-Fix-some-QtDBus-crashes-during-application-destructi.patch + # Do not check any files in %%{_qt5_plugindir}/platformthemes/ for requires. # Those themes are there for platform integration. If the required libraries are # not there, the platform to integrate with isn't either. Then Qt will just @@ -374,6 +379,9 @@ Qt5 libraries used for drawing widgets and OpenGL items. %patch101 -p1 -b .QTBUG-56140 %patch153 -p1 -b .0053 +%patch401 -p1 -b .0401 +%patch402 -p1 -b .0402 + %patch50 -p1 -b .QT_VERSION_CHECK %patch51 -p1 -b .hidpi_scale_at_192 %patch52 -p1 -b .moc_macros @@ -985,6 +993,9 @@ fi %changelog +* Mon May 08 2017 Rex Dieter - 5.7.1-16 +- backport recommended qtdbus patches + * Fri Feb 17 2017 Rex Dieter - 5.7.1-15 - gcc7 FTBFS fix (#1423090)