Bug 449957

Summary: KWin crash in KWin::PlacementArea() when connecting/disconnecting, enabling/disabling screens.
Product: [Plasma] kwin Reporter: phrxmd <philipp.reichmuth>
Component: multi-screenAssignee: KWin default assignee <kwin-bugs-null>
Status: RESOLVED DUPLICATE    
Severity: crash CC: aimlesslywalking, amessina, cd+kde, dev+kde, es, hsantanna, kde, kdebugs, kdebugs, ltstarwarskid, maxicarlos08, nate, peter, postix, sonichedgehog_hyperblast00, xaver.hugl
Priority: NOR Keywords: wayland
Version: 5.24.0   
Target Milestone: ---   
Platform: openSUSE   
OS: Linux   
Latest Commit: Version Fixed In:
Attachments: Backtrace
Backtrace of kwin_wayland monitor issue
New Trace
Somewhat more detailed backtrace /bt full/
Backtrace when this happens after waking up from monitor standby
Backtrace when this happens as a DisplayPort screen comes online

Description phrxmd 2022-02-10 17:50:19 UTC
SUMMARY
I have a monitor attached to a port of a Thunderbolt dock via DisplayPort. KWin crashes whenever I switch off the monitor, or unplug it, or unplug or switch off the dock it's attached to. 

STEPS TO REPRODUCE
1. Switch off the external monitor, or unplug it, or unplug or switch off the dock it's attached to.

OBSERVED RESULT
KWin crashes, taking down all applications.

In addition, when KWin comes up again right after the crash, I see the Akonadi crash reported in bug 445249.

EXPECTED RESULT
KWin should survive the disconnection.

SOFTWARE/OS VERSIONS
Operating System: openSUSE Tumbleweed 20220207
KDE Plasma Version: 5.24.0
KDE Frameworks Version: 5.90.0
Qt Version: 5.15.2
Kernel Version: 5.16.5-1-default (64-bit)
Graphics Platform: Wayland
Processors: 8 × Intel® Core™ i7-8550U CPU @ 1.80GHz
Memory: 15.5 GiB of RAM
Graphics Processor: Mesa Intel® UHD Graphics 620

The machine is a Thinkpad X1 Yoga 3rd, the dock is a Lenovo Thunderbolt 3 dock.

ADDITIONAL INFORMATION
The bug has been present for a while, at least since 5.23, so it's not a 5.24 regression. I didn't report it earlier because I mistook it for bug 438839.
Comment 1 phrxmd 2022-02-10 17:52:08 UTC
I realize the information provided is probably not very helpful. What would be the best way to get a backtrace or detailed log output?
Comment 2 phrxmd 2022-02-10 18:18:02 UTC
In addition, after the crash Desktop Grid shows the visual errors described in bug 449960 until I reboot.
Comment 3 Vlad Zahorodnii 2022-02-10 18:32:34 UTC
(In reply to phrxmd from comment #1)
> I realize the information provided is probably not very helpful. What would
> be the best way to get a backtrace or detailed log output?

There are a couple of ways to get the backtrace:

* check coredumpctl, `coredumpctl list kwin_wayland && coredumpctl gdb <pid>`, then type "bt" in gdb. make sure that debug symbols are installed

* attach a debugger to kwin_wayland process and try to reproduce the crash, when kwin crashes, type "bt" in gdb. For more info https://community.kde.org/KWin/Debugging#Debug_KWin_with_GDB
Comment 4 Mircea Kitsune 2022-02-10 21:39:26 UTC
I only know I'm waiting for at least 3 years on the Wayland session to fix issues with monitor standby. The one and only reason I'm still stuck on X11 is everything crashes when my monitor goes into power saving, which I must enable to conserve power and preserve the screen. Even when it doesn't crash by some miracle, the monitor immediately wakes back up after powering down so power saving still won't work. HDMI and DisplayPort both do this. Whatever it is, please try to fix it in the upcoming Plasma 5.24! Thank you.
Comment 5 phrxmd 2022-02-10 21:43:54 UTC
Created attachment 146556 [details]
Backtrace

Here is a backtrace from the crash.
Comment 6 phrxmd 2022-02-11 18:59:45 UTC
In addition, when KWin comes back up again from the crash, the Plasma wallpaper is scaled incorrectly on a HiDPI display - as if it has the scaling factor for that monitor applied twice. It's as if before the crash there was a cached version of the wallpaper with the HiDPI scaling, and after the crash, when KWin comes up again, it reads the cached wallpaper and applies the HiDPI scaling to it again.

See bug 445160 for photos of the desktop arrangement before and after the crash.
Comment 7 Nate Graham 2022-02-11 20:07:18 UTC
Was there any more? I see this, which is quite helpful:

Thread 1 "kwin_wayland" received signal SIGSEGV, Segmentation fault.
KWin::Workspace::clientArea (this=0x557a5b0fcfd0, opt=KWin::PlacementArea, output=<optimized out>, desktop=<optimized out>) at /usr/src/debug/kwin5-5.24.0-1.1.x86_64/src/workspace.cpp:2288
2288	        screenArea = effectiveOutput->geometry();

...However the attachment does not include the rest of thread 1. Could you see if that was truncated, and attach it?
Comment 8 ltstarwarskid 2022-02-11 21:48:49 UTC
I'm also having this problem still on Wayland, replicated the exact same way. I'll attach my backtrace.

Here's my setup:

Operating System: Ubuntu 21.10
KDE Plasma Version: 5.24.0
KDE Frameworks Version: 5.90.0
Qt Version: 5.15.2
Kernel Version: 5.13.0-30-lowlatency (64-bit)
Processors: 32 × AMD Ryzen 9 3950X 16-Core Processor
Memory: 31.3 GiB of RAM
Graphics Processor: AMD Radeon RX 5700 XT
Monitor:  LG 27GN950-B
Comment 9 ltstarwarskid 2022-02-11 21:49:31 UTC
Created attachment 146603 [details]
Backtrace of kwin_wayland monitor issue
Comment 10 phrxmd 2022-02-11 22:35:23 UTC
(In reply to Nate Graham from comment #7)
> Was there any more? I see this, which is quite helpful:
> 
> Thread 1 "kwin_wayland" received signal SIGSEGV, Segmentation fault.
> KWin::Workspace::clientArea (this=0x557a5b0fcfd0, opt=KWin::PlacementArea,
> output=<optimized out>, desktop=<optimized out>) at
> /usr/src/debug/kwin5-5.24.0-1.1.x86_64/src/workspace.cpp:2288
> 2288	        screenArea = effectiveOutput->geometry();
> 
> ...However the attachment does not include the rest of thread 1. Could you
> see if that was truncated, and attach it?

Unfortunately that's all the `kwin_wayland.gdb` file contains. Attaching a debugger to KWin Wayland seems to be tricky. I'll try getting another laptop ready to ssh into my machine.
Comment 11 Anil 2022-02-12 22:48:38 UTC
I need to figure out how to get debug symbols and/or recompile a local version. However, the steps from here appear to give a full stack trace: https://community.kde.org/KWin/Debugging

namely:
echo 0 | sudo tee /proc/sys/kernel/yama/ptrace_scope
sudo gdb -pid $(pidof kwin_wayland) -batch -ex "set logging file kwin_wayland.gdb" -ex "set logging on" -ex "continue" -ex "thread apply all backtrace" -ex "quit"

Here's the stack, but without proper symbolication:
Thread 1 (Thread 0x7f12da9340c0 (LWP 4456) "kwin_wayland"):
#0  0x00007f12e201af14 in KWin::Workspace::clientArea(KWin::clientAreaOption, KWin::AbstractOutput const*, KWin::VirtualDesktop const*) const () at /usr/lib/libkwin.so.5
#1  0x00007f12e1ec9f13 in  () at /usr/lib/libkwin.so.5
#2  0x00007f12e1ecb743 in  () at /usr/lib/libkwin.so.5
#3  0x00007f12e1ecb765 in  () at /usr/lib/libkwin.so.5
#4  0x00007f12df1f0d16 in  () at /usr/lib/libQt5Qml.so.5
#5  0x00007f12df0f403d in  () at /usr/lib/libQt5Qml.so.5
#6  0x00007f12df0f510b in QV4::QObjectMethod::callInternal(QV4::Value const*, QV4::Value const*, int) const () at /usr/lib/libQt5Qml.so.5
#7  0x00007f12df11508e in QV4::Runtime::CallPropertyLookup::call(QV4::ExecutionEngine*, QV4::Value const&, unsigned int, QV4::Value*, int) () at /usr/lib/libQt5Qml.so.5
#8  0x00007f12a00b9c51 in  ()
#9  0x00007ffe118e3a50 in  ()
#10 0x00007f12a0f2f930 in  ()
#11 0x00007f12a00b93a0 in  ()
#12 0x0000000000000000 in  ()
A debugging session is active.

Maybe someone else who has a setup already working can help :)
Comment 12 ltstarwarskid 2022-02-13 16:53:06 UTC
(In reply to Anil from comment #11)
> I need to figure out how to get debug symbols and/or recompile a local
> version. However, the steps from here appear to give a full stack trace:
> https://community.kde.org/KWin/Debugging
> 
> namely:
> echo 0 | sudo tee /proc/sys/kernel/yama/ptrace_scope
> sudo gdb -pid $(pidof kwin_wayland) -batch -ex "set logging file
> kwin_wayland.gdb" -ex "set logging on" -ex "continue" -ex "thread apply all
> backtrace" -ex "quit"
> 
> Here's the stack, but without proper symbolication:
> Thread 1 (Thread 0x7f12da9340c0 (LWP 4456) "kwin_wayland"):
> #0  0x00007f12e201af14 in
> KWin::Workspace::clientArea(KWin::clientAreaOption, KWin::AbstractOutput
> const*, KWin::VirtualDesktop const*) const () at /usr/lib/libkwin.so.5
> #1  0x00007f12e1ec9f13 in  () at /usr/lib/libkwin.so.5
> #2  0x00007f12e1ecb743 in  () at /usr/lib/libkwin.so.5
> #3  0x00007f12e1ecb765 in  () at /usr/lib/libkwin.so.5
> #4  0x00007f12df1f0d16 in  () at /usr/lib/libQt5Qml.so.5
> #5  0x00007f12df0f403d in  () at /usr/lib/libQt5Qml.so.5
> #6  0x00007f12df0f510b in QV4::QObjectMethod::callInternal(QV4::Value
> const*, QV4::Value const*, int) const () at /usr/lib/libQt5Qml.so.5
> #7  0x00007f12df11508e in
> QV4::Runtime::CallPropertyLookup::call(QV4::ExecutionEngine*, QV4::Value
> const&, unsigned int, QV4::Value*, int) () at /usr/lib/libQt5Qml.so.5
> #8  0x00007f12a00b9c51 in  ()
> #9  0x00007ffe118e3a50 in  ()
> #10 0x00007f12a0f2f930 in  ()
> #11 0x00007f12a00b93a0 in  ()
> #12 0x0000000000000000 in  ()
> A debugging session is active.
> 
> Maybe someone else who has a setup already working can help :)

It depends on the distro if you want already compiled debug symbol packages of course, but if you're on an ubuntu based fork, they usually can be found here ready to go as .debs:
https://launchpad.net/~kubuntu-ppa
https://launchpad.net/ubuntu/+search?text=wayland

If you need source code to compile:
https://gitlab.freedesktop.org/wayland
https://invent.kde.org/plasma/kwin
https://invent.kde.org/plasma/kwayland-server
https://invent.kde.org/plasma/kwayland-integration

A lot of distros also have separate source code you can manually download through a browser at their repo website instead of through terminal if your package manager can't find it for whatever reason. That's where I found debug symbol packs that weren't showing up for the package manager's command line search.
Comment 13 Anil 2022-02-13 20:57:34 UTC
Here's the stack. Faulting line is `screenArea = effectiveOutput->geometry();`
Thread 1 (Thread 0x7f19d581ba80 (LWP 4517) "kwin_wayland"):
#0  KWin::Workspace::clientArea(KWin::clientAreaOption, KWin::AbstractOutput const*, KWin::VirtualDesktop const*) const (this=0x55f05c631ec0, opt=KWin::PlacementArea, output=<optimized out>, desktop=<optimized out>) at /home/anil/kde/src/kwin/src/workspace.cpp:2291
#1  0x00007f19dcc8877a in KWin::Workspace::clientArea(KWin::clientAreaOption, int, int) const (this=<optimized out>, opt=<optimized out>, screen=<optimized out>, desktop=<optimized out>) at /home/anil/kde/src/kwin/src/workspace.cpp:2347
#2  0x00007f19dcc395cf in KWin::WorkspaceWrapper::clientArea(KWin::WorkspaceWrapper::ClientAreaOption, int, int) const (this=<optimized out>, option=<optimized out>, screen=<optimized out>, desktop=<optimized out>) at /home/anil/kde/src/kwin/src/scripting/workspace_wrapper.cpp:270
#3  0x00007f19dcb1d0be in KWin::WorkspaceWrapper::qt_static_metacall(QObject*, QMetaObject::Call, int, void**) (_o=<optimized out>, _c=<optimized out>, _id=<optimized out>, _a=0x7ffe71add250) at /home/anil/kde/build/kwin/src/kwin_autogen/7KDSW62DQT/moc_workspace_wrapper.cpp:676
#4  0x00007f19dcb2e28b in KWin::WorkspaceWrapper::qt_metacall(QMetaObject::Call, int, void**) (this=this@entry=0x55f05c737d60, _c=_c@entry=QMetaObject::InvokeMetaMethod, _id=91, _a=_a@entry=0x7ffe71add250) at /home/anil/kde/build/kwin/src/kwin_autogen/7KDSW62DQT/moc_workspace_wrapper.cpp:946
#5  0x00007f19dcb2e325 in KWin::DeclarativeScriptWorkspaceWrapper::qt_metacall(QMetaObject::Call, int, void**) (this=0x55f05c737d60, _c=QMetaObject::InvokeMetaMethod, _id=<optimized out>, _a=0x7ffe71add250) at /home/anil/kde/build/kwin/src/kwin_autogen/7KDSW62DQT/moc_workspace_wrapper.cpp:1327
#6  0x00007f19dc0add16 in  () at /usr/lib/libQt5Qml.so.5
#7  0x00007f19dbfb103d in  () at /usr/lib/libQt5Qml.so.5
#8  0x00007f19dbfb210b in QV4::QObjectMethod::callInternal(QV4::Value const*, QV4::Value const*, int) const () at /usr/lib/libQt5Qml.so.5
#9  0x00007f19dbfd208e in QV4::Runtime::CallPropertyLookup::call(QV4::ExecutionEngine*, QV4::Value const&, unsigned int, QV4::Value*, int) () at /usr/lib/libQt5Qml.so.5
#10 0x00007f198ea74c51 in  ()
#11 0x00007ffe71add8b0 in  ()
#12 0x00007f19a4746930 in  ()
#13 0x00007f198ea743a0 in  ()
#14 0x0000000000000000 in  ()
[Inferior 1 (process 4517) detached]
Comment 14 ltstarwarskid 2022-02-14 00:33:52 UTC
Created attachment 146689 [details]
New Trace

So I was able to get a more thorough trace, but I'm honestly not sure if I'm getting the same error as the others or not now. It's running down something involving AVX2 for some reason.

Thread 1 (Thread 0x7fab3de629c0 (LWP 3843) "kwin_wayland"):
#0  BYTE_MUL_AVX2 (half=..., colorMask=..., alphaChannel=..., pixelVector=<optimized out>) at painting/qdrawhelper_avx2.cpp:62
#1  BLEND_SOURCE_OVER_ARGB32_AVX2 (length=64, src=0x55da1d3f8bf0, dst=0x7faa83679000) at painting/qdrawhelper_avx2.cpp:189
#2  comp_func_SourceOver_avx2(unsigned int*, unsigned int const*, int, unsigned int) (destPixels=0x7faa83679000, srcPixels=0x55da1d3f8bf0, length=64, const_alpha=255) at painting/qdrawhelper_avx2.cpp:394
#3  0x00007fab4344395e in blend_untransformed_argb(int, QSpan const*, void*) (count=<optimized out>, spans=0x7fff04392dc0, userData=0x55da1caffbd8) at painting/qdrawhelper.cpp:4954
#4  0x00007fab43484550 in fillRect_normalized(QRect const&, QSpanData*, QRasterPaintEnginePrivate*) (r=<optimized out>, data=0x55da1caffbd8, pe=<optimized out>) at painting/qpaintengine_raster.cpp:1542
#5  0x00007fab4348a662 in QRasterPaintEngine::drawImage(QRectF const&, QImage const&, QRectF const&, QFlags<Qt::ImageConversionFlag>) (this=0x55da1c938170, r=..., img=..., sr=...) at painting/qpaintengine_raster.cpp:2480
#6  0x00007fab4348bec6 in QRasterPaintEngine::drawImage(QRectF const&, QImage const&, QRectF const&, QFlags<Qt::ImageConversionFlag>) (sr=..., img=..., r=..., this=0x55da1c938170) at ../../include/QtCore/../../src/corelib/tools/qrect.h:674
#7  QRasterPaintEngine::drawImage(QPointF const&, QImage const&) (this=0x55da1c938170, p=..., img=...) at painting/qpaintengine_raster.cpp:2215
#8  0x00007fab3cbb54e1 in QPainter::drawImage(QPoint const&, QImage const&) (p=<optimized out>, p=<optimized out>, image=..., this=0x7fff043938d8) at /usr/include/x86_64-linux-gnu/qt5/QtGui/qpainter.h:888
#9  KWin::DrmOutput::updateCursor() (this=<optimized out>) at ./src/backends/drm/drm_output.cpp:156
#10 0x00007fab42e1da53 in QtPrivate::QSlotObjectBase::call(QObject*, void**) (a=0x7fff04393af0, r=0x55da1c5705a0, this=0x55da1ba231f0) at ../../include/QtCore/../../src/corelib/kernel/qobjectdefs_impl.h:398
#11 doActivate<false>(QObject*, int, void**) (sender=0x55da1b6d9390, signal_index=3, argv=0x7fff04393af0) at kernel/qobject.cpp:3886
#12 0x00007fab42e16d67 in QMetaObject::activate(QObject*, QMetaObject const*, int, void**) (sender=<optimized out>, m=m@entry=0x7fab45244960 <KWin::Cursors::staticMetaObject>, local_signal_index=local_signal_index@entry=0, argv=argv@entry=0x7fff04393af0) at kernel/qobject.cpp:3946
#13 0x00007fab44fa1d33 in KWin::Cursors::currentCursorChanged(KWin::Cursor*) (this=<optimized out>, _t1=<optimized out>) at ./obj-x86_64-linux-gnu/src/kwin_autogen/EWIEGA46WW/moc_cursor.cpp:374
#14 0x00007fab42e1da53 in QtPrivate::QSlotObjectBase::call(QObject*, void**) (a=0x7fff04393ba0, r=0x55da1b6d9390, this=0x55da1b6d2910) at ../../include/QtCore/../../src/corelib/kernel/qobjectdefs_impl.h:398
#15 doActivate<false>(QObject*, int, void**) (sender=0x55da1b6d6cc0, signal_index=5, argv=0x7fff04393ba0) at kernel/qobject.cpp:3886
#16 0x00007fab45079770 in operator() (__closure=0x55da1b574020) at ./src/pointer_input.cpp:137
#17 QtPrivate::FunctorCall<QtPrivate::IndexesList<>, QtPrivate::List<>, void, KWin::PointerInputRedirection::init()::<lambda()> >::call (arg=<optimized out>, f=...) at /usr/include/x86_64-linux-gnu/qt5/QtCore/qobjectdefs_impl.h:146
#18 QtPrivate::Functor<KWin::PointerInputRedirection::init()::<lambda()>, 0>::call<QtPrivate::List<>, void> (arg=<optimized out>, f=...) at /usr/include/x86_64-linux-gnu/qt5/QtCore/qobjectdefs_impl.h:256
#19 QtPrivate::QFunctorSlotObject<KWin::PointerInputRedirection::init()::<lambda()>, 0, QtPrivate::List<>, void>::impl(int, QtPrivate::QSlotObjectBase *, QObject *, void **, bool *) (which=<optimized out>, this_=0x55da1b574010, r=<optimized out>, a=<optimized out>, ret=<optimized out>) at /usr/include/x86_64-linux-gnu/qt5/QtCore/qobjectdefs_impl.h:443
#20 0x00007fab42e1da53 in QtPrivate::QSlotObjectBase::call(QObject*, void**) (a=0x7fff04393cd0, r=0x55da1b6d6cc0, this=0x55da1b574010) at ../../include/QtCore/../../src/corelib/kernel/qobjectdefs_impl.h:398
#21 doActivate<false>(QObject*, int, void**) (sender=0x55da1bb4fa30, signal_index=3, argv=0x7fff04393cd0) at kernel/qobject.cpp:3886
#22 0x00007fab42e1da53 in QtPrivate::QSlotObjectBase::call(QObject*, void**) (a=0x7fff04393da0, r=0x55da1bb4fa30, this=0x55da1cc41ec0) at ../../include/QtCore/../../src/corelib/kernel/qobjectdefs_impl.h:398
#23 doActivate<false>(QObject*, int, void**) (sender=0x55da1bb32260, signal_index=3, argv=0x7fff04393da0) at kernel/qobject.cpp:3886
#24 0x00007fab42e1da53 in QtPrivate::QSlotObjectBase::call(QObject*, void**) (a=0x7fff04393e70, r=0x55da1bb32260, this=0x55da1c9819b0) at ../../include/QtCore/../../src/corelib/kernel/qobjectdefs_impl.h:398
#25 doActivate<false>(QObject*, int, void**) (sender=0x55da1c89e480, signal_index=6, argv=0x7fff04393e70) at kernel/qobject.cpp:3886
#26 0x00007fab44ca04eb in KWaylandServer::PointerInterfacePrivate::pointer_set_cursor(QtWaylandServer::wl_pointer::Resource*, unsigned int, wl_resource*, int, int) (this=0x55da1bb29c30, resource=0x55da1cb4b9a0, serial=1170, surface_resource=<optimized out>, hotspot_x=0, hotspot_y=0) at ./src/server/pointer_interface.cpp:93
#27 0x00007fab408e5045 in ffi_call_unix64 () at ../src/x86/unix64.S:101
#28 0x00007fab408e4449 in ffi_call_int (cif=<optimized out>, fn=<optimized out>, rvalue=<optimized out>, avalue=<optimized out>, closure=<optimized out>) at ../src/x86/ffi64.c:669
#29 0x00007fab41c72c0e in  () at /opt/amdgpu/lib/x86_64-linux-gnu/libwayland-server.so.0
#30 0x00007fab41c6d226 in  () at /opt/amdgpu/lib/x86_64-linux-gnu/libwayland-server.so.0
#31 0x00007fab41c70082 in wl_event_loop_dispatch () at /opt/amdgpu/lib/x86_64-linux-gnu/libwayland-server.so.0
#32 0x00007fab44c769aa in KWaylandServer::Display::dispatchEvents() (this=<optimized out>) at ./src/server/display.cpp:114
#33 0x00007fab42e1da53 in QtPrivate::QSlotObjectBase::call(QObject*, void**) (a=0x7fff04394670, r=0x55da1b54c250, this=0x55da1b9627f0) at ../../include/QtCore/../../src/corelib/kernel/qobjectdefs_impl.h:398
#34 doActivate<false>(QObject*, int, void**) (sender=0x55da1be9e9d0, signal_index=3, argv=0x7fff04394670) at kernel/qobject.cpp:3886
#35 0x00007fab42e16d67 in QMetaObject::activate(QObject*, QMetaObject const*, int, void**) (sender=sender@entry=0x55da1be9e9d0, m=m@entry=0x7fab43083180 <QSocketNotifier::staticMetaObject>, local_signal_index=local_signal_index@entry=0, argv=argv@entry=0x7fff04394670) at kernel/qobject.cpp:3946
#36 0x00007fab42e20f63 in QSocketNotifier::activated(QSocketDescriptor, QSocketNotifier::Type, QSocketNotifier::QPrivateSignal) (this=this@entry=0x55da1be9e9d0, _t1=..., _t2=<optimized out>, _t3=...) at .moc/moc_qsocketnotifier.cpp:178
#37 0x00007fab42e21793 in QSocketNotifier::event(QEvent*) (this=0x55da1be9e9d0, e=0x7fff04394790) at kernel/qsocketnotifier.cpp:302
#38 0x00007fab4391b6b3 in QApplicationPrivate::notify_helper(QObject*, QEvent*) (this=<optimized out>, receiver=0x55da1be9e9d0, e=0x7fff04394790) at kernel/qapplication.cpp:3632
#39 0x00007fab42de616a in QCoreApplication::notifyInternal2(QObject*, QEvent*) (receiver=0x55da1be9e9d0, event=0x7fff04394790) at kernel/qcoreapplication.cpp:1063
#40 0x00007fab42e3c82b in QEventDispatcherUNIXPrivate::activateSocketNotifiers() (this=0x55da1b524300) at kernel/qeventdispatcher_unix.cpp:304
#41 0x00007fab42e3cc9b in QEventDispatcherUNIX::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) (this=<optimized out>, flags=...) at kernel/qeventdispatcher_unix.cpp:511
#42 0x000055da1b2dd5c1 in QUnixEventDispatcherQPA::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) ()
#43 0x00007fab42de4a9b in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) (this=this@entry=0x7fff04394920, flags=..., flags@entry=...) at ../../include/QtCore/../../src/corelib/global/qflags.h:69
#44 0x00007fab42ded024 in QCoreApplication::exec() () at ../../include/QtCore/../../src/corelib/global/qflags.h:121
#45 0x00007fab431c0d10 in QGuiApplication::exec() () at kernel/qguiapplication.cpp:1867
#46 0x00007fab4391b629 in QApplication::exec() () at kernel/qapplication.cpp:2824
#47 0x000055da1b1eec52 in main(int, char**) (argc=<optimized out>, argv=<optimized out>) at ./src/main_wayland.cpp:727
A debugging session is active.

	Inferior 1 [process 3843] will be detached.
Comment 15 Zamundaaa 2022-04-15 15:54:56 UTC
We had a few fixes for output changes in the bugfix releases for 5.24, can you still reproduce this with a newer release?
Comment 16 phrxmd 2022-04-15 17:18:28 UTC
I'm on a trip at the moment and will test again as soon as I have access to the dock, this will be in about 10 days.
Comment 17 Henrique Sant'Anna 2022-04-16 03:09:55 UTC
I'm using kwin 5.24.4 and can reproduce this problem ALWAYS, every time I unplug HDMI cable without deactivating the external monitor first.

But now the screen completely freezes, even the mouse pointer, and after that it will not unfreeze anymore. 

I'm on Arch and I don't know how to collect useful information about this freeze, since I don't have debug symbols installed, maybe I have to compile it myself.
Comment 18 postix 2022-04-16 09:42:11 UTC
(In reply to Henrique Sant'Anna from comment #17)
> I'm on Arch and I don't know how to collect useful information about this
> freeze, since I don't have debug symbols installed, maybe I have to compile
> it myself.

Check out https://wiki.archlinux.org/title/Debuginfod
Comment 19 phrxmd 2022-04-28 16:53:13 UTC
Unfortunately I can still reproduce the problem in recent 5.24.4 (on OpenSuSE Tumbleweed updated today).
Comment 20 phrxmd 2022-04-28 18:54:34 UTC
Created attachment 148439 [details]
Somewhat more detailed backtrace /bt full/

Here's a backtrace with a few more details - here's the portion from Thread 1 in KWin::Workspace::ClientArea():

Thread 1 (Thread 0x7f63142d0980 (LWP 2734) "kwin_wayland"):
#0  KWin::Workspace::clientArea(KWin::clientAreaOption, KWin::AbstractOutput const*, KWin::VirtualDesktop const*) const (this=0x55bcea23f920, opt=KWin::PlacementArea, output=<optimized out>, desktop=<optimized out>) at /usr/src/debug/kwin5-5.24.4-1.1.x86_64/src/workspace.cpp:2288
        workArea = {x1 = 0, y1 = 0, x2 = -1, y2 = -1}
        effectiveOutput = 0x0
        screenArea = {x1 = 0, y1 = <optimized out>, x2 = -1, y2 = -1}
#1  0x00007f63197896e6 in KWin::WorkspaceWrapper::clientArea(KWin::WorkspaceWrapper::ClientAreaOption, int, int) const (this=0x55bcea5877b0, desktop=<optimized out>, screen=<optimized out>, option=<optimized out>) at /usr/src/debug/kwin5-5.24.4-1.1.x86_64/src/scripting/workspace_wrapper.cpp:270
        _r = {x1 = <optimized out>, y1 = <optimized out>, x2 = <optimized out>, y2 = <optimized out>}
        _t = 0x55bcea5877b0
#2  KWin::WorkspaceWrapper::qt_static_metacall(QObject*, QMetaObject::Call, int, void**) (_o=_o@entry=0x55bcea5877b0, _c=_c@entry=QMetaObject::InvokeMetaMethod, _id=_id@entry=91, _a=_a@entry=0x7fff1ab62a70) at /usr/src/debug/kwin5-5.24.4-1.1.x86_64/build/src/kwin_autogen/7KDSW62DQT/moc_workspace_wrapper.cpp:676
        _r = {x1 = <optimized out>, y1 = <optimized out>, x2 = <optimized out>, y2 = <optimized out>}
        _t = 0x55bcea5877b0
#3  0x00007f631978a17b in KWin::WorkspaceWrapper::qt_metacall(QMetaObject::Call, int, void**) (this=this@entry=0x55bcea5877b0, _c=_c@entry=QMetaObject::InvokeMetaMethod, _id=91, _a=_a@entry=0x7fff1ab62a70) at /usr/src/debug/kwin5-5.24.4-1.1.x86_64/build/src/kwin_autogen/7KDSW62DQT/moc_workspace_wrapper.cpp:946
#4  0x00007f631978a1a1 in KWin::DeclarativeScriptWorkspaceWrapper::qt_metacall(QMetaObject::Call, int, void**) (this=0x55bcea5877b0, _c=QMetaObject::InvokeMetaMethod, _id=<optimized out>, _a=0x7fff1ab62a70) at /usr/src/debug/kwin5-5.24.4-1.1.x86_64/build/src/kwin_autogen/7KDSW62DQT/moc_workspace_wrapper.cpp:1327
#5  0x00007f6318bc51ed in QQmlObjectOrGadget::metacall(QMetaObject::Call, int, void**) const (this=this@entry=0x7fff1ab62d00, type=type@entry=QMetaObject::InvokeMetaMethod, index=<optimized out>, index@entry=96, argv=<optimized out>) at /usr/src/debug/libqt5-qtdeclarative-5.15.2+kde43-2.1.x86_64/src/qml/qml/qqmlobjectorgadget.cpp:51
#6  0x00007f6318aa4210 in CallMethod (callType=<optimized out>, callArgs=0x2, engine=<optimized out>, argTypes=<optimized out>, argCount=<optimized out>, returnType=<optimized out>, index=<optimized out>, object=...) at /usr/include/qt5/QtCore/qvarlengtharray.h:189
        args = {a = 9, s = 4, ptr = 0x7fff1ab62ad0, {array = "\300\343\274\352\274U\000\000\023\000\000@c\177\000\000\b\b\225\352\274U\000\000\320*\266\032\377\177\000\000\377\377\377\377\000\000\000\000\000\000\000\000c\177\000\000\b\000\000\000\000\000\000\000\000\032f\333\036\215\060x\000\354\240\031c\177\000\000\002\000\000\000\377\377\377\377\001", '\000' <repeats 16 times>, "\354\240\031c\177\000\000\210+\266\032\377\177\000\000\002\000\000\000\000\000\000\000\001\000\000\000c\177\000\000\200+\266\032\377\177\000\000\000\032f\333\036\215\060x\000\354\240\031c\177\000\000\002\000\000\000\377\377\377\377\002", '\000' <repeats 15 times>, "\300\343\274\352\274U\000\000\001", '\000' <repeats 15 times>..., q_for_alignment_1 = 94269880460224, q_for_alignment_2 = 4.6575509372957679e-310}}
        argData = {a = 9, s = 4, ptr = 0x7fff1ab62a70, {array = "\314\343\274\352\274U\000\000\370*\266\032\377\177\000\000 +\266\032\377\177\000\000H+\266\032\377\177\000\000\000\000\000\000\000\000@\234\000\032f\333\036\215\060x\000\000\000\000\000\000\000\000\360\376\377\377\377\377\377\377\002\000\000\000\000\000\000", q_for_alignment_1 = 94269880460236, q_for_alignment_2 = 4.6575509372963607e-310}}
        args = <optimized out>
        storage = {a = 9, s = 0, ptr = 0x7fff1ab62a30, {array = "\b+\266\032\377\177\000\000\000\000\000\000\000\000 N\000\000\000\000\000\000\000\000\004\000\000\000\000\000\000\000L+\266\032", q_for_alignment_1 = 140733641534216, q_for_alignment_2 = 6.9531657496192907e-310}}
        unknownTypeError = {d = 0x55bce99ccea0 <QArrayData::shared_null>}
        returnType = <optimized out>
#7  CallPrecise(QQmlObjectOrGadget const&, QQmlPropertyData const&, QV4::ExecutionEngine*, QV4::CallData*, QMetaObject::Call) (object=..., data=<optimized out>, engine=engine@entry=0x55bcea7c8a10, callArgs=callArgs@entry=0x7f62ed559a08, callType=callType@entry=QMetaObject::InvokeMetaMethod) at /usr/src/debug/libqt5-qtdeclarative-5.15.2+kde43-2.1.x86_64/src/qml/jsruntime/qv4qobjectwrapper.cpp:1569
        args = <optimized out>
        storage = {a = 9, s = 0, ptr = 0x7fff1ab62a30, {array = "\b+\266\032\377\177\000\000\000\000\000\000\000\000 N\000\000\000\000\000\000\000\000\004\000\000\000\000\000\000\000L+\266\032", q_for_alignment_1 = 140733641534216, q_for_alignment_2 = 6.9531657496192907e-310}}
        unknownTypeError = {d = 0x55bce99ccea0 <QArrayData::shared_null>}
        returnType = <optimized out>
#8  0x00007f6318aa5ffb in CallOverloaded (callType=<optimized out>, propertyCache=<optimized out>, callArgs=<optimized out>, engine=<optimized out>, data=<optimized out>, object=<optimized out>) at /usr/src/debug/libqt5-qtdeclarative-5.15.2+kde43-2.1.x86_64/src/qml/jsruntime/qv4qobjectwrapper.cpp:1645
        best = {m_flags = {otherBits = 0, isConstantORisVMEFunction = 0, isWritableORhasArguments = 1, isResettableORisSignal = 0, isAliasORisVMESignal = 0, isFinalORisV4Function = 0, isSignalHandler = 0, isOverload = 0, isRequiredORisCloned = 0, isConstructor = 0, isDirect = 1, isOverridden = 1, type = 1, notFullyResolved = 0, overrideIndexIsProperty = 0}, m_coreIndex = 96, m_propType = 19, m_notifyIndex = -1, m_overrideIndex = -1, m_revision = 0 '\000', m_typeMinorVersion = 0 '\000', m_metaObjectOffset = 1, m_arguments = 0x55bceaff2050, m_staticMetaCallFunction = 0x0}
        attempt = <optimized out>
        argumentCount = <optimized out>
        bestParameterScore = <optimized out>
        bestMatchScore = <optimized out>
        dummy = {m_flags = {otherBits = 0, isConstantORisVMEFunction = 0, isWritableORhasArguments = 0, isResettableORisSignal = 0, isAliasORisVMESignal = 0, isFinalORisV4Function = 0, isSignalHandler = 0, isOverload = 0, isRequiredORisCloned = 0, isConstructor = 0, isDirect = 0, isOverridden = 0, type = 0, notFullyResolved = 0, overrideIndexIsProperty = 0}, m_coreIndex = -1, m_propType = 0, m_notifyIndex = -1, m_overrideIndex = -1, m_revision = 0 '\000', m_typeMinorVersion = 0 '\000', m_metaObjectOffset = -1, m_arguments = 0x0, m_staticMetaCallFunction = 0x0}
        v4 = 0x55bcea7c8a10
        object = {<QQmlMetaObject> = {_m = {ptr_value = 94269874524608, static FlagBit = 1, static Flag2Bit = 2, static FlagsMask = 3}}, ptr = {ptr_value = 94269873878960, static Flag2Bit = 2, static FlagsMask = 3}}
        method = {m_flags = {otherBits = 0, isConstantORisVMEFunction = 0, isWritableORhasArguments = 1, isResettableORisSignal = 0, isAliasORisVMESignal = 0, isFinalORisV4Function = 0, isSignalHandler = 0, isOverload = 1, isRequiredORisCloned = 0, isConstructor = 0, isDirect = 1, isOverridden = 0, type = 1, notFullyResolved = 0, overrideIndexIsProperty = 0}, m_coreIndex = 99, m_propType = 19, m_notifyIndex = -1, m_overrideIndex = 98, m_revision = 0 '\000', m_typeMinorVersion = 0 '\000', m_metaObjectOffset = 1, m_arguments = 0x55bceaff20d0, m_staticMetaCallFunction = 0x0}
        scope = {engine = 0x55bcea7c8a10, mark = 0x7f62ed559a08}
        cData = {scope = <optimized out>, argc = <optimized out>, args = <optimized out>, thisObject = <optimized out>}
#9  QV4::QObjectMethod::callInternal(QV4::Value const*, QV4::Value const*, int) const (this=<optimized out>, thisObject=<optimized out>, argv=<optimized out>, argc=<optimized out>) at /usr/src/debug/libqt5-qtdeclarative-5.15.2+kde43-2.1.x86_64/src/qml/jsruntime/qv4qobjectwrapper.cpp:2133
        v4 = 0x55bcea7c8a10
        object = {<QQmlMetaObject> = {_m = {ptr_value = 94269874524608, static FlagBit = 1, static Flag2Bit = 2, static FlagsMask = 3}}, ptr = {ptr_value = 94269873878960, static Flag2Bit = 2, static FlagsMask = 3}}
        method = {m_flags = {otherBits = 0, isConstantORisVMEFunction = 0, isWritableORhasArguments = 1, isResettableORisSignal = 0, isAliasORisVMESignal = 0, isFinalORisV4Function = 0, isSignalHandler = 0, isOverload = 1, isRequiredORisCloned = 0, isConstructor = 0, isDirect = 1, isOverridden = 0, type = 1, notFullyResolved = 0, overrideIndexIsProperty = 0}, m_coreIndex = 99, m_propType = 19, m_notifyIndex = -1, m_overrideIndex = 98, m_revision = 0 '\000', m_typeMinorVersion = 0 '\000', m_metaObjectOffset = 1, m_arguments = 0x55bceaff20d0, m_staticMetaCallFunction = 0x0}
        scope = {engine = 0x55bcea7c8a10, mark = 0x7f62ed559a08}
        cData = {scope = <optimized out>, argc = <optimized out>, args = <optimized out>, thisObject = <optimized out>}
#10 0x00007f6318ad44ca in QV4::FunctionObject::call(QV4::Value const*, QV4::Value const*, int) const (argc=3, argv=0x7f62ed5599c0, thisObject=0x7f62ed5599a8, this=0x7fff1ab62e38) at /usr/src/debug/libqt5-qtdeclarative-5.15.2+kde43-2.1.x86_64/src/qml/jsruntime/qv4functionobject_p.h:202
        l = <optimized out>
        f = {<QV4::StaticValue> = {_val = 140062860057760, static NaNEncodeMask = 18445618173802708992, static Immediate_Mask_64 = 131072, static Immediate_Mask_32 = 2147352576}, <No data fields>}
#11 QV4::Runtime::CallPropertyLookup::call(QV4::ExecutionEngine*, QV4::Value const&, unsigned int, QV4::Value*, int) (engine=0x55bcea7c8a10, base=..., index=<optimized out>, argv=0x7f62ed5599c0, argc=3) at /usr/src/debug/libqt5-qtdeclarative-5.15.2+kde43-2.1.x86_64/src/qml/jsruntime/qv4runtime.cpp:1460
        l = <optimized out>
        f = {<QV4::StaticValue> = {_val = 140062860057760, static NaNEncodeMask = 18445618173802708992, static Immediate_Mask_64 = 131072, static Immediate_Mask_32 = 2147352576}, <No data fields>}
#12 0x00007f62ec0038f4 in  ()
#13 0x0000000000000000 in  ()
A debugging session is active.
Comment 21 phrxmd 2022-05-02 18:45:57 UTC
Potentially important information: I can connect/disconnect the external monitor *as long as there are no windows on it*. A Plasma panel seems to be fine. However, as soon as there is an application window on the disconnected output, I get this crash. 

In my regular work setup I would always have windows on the output because it's my main monitor; I'm now testing this in a road warrior setting with a projector, and here I can reproducibly crash KWin by putting a window on the projector and then disconnecting it, while the projector disconnects just fine as long as there is no window there. 

It seems like KWin tries to redraw the windows on the lost output by placing them on the remaining outputs, and that the crash happens during the recalculation of the placement coordinates. As long as there is nothing to place, there is no crash.

(Subject line edited accordingly)
Comment 22 phrxmd 2022-05-08 14:01:34 UTC
Upon further experimentation, I get the same crash when hitting Meta-P and switching to the internal display, without disconnecting the monitor.
Comment 23 phrxmd 2022-05-16 20:17:46 UTC
Further clarification: on 5.24.5 this crash happens only when...
(a) unplugging a primary display, whether it has windows on it or not
(b) unplugging a non-primary display if and only if it has windows on it

E.g. on my home setting, where I have an monitor connected to the docking station that is marked primary, KWin crashes whenever I unplug the docking station, unplug the monitor from the docking station or switch off the monitor. In that situation I can avoid the crash by moving all windows off the external monitor, marking the notebook screen as primary and then unplugging the (now-secondary) monitor. 

It seems that it is triggered by the recalculation of window coordinates that happens either when a window is on a disabled output and needs to be placed somewhere else, or when the primary display goes down.
Comment 24 Maximilian Schmeling 2022-05-22 20:44:52 UTC
Same issue here.

Operating System: Arch Linux
KDE Plasma Version: 5.24.5
KDE Frameworks Version: 5.94.0
Qt Version: 5.15.4
Kernel Version: 5.17.9-zen1-1-zen (64-bit)
Graphics Platform: Wayland
Processors: 12 × AMD Ryzen 5 5500U with Radeon Graphics
Memory: 13.6 GiB of RAM
Graphics Processor: AMD RENOIR
Comment 25 Bug Janitor Service 2022-06-11 06:08:47 UTC
A possibly relevant merge request was started @ https://invent.kde.org/plasma/kwin/-/merge_requests/2509
Comment 26 phrxmd 2022-06-11 14:26:02 UTC
Created attachment 149618 [details]
Backtrace when this happens after waking up from monitor standby

Since a recent system update (since kernel 5.17 or so) I start seeing this much more often. 

One situation where it happens reproducibly is whenever a screen is connected to the laptop's internal HDMI port, KWin wakes up from monitor standby and the external screen comes online. (The workaround is to disable monitor standby in System Settings). 

System as of now:
Operating System: openSUSE Tumbleweed 20220609
KDE Plasma Version: 5.24.5
KDE Frameworks Version: 5.94.0
Qt Version: 5.15.2
Kernel Version: 5.18.2-1-default (64-bit)
Graphics Platform: Wayland
Processors: 8 × Intel® Core™ i7-8550U CPU @ 1.80GHz
Memory: 15.5 GiB of RAM
Graphics Processor: Mesa Intel® UHD Graphics 620
Comment 27 phrxmd 2022-06-11 15:21:53 UTC
Created attachment 149621 [details]
Backtrace when this happens as a DisplayPort screen comes online

Another very annoying instance where this has recently started to happen is whenever I try to log into the Plasma session with an external screen attached via DisplayPort to my Thunderbolt dock. In this configuration, Plasma is now unbootable. KWin comes up, initializes the screen, crashes, comes up again, initializes the screen again, crashes and so on. After going through this crash loop a few times, I'm dropped back into the display manager.

This happens whenever a DisplayPort monitor attached to the dock comes up (see backtrace attached). 

I'm not sure what led to this change. However, before the recent system update (pre-kernel 5.17??), the eGPU in the dock and the DisplayPort screen attached to the dock would come up already during the boot process, and I'd see boot messages scrolling by on the external screen that duplicate those on the internal desktop. Since the change, the external screen stays dark during the boot process (maybe the eGPU in the dock gets initialized later?), and when KWin tries to bring it up, KWin crashes.
Comment 28 Ta-Lun Yen 2022-06-11 17:33:31 UTC
phrxmd: Is there by any chance, you have plugins like grid-tiling-kwin or bismuth installed? If so, please try https://invent.kde.org/plasma/kwin/-/merge_requests/2509
Comment 29 phrxmd 2022-06-11 21:24:06 UTC
(In reply to Ta-Lun Yen from comment #28)
> phrxmd: Is there by any chance, you have plugins like grid-tiling-kwin or
> bismuth installed? If so, please try
> https://invent.kde.org/plasma/kwin/-/merge_requests/2509

I'll try, but it might take me a few days as I've never compiled KDE from source before.
Comment 30 phrxmd 2022-06-12 19:42:32 UTC
(In reply to Ta-Lun Yen from comment #28)
> phrxmd: Is there by any chance, you have plugins like grid-tiling-kwin or
> bismuth installed? If so, please try
> https://invent.kde.org/plasma/kwin/-/merge_requests/2509

I have bismuth installed. That merge request fixes this bug for me.
Comment 31 Bug Janitor Service 2022-06-14 09:12:30 UTC
A possibly relevant merge request was started @ https://invent.kde.org/plasma/kwin/-/merge_requests/2517
Comment 32 Vlad Zahorodnii 2022-06-14 11:24:59 UTC
Git commit ac97e282fca0dbe00b85f8af5ca6d7c083acaab1 by Vlad Zahorodnii.
Committed on 14/06/2022 at 11:09.
Pushed by vladz into branch 'master'.

scripting: Handle bad output and desktop ids gracefully

Don't crash if a script has provided bad screen or desktop id to
clientArea().

M  +24   -14   src/scripting/workspace_wrapper.cpp

https://invent.kde.org/plasma/kwin/commit/ac97e282fca0dbe00b85f8af5ca6d7c083acaab1
Comment 33 Vlad Zahorodnii 2022-06-14 11:45:38 UTC
Git commit 5afa5c64409f22ab9e65485780dbb05f9ca47229 by Vlad Zahorodnii.
Committed on 14/06/2022 at 11:45.
Pushed by vladz into branch 'Plasma/5.25'.

scripting: Handle bad output and desktop ids gracefully

Don't crash if a script has provided bad screen or desktop id to
clientArea().


(cherry picked from commit ac97e282fca0dbe00b85f8af5ca6d7c083acaab1)

M  +24   -14   src/scripting/workspace_wrapper.cpp

https://invent.kde.org/plasma/kwin/commit/5afa5c64409f22ab9e65485780dbb05f9ca47229
Comment 34 Nate Graham 2022-06-14 13:15:54 UTC
Nice. Anything more to do here, or is that enough of a fix?
Comment 35 phrxmd 2022-06-14 16:25:36 UTC
Just tested with master and it seems to be fixed.
Comment 36 Nate Graham 2022-06-14 16:30:16 UTC

*** This bug has been marked as a duplicate of bug 448102 ***
Comment 37 David Edmundson 2022-06-29 16:06:00 UTC
*** Bug 455689 has been marked as a duplicate of this bug. ***