Bug 467298

Summary: kwin_wayland segfaults in KWaylandServer::OutputInterface::handle() on screen off when system is locked
Product: [Plasma] kwin Reporter: Mark S <wolfendeathx>
Component: generalAssignee: KWin default assignee <kwin-bugs-null>
Status: RESOLVED DUPLICATE    
Severity: crash CC: kde, postix
Priority: NOR    
Version: 5.27.2   
Target Milestone: ---   
Platform: Arch Linux   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:
Attachments: kwin_wayland lockscreen crash stacktrace

Description Mark S 2023-03-13 20:20:30 UTC
Created attachment 157244 [details]
kwin_wayland lockscreen crash stacktrace

SUMMARY

`kwin_wayland` segfaults in `KWaylandServer::OutputInterface::handle()` if computer sits on the lock screen for the amount of time set in `System Settings > Power Management > Energy Saving > On AC Power > Screen Energy Saving`. This happens sometimes on closing and opening the lid of the laptop as well, but it's less frequent whereas the steps described below reproduce the problem 100% of the time for me.

Stack trace of dumped core is in attached file `kwin_wayland-lockscreen-crash-stacktrace.txt`.

Backtrace from `debuginfod` and `gdb`:

```
#0  0x00007f65999d2f14 in KWaylandServer::OutputInterface::handle() const () at /usr/lib/libkwin.so.5
#1  0x00007f65999c59c0 in  () at /usr/lib/libkwin.so.5
#2  0x00007f65999c5d5a in  () at /usr/lib/libkwin.so.5
#3  0x00007f6597ebea71 in  () at /usr/lib/libQt5Core.so.5
#4  0x00007f65997c495e in KWin::Output::setState(KWin::Output::State const&) () at /usr/lib/libkwin.so.5
#5  0x00007f659997ccba in KWin::DrmOutput::updateDpmsMode(KWin::Output::DpmsMode) () at /usr/lib/libkwin.so.5
#6  0x00007f659997dd64 in KWin::DrmOutput::setDrmDpmsMode(KWin::Output::DpmsMode) () at /usr/lib/libkwin.so.5
#7  0x00007f6597ebea71 in  () at /usr/lib/libQt5Core.so.5
#8  0x00007f6597ec0fcf in QTimer::timeout(QTimer::QPrivateSignal) () at /usr/lib/libQt5Core.so.5
#9  0x00007f6597eb1b56 in QObject::event(QEvent*) () at /usr/lib/libQt5Core.so.5
#10 0x00007f6597578b5c in QApplicationPrivate::notify_helper(QObject*, QEvent*) () at /usr/lib/libQt5Widgets.so.5
#11 0x00007f6597e8df48 in QCoreApplication::notifyInternal2(QObject*, QEvent*) () at /usr/lib/libQt5Core.so.5
#12 0x00007f6597ed84b3 in QTimerInfoList::activateTimers() () at /usr/lib/libQt5Core.so.5
#13 0x00007f6597ed8962 in QEventDispatcherUNIX::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) () at /usr/lib/libQt5Core.so.5
#14 0x000055c6dfaf95f2 in  ()
#15 0x00007f6597e866ec in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) () at /usr/lib/libQt5Core.so.5
#16 0x00007f6597e91219 in QCoreApplication::exec() () at /usr/lib/libQt5Core.so.5
#17 0x000055c6dfa16242 in  ()
#18 0x00007f6596e3c790 in  () at /usr/lib/libc.so.6
#19 0x00007f6596e3c84a in __libc_start_main () at /usr/lib/libc.so.6
#20 0x000055c6dfa17e95 in  ()
```

STEPS TO REPRODUCE

1. In `System Settings > Power Management > Energy Saving > On AC Power` set a time for `Screen Energy Saving` (mine was set for 30 minutes)
2. (_likely_ optional) On the same page, uncheck `Suspend Session`
3. Lock the machine and let it sit for the time set in step 1

OBSERVED RESULT

One of two things happens:

1. Upon entering the correct password on the lock screen, the login prompt it replaced with a button that says "Unlock" that doesn't do anything.
2. Upon waking up the machine the 'The screen locker is broken and unlocking is not possible anymore.` screen is present.

For both outcomes, only `sudo loginctl unlock-sessions` in a separate tty is able to restore the session. Once the session is unlocked, all applications have closed (in `journalctl` after the segfault, all services report `kactivitymanagerd[1213]: The Wayland connection broke. Did the Wayland compositor die?` but with the appropriate service name/number).

EXPECTED RESULT

Able to log back in as normal.

SOFTWARE/OS VERSIONS

Operating System: Arch Linux 
KDE Plasma Version: 5.27.2
KDE Frameworks Version: 5.103.0
Qt Version: 5.15.8
Kernel Version: 6.2.2-arch1-g14-1 (64-bit)
Graphics Platform: Wayland
Processors: 16 × AMD Ryzen 9 6900HS with Radeon Graphics
Memory: 38.4 GiB of RAM
Graphics Processor: AMD Radeon RX 6700S
Manufacturer: ASUSTeK COMPUTER INC.
Product Name: ROG Zephyrus G14 GA402RJ_GA402RJ
System Version: 1.0
Comment 1 David Edmundson 2023-03-14 12:53:08 UTC

*** This bug has been marked as a duplicate of bug 467234 ***
Comment 2 postix 2023-03-25 15:17:13 UTC

*** This bug has been marked as a duplicate of bug 466346 ***