Bug 376508 - kpackage 5.31 crash plasma after logging
Summary: kpackage 5.31 crash plasma after logging
Status: RESOLVED WORKSFORME
Alias: None
Product: frameworks-kpackage
Classification: Frameworks and Libraries
Component: default (show other bugs)
Version: unspecified
Platform: Fedora RPMs Linux
: NOR normal
Target Milestone: ---
Assignee: Marco Martin
URL:
Keywords:
: 376847 377282 (view as bug list)
Depends on:
Blocks:
 
Reported: 2017-02-15 10:20 UTC by eddy.pilon
Modified: 2020-12-31 04:34 UTC (History)
4 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description eddy.pilon 2017-02-15 10:20:14 UTC
plasma (5.8 - 5.9) crash after kf5-kpackage update to 5.31 

Part of the backtrace:

Thread 1 "ksplashqml" received signal SIGSEGV, Segmentation fault.
0x00007ffff59d61f2 in QJsonPrivate::Parser::parseObject() () from /lib64/libQt5Core.so.5
(gdb) bt
#0  0x00007ffff59d61f2 in QJsonPrivate::Parser::parseObject() () from /lib64/libQt5Core.so.5
#1  0x00007ffff59d6897 in QJsonPrivate::Parser::parseValue(QJsonPrivate::Value*, int) () from /lib64/libQt5Core.so.5
#2  0x00007ffff59d6d35 in QJsonPrivate::Parser::parseArray() () from /lib64/libQt5Core.so.5
#3  0x00007ffff59d6953 in QJsonPrivate::Parser::parseValue(QJsonPrivate::Value*, int) () from /lib64/libQt5Core.so.5
#4  0x00007ffff59d6bc0 in QJsonPrivate::Parser::parseMember(int) () from /lib64/libQt5Core.so.5
#5  0x00007ffff59d6352 in QJsonPrivate::Parser::parseObject() () from /lib64/libQt5Core.so.5
#6  0x00007ffff59d6897 in QJsonPrivate::Parser::parseValue(QJsonPrivate::Value*, int) () from /lib64/libQt5Core.so.5
#7  0x00007ffff59d6bc0 in QJsonPrivate::Parser::parseMember(int) () from /lib64/libQt5Core.so.5
#8  0x00007ffff59d6352 in QJsonPrivate::Parser::parseObject() () from /lib64/libQt5Core.so.5
#9  0x00007ffff59d74f4 in QJsonPrivate::Parser::parse(QJsonParseError*) () from /lib64/libQt5Core.so.5
#10 0x00007ffff59ccc1e in QJsonDocument::fromJson(QByteArray const&, QJsonParseError*) () from /lib64/libQt5Core.so.5
#11 0x00007ffff69df0ff in KPluginMetaData::KPluginMetaData(QString const&) () from /lib64/libKF5CoreAddons.so.5
#12 0x00007ffff730b3c0 in KPackage::PackagePrivate::createPackageMetadata(QString const&) () from /lib64/libKF5Package.so.5
#13 0x00007ffff730d6c5 in KPackage::Package::metadata() const () from /lib64/libKF5Package.so.5
#14 0x00007ffff730eada in KPackage::Package::setPath(QString const&) () from /lib64/libKF5Package.so.5
#15 0x00007fffdc5d3bc8 in LookAndFeelPackage::initPackage (this=<optimized out>, package=0x7fffff7ff810)
    at /home/edmond/rpmbuild/BUILD/plasma-workspace-5.9.1/shell/packageplugins/lookandfeel/lookandfeel.cpp:84
#16 0x00007ffff730a5cd in KPackage::Package::Package(KPackage::PackageStructure*) () from /lib64/libKF5Package.so.5
#17 0x00007ffff7315bef in KPackage::PackageLoader::loadPackage(QString const&, QString const&) () from /lib64/libKF5Package.so.5
#18 0x00007fffdc5d47af in LookAndFeelPackage::pathChanged (this=<optimized out>, package=0x7fffff7ffac0)
    at /home/edmond/rpmbuild/BUILD/plasma-workspace-5.9.1/shell/packageplugins/lookandfeel/lookandfeel.cpp:96
#19 0x00007ffff730e9f8 in KPackage::Package::setPath(QString const&) () from /lib64/libKF5Package.so.5
#20 0x00007fffdc5d3bc8 in LookAndFeelPackage::initPackage (this=<optimized out>, package=0x7fffff7ffac0).


A quick debugging shows that it's because of this upstream patch:

From e6d72cb9df6f55b3f463a5acfcad6a7bafe4bd81 Mon Sep 17 00:00:00 2001
From: Aleix Pol <aleixpol@kde.org>
Date: Thu, 29 Dec 2016 01:12:23 +0100
Subject: Improve installation process of KPackage bundles

When parsing the desktop files, pass together the kpackage-generic.desktop
service type, so that the parser knows its intrinsic types (most especially
 X-KPackage-Dependencies which is in fact added now). This is important
because otherwise we get warnings when we extract the value when the
package is a desktop file.

This would be much less of a problem if desktop service types could be
extended, but it's not the case at the moment.

REVIEW: 129716
---
 .../data/servicetypes/kpackage-generic.desktop        |  2 ++
 src/kpackage/package.cpp                              | 19 ++++++++++++++-----
 src/kpackage/private/packagejobthread.cpp             |  8 +++++---
 3 files changed, 21 insertions(+), 8 deletions(-)

diff --git a/src/kpackage/data/servicetypes/kpackage-generic.desktop b/src/kpackage/data/servicetypes/kpackage-generic.desktop
index 879d3b2..73e9077 100644
--- a/src/kpackage/data/servicetypes/kpackage-generic.desktop
+++ b/src/kpackage/data/servicetypes/kpackage-generic.desktop
@@ -8,3 +8,5 @@ Type=QString
 [PropertyDef::X-Plasma-MainScript]
 Type=QString
 
+[PropertyDef::X-KPackage-Dependencies]
+Type=QStringList
diff --git a/src/kpackage/package.cpp b/src/kpackage/package.cpp
index c032e6e..adc2a6e 100644
--- a/src/kpackage/package.cpp
+++ b/src/kpackage/package.cpp
@@ -921,17 +921,26 @@ void PackagePrivate::updateHash(const QString &basePath, const QString &subPath,
 
 void PackagePrivate::createPackageMetadata(const QString &path)
 {
+    static QString kpackageGenericService = QStandardPaths::locate(QStandardPaths::GenericDataLocation, QStringLiteral("kservicetypes5/kpackage-generic.desktop"));
     delete metadata;
 
     const bool isDir = QFileInfo(path).isDir();
-    if (isDir && QFile::exists(path + "/metadata.desktop")) {
-        metadata = new KPluginMetaData(path + "/metadata.desktop");
-    } else if (isDir && QFile::exists(path + "/metadata.json")) {
+
+    if (isDir && QFile::exists(path + "/metadata.json")) {
         metadata = new KPluginMetaData(path + "/metadata.json");
+    } else if (isDir && QFile::exists(path + "/metadata.desktop")) {
+        Q_ASSERT(!kpackageGenericService.isEmpty());
+        auto md = KPluginMetaData::fromDesktopFile(path + "/metadata.desktop", {kpackageGenericService});
+        metadata = new KPluginMetaData(md);
     } else {
-        if (isDir)
+        if (isDir) {
             qWarning() << "No metadata file in the package, expected it at:" << path;
-        metadata = new KPluginMetaData(path);
+        } else if (path.endsWith(".desktop")) {
+            auto md = KPluginMetaData::fromDesktopFile(path, {kpackageGenericService});
+            metadata = new KPluginMetaData(md);
+        } else {
+            metadata = new KPluginMetaData(path);
+        }
     }
 }
 
diff --git a/src/kpackage/private/packagejobthread.cpp b/src/kpackage/private/packagejobthread.cpp
index 8697341..fe187f0 100644
--- a/src/kpackage/private/packagejobthread.cpp
+++ b/src/kpackage/private/packagejobthread.cpp
@@ -40,6 +40,7 @@
 #include <qtemporarydir.h>
 #include <QProcess>
 #include <QUrl>
+#include <QStandardPaths>
 #include <QDebug>
 
 namespace KPackage
@@ -292,9 +293,10 @@ bool PackageJobThread::installPackage(const QString &src, const QString &dest, O
     KPluginMetaData meta;
     if (!entries.isEmpty()) {
         const QString metadataFilePath = entries.first().filePath();
-        if (metadataFilePath.endsWith(QLatin1String(".desktop")))
-            meta = KPluginMetaData(metadataFilePath);
-        else {
+        if (metadataFilePath.endsWith(QLatin1String(".desktop"))) {
+            static QString kpackageGenericService = QStandardPaths::locate(QStandardPaths::GenericDataLocation, QStringLiteral("kservicetypes5/kpackage-generic.desktop"));
+            meta = KPluginMetaData::fromDesktopFile(metadataFilePath, {kpackageGenericService});
+        } else {
             QFile f(metadataFilePath);
             if(!f.open(QIODevice::ReadOnly)){
                 qWarning() << "Couldn't open metadata file" << src << path;
-- 
cgit v0.11.2


Reverting this patch solves the issue.
Comment 1 Christoph Feck 2017-02-17 02:55:40 UTC
Adding committer.
Comment 2 Rex Dieter 2017-03-06 05:17:48 UTC
*** Bug 376847 has been marked as a duplicate of this bug. ***
Comment 3 Rex Dieter 2017-03-06 05:19:02 UTC
See also bug #376847

where I think the one contributing factor is a lookandfeel theme where the .desktop and metadata.json do not match.
Comment 4 Rex Dieter 2017-03-06 05:21:29 UTC
(and doesn't help if the default fallback lookandfeel is modified to be the problematic one, as what is currently done in fedora packaging).

Fwiw, the mismatch is fixed in fedora's plasma-5.8.6 packages.
Comment 5 Rex Dieter 2017-03-06 17:50:37 UTC
*** Bug 377282 has been marked as a duplicate of this bug. ***
Comment 6 Nate Graham 2020-12-01 18:27:50 UTC
No duplicates in three and a half years; is this crash still happening for anyone?
Comment 7 Bug Janitor Service 2020-12-16 04:33:56 UTC
Dear Bug Submitter,

This bug has been in NEEDSINFO status with no change for at least
15 days. Please provide the requested information as soon as
possible and set the bug status as REPORTED. Due to regular bug
tracker maintenance, if the bug is still in NEEDSINFO status with
no change in 30 days the bug will be closed as RESOLVED > WORKSFORME
due to lack of needed information.

For more information about our bug triaging procedures please read the
wiki located here:
https://community.kde.org/Guidelines_and_HOWTOs/Bug_triaging

If you have already provided the requested information, please
mark the bug as REPORTED so that the KDE team knows that the bug is
ready to be confirmed.

Thank you for helping us make KDE software even better for everyone!
Comment 8 Bug Janitor Service 2020-12-31 04:34:20 UTC
This bug has been in NEEDSINFO status with no change for at least
30 days. The bug is now closed as RESOLVED > WORKSFORME
due to lack of needed information.

For more information about our bug triaging procedures please read the
wiki located here:
https://community.kde.org/Guidelines_and_HOWTOs/Bug_triaging

Thank you for helping us make KDE software even better for everyone!