Bug 465456 - kwin_wayland often crashed when used as the sddm Wayland compositor and logging out of Plasma resulting in a black screen
Summary: kwin_wayland often crashed when used as the sddm Wayland compositor and loggi...
Status: RESOLVED FIXED
Alias: None
Product: kwin
Classification: Plasma
Component: wayland-generic (show other bugs)
Version: 5.26.90
Platform: Fedora RPMs Linux
: NOR crash
Target Milestone: ---
Assignee: KWin default assignee
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-02-08 04:15 UTC by Matt Fagnani
Modified: 2023-02-24 01:34 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In: 5.27.2


Attachments
Full trace of all threads of kwin_wayland crash when logging out of Plasma as sddm Wayland compositor (27.21 KB, text/plain)
2023-02-08 04:15 UTC, Matt Fagnani
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Matt Fagnani 2023-02-08 04:15:48 UTC
Created attachment 156057 [details]
Full trace of all threads of kwin_wayland crash when logging out of Plasma as sddm Wayland compositor

SUMMARY

I started Plasma 5.26.90 on Wayland in GNOME Boxes QEMU/KVM VMs using the Fedora Rawhide live image Fedora-KDE-Live-x86_64-Rawhide-20230207.n.0.iso (and earlier) with 3D acceleration disabled using the llvmpipe mesa driver from mesa 22.3.3 (or 3D acceleration enabled using the virgl mesa driver). I disabled automatic login from sddm in System Settings. I logged out from the Application Launcher menu. kwin_wayland often crashed when used as the sddm Wayland compositor when logging out resulting in a black screen with a flashing text cursor appearing instead of sddm. The crashes occurred in KWin::Workspace::geometry and might've been null pointer dereferences since this=0x0.

Core was generated by `/usr/bin/kwin_wayland --no-lockscreen --inputmethod maliit-keyboard --locale1'.
Program terminated with signal SIGSEGV, Segmentation fault.
#0  KWin::Workspace::geometry (this=0x0) at /usr/src/debug/kwin-5.26.90-1.fc38.x86_64/src/workspace.cpp:2671
2671        return m_geometry;
[Current thread is 1 (Thread 0x7f250aaaae40 (LWP 3986))]

(gdb) bt
#0  KWin::Workspace::geometry (this=0x0) at /usr/src/debug/kwin-5.26.90-1.fc38.x86_64/src/workspace.cpp:2671
#1  0x00007f250b5c4f61 in KWin::LibInput::Connection::processEvents (this=0x55ed1ebd4000)
    at /usr/src/debug/kwin-5.26.90-1.fc38.x86_64/src/backends/libinput/connection.cpp:376
#2  0x00007f2509adefdb in QObject::event (this=0x55ed1ebc0fd0, e=0x7f24e40056d0) at kernel/qobject.cpp:1347
#3  0x00007f2508faece5 in QApplicationPrivate::notify_helper (this=<optimized out>, receiver=0x55ed1ebc0fd0, 
    e=0x7f24e40056d0) at kernel/qapplication.cpp:3640
#4  0x00007f2509ab35e8 in QCoreApplication::notifyInternal2 (receiver=0x55ed1ebc0fd0, event=0x7f24e40056d0)
    at kernel/qcoreapplication.cpp:1064
#5  0x00007f2509ab6a95 in QCoreApplicationPrivate::sendPostedEvents (receiver=receiver@entry=0x0, 
    event_type=event_type@entry=0, data=data@entry=0x55ed1eb2abc0) at kernel/qcoreapplication.cpp:1821
#6  0x00007f2509b03311 in QEventDispatcherUNIX::processEvents (this=0x55ed1eb2d940, flags=...)
    at kernel/qeventdispatcher_unix.cpp:468
#7  0x000055ed1e4a0041 in QUnixEventDispatcherQPA::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) ()
#8  0x00007f2509ab1fbb in QEventLoop::exec (this=this@entry=0x7ffc15e20460, flags=..., flags@entry=...)
    at ../../include/QtCore/../../src/corelib/global/qflags.h:69
#9  0x00007f2509aba23b in QCoreApplication::exec ()
    at ../../include/QtCore/../../src/corelib/global/qflags.h:121
#10 0x00007f2509f5f5bd in QGuiApplication::exec () at kernel/qguiapplication.cpp:1863
#11 0x00007f2508faec59 in QApplication::exec () at kernel/qapplication.cpp:2832
#12 0x000055ed1e3bcc24 in main (argc=<optimized out>, argv=<optimized out>)
    at /usr/src/debug/kwin-5.26.90-1.fc38.x86_64/src/main_wayland.cpp:628

I'm attaching the full trace of all threads.  This problem seemed to start after the update to sddm-0.19.0^git20230201.3ee57e9-2.fc38 https://koji.fedoraproject.org/koji/buildinfo?buildID=2145291 which fixed a problem where logging out of Plasma on Wayland to sddm on Wayland would show a text console instead of sddm https://bugzilla.redhat.com/show_bug.cgi?id=2110801 That problem might have been masking this one. 

This problem happened most of the times I logged out of Plasma to sddm in recent Fedora Rawhide KDE Plasma VMs. sddm occasionally appeared with a different looking theme where the user icon and password box were at the right side of the screen and the Desktop selection and options to reboot and shutdown were in a bar at the top of the screen

kwin_wayland sometimes crashed 1-10 times when Plasma started in similar VMs with the same type of trace. Plasma appeared in such cases unless kwin_wayland crashed 10 times and systemd stopped trying to start kwin_wayland.

This type of crash didn't seem to happen on bare metal with on a laptop with an AMD A10-9620P CPU and an integrated AMD Radeon R5 GPU using the radeonsi mesa driver and amdgpu kernel driver. The problem might be specific to running in VMs

STEPS TO REPRODUCE
1. Boot a Fedora 37 KDE Plasma installation updated to 2023-2-7 with updates-testing enabled
2. Log in to Plasma on Wayland
3. Download Fedora-KDE-Live-x86_64-Rawhide-20230207.n.0.iso from https://koji.fedoraproject.org/koji/buildinfo?buildID=2147622 
4. Install GNOME Boxes if it isn't already with sudo dnf install gnome-boxes
5. Start GNOME Boxes
6. boot the Fedora Rawhide live image Fedora-KDE-Live-x86_64-Rawhide-20230207.n.0.iso in a GNOME Boxes QEMU/KVM VM with 3D acceleration disabled using the llvmpipe driver, EFI enabled, and 3 GB RAM
7. Start System Settings in Plasma 5.26.90 on Wayland
8. Click Startup and Shutdown in the menu on the left of System Settings
9. Click Behavior in the Startup and Shutdown > Login Screen (SDDM) screen
10. Remove the check mark for Automatically log in
11. Click Apply
12. Close System Settings
13. Click the Application Launcher menu button at the bottom left of the screen
14. Click the Leave button in the Application Launcher menu
15. Click Log out
16. Select OK to Log out
17. If the kwin_wayland crash didn't happen, log in to Plasma and log out as above until it does

OBSERVED RESULT
kwin_wayland often crashed when used as the sddm Wayland compositor when logging out of Plasma resulting in a black screen

EXPECTED RESULT
kwin_wayland wouldn't crash and sddm would appear normally every time.

SOFTWARE/OS VERSIONS
Linux/KDE Plasma: Fedora Rawhide/38
(available in About System)
KDE Plasma Version: 5.26.90
KDE Frameworks Version: 5.103.0
Qt Version: 5.15.8

ADDITIONAL INFORMATION

When booting the Fedora Rawhide live image Fedora-KDE-Live-x86_64-Rawhide-20230202.n.0.iso with mesa-23.0.0~rc4-1.fc38 in a GNOME Boxes QEMU/KVM VM with 3D acceleration disabled using the llvmpipe driver, kwin_wayland crashed 10 times in a row as I reported at https://bugs.kde.org/show_bug.cgi?id=465284 I ran startx & from another VT. Plasma on X ran normally. I disabled automatic login from sddm in System Settings and logged out. kwin_wayland on Wayland as the sddm compositor crashed with the type of trace at https://bugs.kde.org/show_bug.cgi?id=465284 after logging out. The black screen problem with the flashing text cursor at the top left happened. mesa-23.0.0~rc4-1.fc38 was untagged from Rawhide due to this problem https://pagure.io/releng/issue/11247 so later images might have mesa-22.3.3-3.fc38 and so would have kwin_wayland crashes in KWin::Workspace::geometry.
Comment 1 Alessandro Astone 2023-02-22 19:24:29 UTC
The stacktrace points to https://invent.kde.org/plasma/kwin/-/blob/v5.27.1/src/backends/libinput/connection.cpp#L376

Indeed this is reproducible 100% of the times by just continuously moving the mouse after clicking logout. And never happens when keeping the mouse still.
Comment 2 Alessandro Astone 2023-02-22 19:27:49 UTC
Perhaps the same change as here should be applied https://invent.kde.org/plasma/kwin/-/commit/8386a8bb666891d92539a52375157e2c5b6987a2
Comment 3 Bug Janitor Service 2023-02-22 19:40:48 UTC
A possibly relevant merge request was started @ https://invent.kde.org/plasma/kwin/-/merge_requests/3667
Comment 4 Vlad Zahorodnii 2023-02-23 00:44:52 UTC
Git commit da26deaa5c843ef303ef9f1b9f0cd3d341c5c5f5 by Vlad Zahorodnii.
Committed on 22/02/2023 at 19:39.
Pushed by vladz into branch 'master'.

backends/libinput: Fix crash upon receiving motion absolute events

The input events can be processed when the workspace is not available,
e.g. during startup or shutdown, so add a corresponding guard.

As a long term plan, we need to decouple Workspace from low-level input
backend parts, but it will be a too invasive change for now.
Related: bug 449317

M  +3    -1    src/backends/libinput/connection.cpp

https://invent.kde.org/plasma/kwin/commit/da26deaa5c843ef303ef9f1b9f0cd3d341c5c5f5
Comment 5 Vlad Zahorodnii 2023-02-23 10:41:56 UTC
Git commit 6970199ccc6ff54badcbf2b33a22aada89c164cc by Vlad Zahorodnii.
Committed on 23/02/2023 at 07:23.
Pushed by vladz into branch 'Plasma/5.27'.

backends/libinput: Fix crash upon receiving motion absolute events

The input events can be processed when the workspace is not available,
e.g. during startup or shutdown, so add a corresponding guard.

As a long term plan, we need to decouple Workspace from low-level input
backend parts, but it will be a too invasive change for now.
Related: bug 449317


(cherry picked from commit da26deaa5c843ef303ef9f1b9f0cd3d341c5c5f5)

M  +3    -1    src/backends/libinput/connection.cpp

https://invent.kde.org/plasma/kwin/commit/6970199ccc6ff54badcbf2b33a22aada89c164cc