Bug 406718 - SegFault in SDDM Theme Installer (sdmthemeinstaller.cpp)
Summary: SegFault in SDDM Theme Installer (sdmthemeinstaller.cpp)
Status: RESOLVED FIXED
Alias: None
Product: frameworks-knewstuff
Classification: Frameworks and Libraries
Component: general (show other bugs)
Version: unspecified
Platform: Other Linux
: NOR crash
Target Milestone: ---
Assignee: David Edmundson
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-04-20 18:39 UTC by John Gehrig
Modified: 2019-05-14 20:37 UTC (History)
3 users (show)

See Also:
Latest Commit:
Version Fixed In: 5.16.0


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description John Gehrig 2019-04-20 18:39:35 UTC
SUMMARY
The SDDM-KCM module does not work on my system. When trying to install themes, one of the error handling paths segfaults.

STEPS TO REPRODUCE
1. Open 'System Settings'
2. Click 'Startup and Shutdown'
3. Click Login Screen (SDDM)
4. Click 'Get New Theme'
5. Click 'Install' for any theme.
6. Segfault!


OBSERVED RESULT
The utility 'sddmthemeinstaller' segfaults.

ADDITIONAL INFORMATION
I have some (unknown) configuration issue on my system that is taking me down an error path. This error path is segfaulting because it makes some invalid assumptions about job->errorString().

Based on a quick glance at source code in master, it looks like this issue is still around.
Comment 1 John Gehrig 2019-04-20 18:49:20 UTC
As per the documentation (https://api.kde.org/frameworks/kcoreaddons/html/classKJob.html#a975a15193b17d06e182f8fd55c5f0d8b) job->errorString() should only be called when job->error() != 0. 

A quick fix for my issues goes something like this:

75,76c75,81
<             KMessageBox::sorry(nullptr, i18n("Unable to install theme"), job->errorString());
<             qWarning() << job->error() << job->errorString();
---
>             QString errMessage;
>             if (job->error() != 0) {
>                 errMessage = job->errorString();
>             }
> 
>             KMessageBox::sorry(nullptr, i18n("Unable to install theme"), errMessage);
>             qWarning() << job->error() << errMessage;
Comment 2 Patrick Silva 2019-04-21 10:58:33 UTC
maybe duplicate of bug 404609
Comment 3 Nate Graham 2019-04-23 17:24:29 UTC
Thanks John, would you be interested in submitting your patch? If so please see https://community.kde.org/Infrastructure/Phabricator for instructions. I'm happy to help if you get stuck.
Comment 4 John Gehrig 2019-04-27 01:27:06 UTC
Hi Nate,

Sure, I can submit a patch... I should have some free time this weekend.

Thanks for the link! I will ping you if I have any troubles.
Comment 5 John Gehrig 2019-04-27 01:39:05 UTC
Patrick, I took a look at your backtrace... It looks like the same crash to me.

Your crash should be fixed by this patch. Probably Duplicate.
Comment 6 Nate Graham 2019-05-14 20:37:10 UTC
Git commit 7df456404c26200ff6e36fc3d65aa39f2c6e7c3c by Nate Graham, on behalf of John Gehrig.
Committed on 14/05/2019 at 20:37.
Pushed by ngraham into branch 'master'.

Crash in sddmthemeinstaller invalid use of errorString

Summary:
The destruction of KAuth::ExecuteJob* "job" is not handled properly when passed as a parameter to KMessageBox.

An intermediate QString is created containing the error text. This value is passed into the KMessageBox and qWarning() so that the object "job" is no longer an input. The console error is now first so an error message displayed even in the event of a GUI crash.
Related: bug 404609
FIXED-IN: 5.16.0

Test Plan: The patch has been applied to my system and the crash no longer occurs.

Reviewers: ngraham, davidedmundson, #plasma

Reviewed By: ngraham, davidedmundson, #plasma

Subscribers: anthonyfieroni, plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D20859

M  +3    -2    sddmthemeinstaller.cpp

https://commits.kde.org/sddm-kcm/7df456404c26200ff6e36fc3d65aa39f2c6e7c3c