Bug 464590 - kded5 crashes in KScreen::Config::setOutputPriority() after monitor wakes from sleep
Summary: kded5 crashes in KScreen::Config::setOutputPriority() after monitor wakes fro...
Status: RESOLVED FIXED
Alias: None
Product: KScreen
Classification: Plasma
Component: common (show other bugs)
Version: 5.26.90
Platform: Arch Linux Linux
: NOR crash
Target Milestone: ---
Assignee: kscreen-bugs-null@kde.org
URL:
Keywords: regression
: 466006 466036 466223 (view as bug list)
Depends on:
Blocks:
 
Reported: 2023-01-21 12:09 UTC by Jurica Vukadin
Modified: 2023-02-22 20:52 UTC (History)
12 users (show)

See Also:
Latest Commit:
Version Fixed In: 5.27.1


Attachments
libkscreen-crash.patch (675 bytes, patch)
2023-01-31 07:45 UTC, Guillaume Castagnino
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Jurica Vukadin 2023-01-21 12:09:43 UTC
SUMMARY
Thread 1 (Thread 0x7ff0ee639840 (LWP 25283)):
#0  __pthread_kill_implementation (threadid=<optimized out>, signo=signo@entry=11, no_tid=no_tid@entry=0) at pthread_kill.c:44
#1  0x00007ff0ee2a16b3 in __pthread_kill_internal (signo=11, threadid=<optimized out>) at pthread_kill.c:78
#2  0x00007ff0ee251938 in __GI_raise (sig=11) at raise.c:26
#3  0x00007ff0ef7dd37c in KCrash::defaultCrashHandler(int) (sig=11) at kcrash.cpp:611
#4  0x00007ff0ee2519e0 in <signal handler called> () at /usr/lib/libc.so.6
#5  KScreen::Output::id() const (this=0x0) at output.cpp:189
#6  0x00007ff0d408171d in KScreen::Config::setOutputPriority(QSharedPointer<KScreen::Output> const&, unsigned int) (this=0x7ff0dc006980, output=..., priority=1) at qsharedpointer_impl.h:301
#7  0x00007ff0d408b26f in KScreen::SetConfigOperationPrivate::fixPrimaryOutput() (this=<optimized out>) at qsharedpointer_impl.h:301
#8  KScreen::SetConfigOperation::start() (this=0x55dd8d2953c0) at setconfigoperation.cpp:114
#9  0x00007ff0eeab1a70 in QObject::event(QEvent*) (this=0x55dd8d2953c0, e=0x55dd8cfd9720) at qobject.cpp:1347
#10 0x00007ff0ef978b5c in QApplicationPrivate::notify_helper(QObject*, QEvent*) (this=<optimized out>, receiver=0x55dd8d2953c0, e=0x55dd8cfd9720) at qapplication.cpp:3640
#11 0x00007ff0eea8de08 in QCoreApplication::notifyInternal2(QObject*, QEvent*) (receiver=0x55dd8d2953c0, event=0x55dd8cfd9720) at qcoreapplication.cpp:1064
#12 0x00007ff0eea8e913 in QCoreApplicationPrivate::sendPostedEvents(QObject*, int, QThreadData*) (receiver=0x0, event_type=0, data=0x55dd8c9e4f20) at qcoreapplication.cpp:1821
#13 0x00007ff0eead4d48 in postEventSourceDispatch(GSource*, GSourceFunc, gpointer) (s=0x55dd8caf3950) at qeventdispatcher_glib.cpp:277
#14 0x00007ff0eda6d87b in g_main_dispatch (context=0x7ff0e4005010) at gmain.c:3454
#15 g_main_context_dispatch (context=0x7ff0e4005010) at gmain.c:4172
#16 0x00007ff0edac4c89 in g_main_context_iterate.constprop.0 (context=0x7ff0e4005010, block=1, dispatch=1, self=<optimized out>) at gmain.c:4248
#17 0x00007ff0eda6c132 in g_main_context_iteration (context=0x7ff0e4005010, may_block=1) at gmain.c:4313
#18 0x00007ff0eead8b2c in QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) (this=0x55dd8caf7f20, flags=...) at qeventdispatcher_glib.cpp:423
#19 0x00007ff0eea865ac in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) (this=0x7ffd4d226bf0, flags=...) at qflags.h:69
#20 0x00007ff0eea910d9 in QCoreApplication::exec() () at qflags.h:121
#21 0x00007ff0eef39fe2 in QGuiApplication::exec() () at qguiapplication.cpp:1870
#22 0x00007ff0ef976f2a in QApplication::exec() () at qapplication.cpp:2832
#23 0x000055dd8ab71040 in main(int, char**) (argc=<optimized out>, argv=<optimized out>) at kded.cpp:785

STEPS TO REPRODUCE
Happens every time monitor wakes from sleep.

ADDITIONAL INFORMATION
I only have a single display connected via display port, nothing special.

cat .local/share/kscreen/a37e14e3c2e6a407e13f5a947ec3f01a
[
    {
        "enabled": true,
        "id": "8da2bf5db1a73ca49dd6dc4ceb00755b",
        "metadata": {
            "fullname": "xrandr-LG Electronics-LG Ultra HD-406240",
            "name": "DisplayPort-0"
        },
        "mode": {
            "refresh": 59.99662399291992,
            "size": {
                "height": 2160,
                "width": 3840
            }
        },
        "overscan": 0,
        "pos": {
            "x": 0,
            "y": 0
        },
        "priority": 1,
        "rgbrange": 0,
        "rotation": 1,
        "scale": 1,
        "vrrpolicy": 2
    }
]
cat .local/share/kscreen/outputs/8da2bf5db1a73ca49dd6dc4ceb00755b
{
    "id": "8da2bf5db1a73ca49dd6dc4ceb00755b",
    "metadata": {
        "fullname": "xrandr-LG Electronics-LG Ultra HD-406240",
        "name": "DisplayPort-0"
    },
    "mode": {
        "refresh": 59.99662399291992,
        "size": {
            "height": 2160,
            "width": 3840
        }
    },
    "overscan": 0,
    "rgbrange": 0,
    "rotation": 1,
    "scale": 1,
    "vrrpolicy": 2
}
Comment 1 Guillaume Castagnino 2023-01-29 10:28:06 UTC
I can report the same crash here with kf 5.102 and plasma 5.26.90. The crash did not occur with plasma 5.26.5
Only one monitor connected using DP, the crash can be triggered simply by powering off/on the monitor. It seems to crash when powering back on the screen.

I did not manage to get a stacktrace yet.

Nothing special in log files when powering on the screen as you can see:
janv. 29 11:11:26 dagobah kded5[836]: colord: Setting X atom (id: 0 ) "_ICC_PROFILE" on output: "DP-1"
janv. 29 11:11:26 dagobah dbus-daemon[539]: [session uid=1000 pid=539] Activating via systemd: service name='org.kde.kscreen.osdService' unit='plasma-kscreen-osd.service' requested by ':1.12' (uid=1000 pid=836 comm="/usr/bin/kded5")
janv. 29 11:11:26 dagobah systemd[504]: Starting plasma-kscreen-osd.service...
janv. 29 11:11:26 dagobah dbus-daemon[539]: [session uid=1000 pid=539] Successfully activated service 'org.kde.kscreen.osdService'
janv. 29 11:11:26 dagobah systemd[504]: Started plasma-kscreen-osd.service.
janv. 29 11:11:27 dagobah kscreen_backend_launcher[1037]: kscreen.xrandr: Emitting configChanged()
janv. 29 11:11:27 dagobah kded5[836]: KCrash: Attempting to start /usr/bin/kded5
janv. 29 11:11:27 dagobah kded5[836]: KCrash: crashing... crashRecursionCounter = 2
janv. 29 11:11:27 dagobah kded5[836]: KCrash: Application Name = kded5 path = /usr/bin pid = 836
janv. 29 11:11:27 dagobah kded5[836]: KCrash: Arguments: /usr/bin/kded5
janv. 29 11:11:27 dagobah ksmserver[1330]: 11:11:27.832 WARN  unknown                          env says KDE is running but SNI unavailable -- check KDE_FULL_SESSION and XDG_CURRENT_DESKTOP
janv. 29 11:11:27 dagobah keepassxc[1023]: kf.notifications: env says KDE is running but SNI unavailable -- check KDE_FULL_SESSION and XDG_CURRENT_DESKTOP
janv. 29 11:11:27 dagobah fookb[1154]: kf.notifications: env says KDE is running but SNI unavailable -- check KDE_FULL_SESSION and XDG_CURRENT_DESKTOP
janv. 29 11:11:27 dagobah systemd[504]: plasma-kded.service: Main process exited, code=dumped, status=11/SEGV
janv. 29 11:11:27 dagobah systemd[504]: plasma-kded.service: Failed with result 'core-dump'.
janv. 29 11:11:36 dagobah plasmashell[898]: trying to show an empty dialog
Comment 2 Guillaume Castagnino 2023-01-31 07:45:28 UTC
Created attachment 155820 [details]
libkscreen-crash.patch

This is probably not the correct fix, but this small patch in libkscreen fixes the issue for me.
Comment 3 Fushan Wen 2023-02-01 01:41:49 UTC
(In reply to Guillaume Castagnino from comment #2)
> Created attachment 155820 [details]
> libkscreen-crash.patch
> 
> This is probably not the correct fix, but this small patch in libkscreen
> fixes the issue for me.

The patch looks sane, would you like to create a merge request?
Comment 4 Guillaume Castagnino 2023-02-01 05:59:35 UTC
(In reply to Fushan Wen from comment #3)
> The patch looks sane, would you like to create a merge request?

Honestly, I do not think that’s the correct fix. It hides the crash, but I assume there is some flaw before this somewhere in the logic. In this case, we may fall under the case where the monitor is already primary but still disabled (here: https://invent.kde.org/plasma/libkscreen/-/blob/master/src/setconfigoperation.cpp#L175) . But is this not a race condition? Shouldn’t the screen be already woken-up when entering this code?
With my patch, you may end with no primary at all, or multiple primary when exiting fixPrimaryOutput().

So I think there is something better to do than this patch that is just hiding things. The only purpose of this patch was in fact to narrow down the crash location and workaround until we get a proper fix :)
Comment 5 David Edmundson 2023-02-10 11:10:13 UTC
Git commit 8a436ad524cd961bf9e367d83b5872af77645d9c by David Edmundson.
Committed on 10/02/2023 at 11:09.
Pushed by davidedmundson into branch 'master'.

Fix potential crash setting new configs

If we get a setConfigOperation with entirely disabled outputs we would
not have a valid primary screen. At this point we would call
setPrimaryOutput with a null pointer.

M  +1    -1    src/setconfigoperation.cpp

https://invent.kde.org/plasma/libkscreen/commit/8a436ad524cd961bf9e367d83b5872af77645d9c
Comment 6 David Edmundson 2023-02-10 11:10:42 UTC
Git commit d42dea00822c1cfb7478d1d55746e0750156918b by David Edmundson.
Committed on 10/02/2023 at 11:10.
Pushed by davidedmundson into branch 'Plasma/5.27'.

Fix potential crash setting new configs

If we get a setConfigOperation with entirely disabled outputs we would
not have a valid primary screen. At this point we would call
setPrimaryOutput with a null pointer.


(cherry picked from commit 8a436ad524cd961bf9e367d83b5872af77645d9c)

M  +1    -1    src/setconfigoperation.cpp

https://invent.kde.org/plasma/libkscreen/commit/d42dea00822c1cfb7478d1d55746e0750156918b
Comment 7 Nate Graham 2023-02-22 00:05:55 UTC
*** Bug 466036 has been marked as a duplicate of this bug. ***
Comment 8 Nate Graham 2023-02-22 00:05:59 UTC
*** Bug 466006 has been marked as a duplicate of this bug. ***
Comment 9 Nate Graham 2023-02-22 00:06:40 UTC
Re-opening as we are getting more crash reports with the same backtrace from users on 5.27, which is the release that was supposed to have fixed this.
Comment 10 Guillaume Castagnino 2023-02-22 08:03:25 UTC
Indeed, looking at git history, it seems it missed 5.27 and is for 5.27.1. I had to patch manually over 5.27.
Comment 11 Nicolas Fella 2023-02-22 11:19:11 UTC
*** Bug 466223 has been marked as a duplicate of this bug. ***
Comment 12 Nate Graham 2023-02-22 20:52:38 UTC
Right right right, well spotted!