Bug 450531

Summary: Portal crashed inQGuiApplicationPrivate::createPlatformIntegration() after changing display scale to 125% on X11, logout and login
Product: [Plasma] xdg-desktop-portal-kde Reporter: Patrick Silva <bugseforuns>
Component: generalAssignee: Plasma Bugs List <plasma-bugs>
Status: RESOLVED FIXED    
Severity: crash CC: aleixpol, jgrulich, nate, sitter
Priority: NOR    
Version: 5.24.1   
Target Milestone: ---   
Platform: Arch Linux   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:

Description Patrick Silva 2022-02-18 18:13:02 UTC
SUMMARY
I changed display scale from 100% to 125% on X11, logged out, started X11 session again and got a black screen with mouse pointer. coredumpctl command revealed xdg-desktop-portal-kde crash.

SOFTWARE/OS VERSIONS
Operating System: Arch Linux
KDE Plasma Version: 5.24.1
KDE Frameworks Version: 5.91.0
Qt Version: 5.15.2
Kernel Version: 5.16.10-arch1-1 (64-bit)
Graphics Platform: X11


Thread 1 (Thread 0x7fc37b040a80 (LWP 4778)):
#0  0x00007fc37f5ed34c in __pthread_kill_implementation () from /usr/lib/libc.so.6
#1  0x00007fc37f5a04b8 in raise () from /usr/lib/libc.so.6
#2  0x00007fc37f58a534 in abort () from /usr/lib/libc.so.6
#3  0x00007fc37fa2dee4 in qt_message_fatal (message=<synthetic pointer>..., context=...) at global/qlogging.cpp:1914
#4  QMessageLogger::fatal (this=this@entry=0x7ffc55380870, msg=msg@entry=0x7fc380c07f69 "%s") at global/qlogging.cpp:893
#5  0x00007fc3807a2bc5 in init_platform (argv=<optimized out>, argc=@0x7ffc55380860: 1817763088, platformThemeName=..., platformPluginPath=..., pluginNamesWithArguments=...) at kernel/qguiapplication.cpp:1254
#6  QGuiApplicationPrivate::createPlatformIntegration (this=0x55b06c58bce0) at kernel/qguiapplication.cpp:1481
#7  0x00007fc3807a31e9 in QGuiApplicationPrivate::createEventDispatcher (this=<optimized out>) at kernel/qguiapplication.cpp:1498
#8  0x00007fc37fc2067b in QCoreApplicationPrivate::init (this=this@entry=0x55b06c58bce0) at kernel/qcoreapplication.cpp:835
#9  0x00007fc3807a32a7 in QGuiApplicationPrivate::init (this=this@entry=0x55b06c58bce0) at kernel/qguiapplication.cpp:1527
#10 0x00007fc38138337e in QApplicationPrivate::init (this=0x55b06c58bce0) at kernel/qapplication.cpp:513
#11 0x00007fc3813834a4 in QApplication::QApplication (this=<optimized out>, argc=<optimized out>, argv=<optimized out>, _internal=<optimized out>, this=<optimized out>, argc=<optimized out>, argv=<optimized out>, _internal=<optimized out>) at kernel/qapplication.cpp:501
#12 0x000055b06b5e10d1 in main (argc=<optimized out>, argv=0x7ffc55380c88) at /usr/src/debug/xdg-desktop-portal-kde-5.24.1/src/xdg-desktop-portal-kde.cpp:25
Comment 1 Nate Graham 2022-02-21 22:42:36 UTC
#5  0x00007fc3807a2bc5 in init_platform (argv=<optimized out>, argc=@0x7ffc55380860: 1817763088, platformThemeName=..., platformPluginPath=..., pluginNamesWithArguments=...) at kernel/qguiapplication.cpp:1254
#6  QGuiApplicationPrivate::createPlatformIntegration (this=0x55b06c58bce0) at kernel/qguiapplication.cpp:1481

No platform theme name maybe?
Comment 2 Harald Sitter 2022-04-04 08:37:00 UTC
Yes. I rather think that the process was from the previous session though. Notably I suspect that if the logout hadn't completed properly (i.e. processes lingered on) then conceivably dbus-daemon would have tried to activate the portal in the wrong context (the one from the previous session) and that then failed to load a platform plugin because neither x nor wayland were on that context anymore. It'd also explain why the session as a whole broke even though portal isn't a required piece of session startup - dbus-daemon is required to function properly.

Is this problem reproducible?
Comment 3 Aleix Pol 2022-04-04 10:38:17 UTC
Maybe we should listen to SIGTERM and close it when we receive it? It's weird that xdp is the only process with this problem though...
Comment 4 Harald Sitter 2022-04-04 11:18:51 UTC
I suspect it happens loads, we just never hear about it because drkonqi isn't able to detect or action these crashes. e.g. on ubuntu's error tracker (the one that is based on coredumps) failing to find a suitable platform is in the top 15 crashers for dolphin.

It may be that this is more likely for the portal, what with being dbus activated and thus (maybe?) having an easier time escaping session shutdown. e.g. ubuntu's error tracker has magnitudes more errors form the portal than from dolphin on this particular trace (it is in fact the top crasher for the portal). 

Going off on a tangent: it may make sense to move ahead with drkonqi-coredump integration to get reports from crashes like this.
Comment 5 Patrick Silva 2022-04-04 13:32:44 UTC
I was able to reproduce the black screen with cursor again, but coredumpctl command gave me no coredump this time.

1. change display scale from 100% to 125% on X11
2. logout
3. quickly type your password and press enter/return key

Here is the journalctl log:
abr 04 10:16:23 Arch-PC systemd[2347]: Finished Exit the Session.
abr 04 10:16:23 Arch-PC systemd[2347]: Reached target Exit the Session.
abr 04 10:16:23 Arch-PC systemd[1]: user@977.service: Deactivated successfully.
abr 04 10:16:23 Arch-PC systemd[1]: Stopped User Manager for UID 977.
abr 04 10:16:23 Arch-PC audit[1]: SERVICE_STOP pid=1 uid=0 auid=4294967295 ses=4294967295 msg='unit=user@977 comm="systemd" exe="/usr/lib/systemd/systemd" hostname=? addr=? terminal=? res=success'
abr 04 10:16:23 Arch-PC kernel: kauditd_printk_skb: 17 callbacks suppressed
abr 04 10:16:23 Arch-PC kernel: audit: type=1131 audit(1649078183.558:287): pid=1 uid=0 auid=4294967295 ses=4294967295 msg='unit=user@977 comm="systemd" exe="/usr/lib/systemd/systemd" hostname=? addr=? terminal=? res=success'
abr 04 10:16:23 Arch-PC systemd[1]: Stopping User Runtime Directory /run/user/977...
abr 04 10:16:23 Arch-PC systemd[1]: run-user-977.mount: Deactivated successfully.
abr 04 10:16:23 Arch-PC systemd[1]: user-runtime-dir@977.service: Deactivated successfully.
abr 04 10:16:23 Arch-PC systemd[1]: Stopped User Runtime Directory /run/user/977.
abr 04 10:16:23 Arch-PC audit[1]: SERVICE_STOP pid=1 uid=0 auid=4294967295 ses=4294967295 msg='unit=user-runtime-dir@977 comm="systemd" exe="/usr/lib/systemd/systemd" hostname=? addr=? terminal=? res=success'
abr 04 10:16:23 Arch-PC systemd[1]: Removed slice User Slice of UID 977.
abr 04 10:16:23 Arch-PC systemd[1]: user-977.slice: Consumed 1.620s CPU time.
abr 04 10:16:23 Arch-PC kernel: audit: type=1131 audit(1649078183.568:288): pid=1 uid=0 auid=4294967295 ses=4294967295 msg='unit=user-runtime-dir@977 comm="systemd" exe="/usr/lib/systemd/systemd" hostname=? addr=? terminal=? res=success'
abr 04 10:16:27 Arch-PC dbus-daemon[782]: [session uid=1003 pid=782] Activating via systemd: service name='org.kde.krunner' unit='plasma-krunner.service' requested by ':1.179' (uid=1003 pid=2458 comm="/usr/bin/kglobalaccel5")
abr 04 10:16:27 Arch-PC systemd[770]: Starting KRunner...
abr 04 10:16:27 Arch-PC dbus-daemon[782]: [session uid=1003 pid=782] Successfully activated service 'org.kde.krunner'
abr 04 10:16:27 Arch-PC systemd[770]: Started KRunner.
abr 04 10:16:28 Arch-PC krunner[2550]: QCommandLineParser: argument list cannot be empty, it should contain at least the executable name
abr 04 10:16:30 Arch-PC systemd[1]: systemd-localed.service: Deactivated successfully.
abr 04 10:16:30 Arch-PC audit[1]: SERVICE_STOP pid=1 uid=0 auid=4294967295 ses=4294967295 msg='unit=systemd-localed comm="systemd" exe="/usr/lib/systemd/systemd" hostname=? addr=? terminal=? res=success'
abr 04 10:16:30 Arch-PC kernel: audit: type=1131 audit(1649078190.548:289): pid=1 uid=0 auid=4294967295 ses=4294967295 msg='unit=systemd-localed comm="systemd" exe="/usr/lib/systemd/systemd" hostname=? addr=? terminal=? res=success'
abr 04 10:16:30 Arch-PC audit: BPF prog-id=0 op=UNLOAD
abr 04 10:16:30 Arch-PC audit: BPF prog-id=0 op=UNLOAD
abr 04 10:16:30 Arch-PC audit: BPF prog-id=0 op=UNLOAD
abr 04 10:16:30 Arch-PC kernel: audit: type=1334 audit(1649078190.601:290): prog-id=0 op=UNLOAD
abr 04 10:16:30 Arch-PC kernel: audit: type=1334 audit(1649078190.601:291): prog-id=0 op=UNLOAD
abr 04 10:16:30 Arch-PC kernel: audit: type=1334 audit(1649078190.601:292): prog-id=0 op=UNLOAD
abr 04 10:16:31 Arch-PC krunner[2550]: kf.sonnet.core: Sonnet: Unable to load plugin "/usr/lib/qt/plugins/kf5/sonnet/sonnet_hspell.so" Error: "Cannot load library /usr/lib/qt/plugins/kf5/sonnet/sonnet_hspell.so: (libhspell.so.0: não é possível abrir arquivo compartilhado: Arquivo ou diretório inexistente)"
abr 04 10:16:31 Arch-PC krunner[2550]: kf.sonnet.core: Sonnet: Unable to load plugin "/usr/lib/qt/plugins/kf5/sonnet/sonnet_hspell.so" Error: "Cannot load library /usr/lib/qt/plugins/kf5/sonnet/sonnet_hspell.so: (libhspell.so.0: não é possível abrir arquivo compartilhado: Arquivo ou diretório inexistente)"
abr 04 10:16:31 Arch-PC qdbus[2173]: Cannot find 'org.kde.KSplash.setStage' in object /KSplash at org.kde.KSplash
abr 04 10:16:31 Arch-PC systemd[770]: Finished KSplash "ready" Stage.
abr 04 10:16:31 Arch-PC dbus-daemon[782]: [session uid=1003 pid=782] Activating via systemd: service name='org.kde.runners.baloo' unit='plasma-baloorunner.service' requested by ':1.185' (uid=1003 pid=2550 comm="/usr/bin/krunner")
abr 04 10:16:31 Arch-PC systemd[770]: Starting KRunner provider for baloo file indexer...
abr 04 10:16:32 Arch-PC dbus-daemon[782]: [session uid=1003 pid=782] Successfully activated service 'org.kde.runners.baloo'
abr 04 10:16:32 Arch-PC systemd[770]: Started KRunner provider for baloo file indexer.
abr 04 10:16:33 Arch-PC systemd[770]: Started Konsole - Terminal.
abr 04 10:16:33 Arch-PC kwin_x11[2426]: qt.qpa.xcb: QXcbConnection: XCB error: 3 (BadWindow), sequence: 1739, resource id: 29360210, major code: 3 (GetWindowAttributes), minor code: 0
abr 04 10:16:33 Arch-PC kwin_x11[2426]: qt.qpa.xcb: QXcbConnection: XCB error: 9 (BadDrawable), sequence: 1740, resource id: 29360210, major code: 14 (GetGeometry), minor code: 0
abr 04 10:16:34 Arch-PC PackageKit[755]: get-updates transaction /5_aeacdbab from uid 1003 finished with success after 3ms
abr 04 10:16:34 Arch-PC kernel: r8169 0000:04:00.0 enp4s0: Rx ERROR. status = 352ac5ed
abr 04 10:16:35 Arch-PC dbus-daemon[433]: [system] Activating via systemd: service name='org.freedesktop.locale1' unit='dbus-org.freedesktop.locale1.service' requested by ':1.208' (uid=1003 pid=2434 comm="/usr/lib/DiscoverNotifier")
abr 04 10:16:35 Arch-PC audit: BPF prog-id=63 op=LOAD
abr 04 10:16:35 Arch-PC audit: BPF prog-id=64 op=LOAD
abr 04 10:16:35 Arch-PC audit: BPF prog-id=65 op=LOAD
abr 04 10:16:35 Arch-PC systemd[1]: Starting Locale Service...
abr 04 10:16:35 Arch-PC kernel: audit: type=1334 audit(1649078195.805:293): prog-id=63 op=LOAD
abr 04 10:16:35 Arch-PC kernel: audit: type=1334 audit(1649078195.805:294): prog-id=64 op=LOAD
abr 04 10:16:35 Arch-PC kernel: audit: type=1334 audit(1649078195.805:295): prog-id=65 op=LOAD
abr 04 10:16:35 Arch-PC dbus-daemon[433]: [system] Successfully activated service 'org.freedesktop.locale1'
abr 04 10:16:35 Arch-PC systemd[1]: Started Locale Service.
abr 04 10:16:35 Arch-PC audit[1]: SERVICE_START pid=1 uid=0 auid=4294967295 ses=4294967295 msg='unit=systemd-localed comm="systemd" exe="/usr/lib/systemd/systemd" hostname=? addr=? terminal=? res=success'
abr 04 10:16:35 Arch-PC kernel: audit: type=1130 audit(1649078195.861:296): pid=1 uid=0 auid=4294967295 ses=4294967295 msg='unit=systemd-localed comm="systemd" exe="/usr/lib/systemd/systemd" hostname=? addr=? terminal=? res=success'
abr 04 10:16:36 Arch-PC kernel: r8169 0000:04:00.0 enp4s0: Rx ERROR. status = 352ac5ea
abr 04 10:16:36 Arch-PC kernel: r8169 0000:04:00.0 enp4s0: Rx ERROR. status = 352ac5ee
abr 04 10:16:38 Arch-PC plasma_waitforname[1977]: org.kde.knotifications: WaitForName: Service was not registered within timeout
abr 04 10:16:38 Arch-PC dbus-daemon[782]: [session uid=1003 pid=782] Activated service 'org.kde.KSplash' failed: Process org.kde.KSplash exited with status 1
abr 04 10:16:42 Arch-PC pamac-tray-plas[2435]: updates_checker.vala:101: 4 updates found


If I wait 1 minute between the steps 2 and 3, my session starts correctly. I use systemd startup if it matters.
Unfortunatly black screen with cursor occurs often on my system and sometimes several coredumps occur
after logout and login. I have reported some bugs regarding this:
bug 451939 (read comment 4)
bug 450320
Comment 6 Harald Sitter 2022-04-05 11:38:04 UTC
I really think this is more of a symptom than anything. Also explains the other bugs you've reported.

The similar report bug #452269 has some additional data which shows half the processes falling on the nose rather than getting shut down properly.
Comment 7 David Edmundson 2023-09-29 14:32:05 UTC
Git commit 6ce8f434139f47e6a71bf0b68beae92be8845ce4 by David Edmundson.
Committed on 29/09/2023 at 16:31.
Pushed by davidedmundson into branch 'master'.

Use systemd to handle more of the shutdown

Previously we killed kwin manually, then tried to exit the session.
This is racey as kwin will close all connections, before systemd has
realised that the session is ending this can cause all apps to restart.

Also closing plasma-workspace-wayland.target is ineffective, closing the
graphical-session implicitly brings down the session more explicitly.
It'll close the other targets and services.
Related: bug 473824, bug 409088, bug 451939, bug 450320, bug 434403

Tested by looking at `coredumpctl list` after a logout and seeing it go from 10 entries of silly aborts restarting without a display server to 3, with different unrelated causes.

M  +12   -4    startkde/plasma-shutdown/shutdown.cpp

https://invent.kde.org/plasma/plasma-workspace/-/commit/6ce8f434139f47e6a71bf0b68beae92be8845ce4