bismuth
                                
                                
                                
                                    bismuth copied to clipboard
                            
                            
                            
                        [Bug]: various problems & crashes `kwin_wayland` when disconnecting external monitors
Summary
SUMMARY
kwin_wayland crashes when external monitor connected via usb-c hub is disconnected. Did not break before 5.23.3.
STEPS TO REPRODUCE
OBSERVED RESULT Kwin_wayland crashes
EXPECTED RESULT kwin_wayland doesn't crash
See crash log, stack trace: https://bugs.kde.org/attachment.cgi?id=143975
See: https://bugs.kde.org/show_bug.cgi?id=446124
Steps to Reproduce
- Plug in monitor through usb-c hub
 - Unplug hub
 
Expected behavior
kwin_wayland doesn't crash
Screenshots
No response
Bismuth version
2.10-2
KDE Plasma version
5.23.3
The platform KWin is running on
Wayland
Additional context
No response
This is also happening to me on X11. Seems to only happen if there's windows tiled on the screen that gets turned-off/disconnected.
I cannot reproduce the crash, but enabling Bismuth makes KWin go south when disconnecting the external monitor.
This happens to me on both X11 and Wayland. On X11 I've made the issue slightly easier to deal with by setting up keyboard shortcuts to quickly restart Plasma (killall plasmashell && kstart5 plasmashell) and KWin (kwin_x11 --replace). Restarting both brings everything back to normal after the crash.
I have crashes on disconnection of an HDMI monitor, in Wayland.
However, I saw similar instability before I knew about Bismuth. It could be a more general KWin bug.
There is one specific difference after installation of Bismuth: I am no longer able to use the laptop screen management Fn key. The screen selection window does pop up and I am able to click the options, but all it does is crash the Wayland session and recycle me back to the two-screen configuration.
In gdb:
#0  KWin::Workspace::clientArea (this=0x560a790f8ed0, opt=<optimized out>, output=<optimized out>, desktop=<optimized out>) at /usr/src/debug/kwin-5.24.5-1.fc36.x86_64/src/workspace.cpp:2288
#1  0x00007f4228d89d42 in KWin::WorkspaceWrapper::clientArea (this=0x560a7918d6c0, desktop=<optimized out>, screen=<optimized out>, option=<optimized out>)
    at /usr/src/debug/kwin-5.24.5-1.fc36.x86_64/src/scripting/workspace_wrapper.cpp:270
#2  KWin::WorkspaceWrapper::qt_static_metacall (_o=_o@entry=0x560a7918d6c0, _c=_c@entry=QMetaObject::InvokeMetaMethod, _id=_id@entry=91, _a=_a@entry=0x7fffade17fe0)
    at /usr/src/debug/kwin-5.24.5-1.fc36.x86_64/redhat-linux-build/src/kwin_autogen/7KDSW62DQT/moc_workspace_wrapper.cpp:676
#3  0x00007f4226b41c9a in QMetaMethod::invoke (this=this@entry=0x7fffade18180, object=0x560a7918d6c0, connectionType=connectionType@entry=Qt::DirectConnection, returnValue=..., val0=..., 
    val1=..., val2=..., val3=..., val4=..., val5=..., val6=..., val7=..., val8=..., val9=...) at kernel/qmetaobject.cpp:2303
#4  0x00007f42100c5fe4 in PlasmaApi::Workspace::clientArea (this=0x560a79bdd2d8, option=<optimized out>, screen=<optimized out>, desktop=<optimized out>)
    at /usr/include/qt5/QtCore/qobjectdefs.h:292
#5  0x00007f42100c7145 in PlasmaApi::Workspace::qt_static_metacall (_o=0x560a79bdd2d8, _c=<optimized out>, _id=<optimized out>, _a=0x7fffade183e0)
    at /usr/src/debug/bismuth-3.1.1-1.fc36.x86_64/redhat-linux-build/src/core/bismuth_core_autogen/MSMBI3FKJV/moc_workspace.cpp:213
#6  0x00007f42100ccd0b in PlasmaApi::Workspace::qt_metacall (this=0x560a79bdd2d8, _c=QMetaObject::InvokeMetaMethod, _id=15, _a=0x7fffade183e0)
    at /usr/src/debug/bismuth-3.1.1-1.fc36.x86_64/redhat-linux-build/src/core/bismuth_core_autogen/MSMBI3FKJV/moc_workspace.cpp:392
#7  0x00007f4228180ea3 in QQmlObjectOrGadget::metacall (this=this@entry=0x7fffade18680, type=type@entry=QMetaObject::InvokeMetaMethod, index=<optimized out>, index@entry=20, 
    argv=<optimized out>) at qml/qqmlobjectorgadget.cpp:51
#8  0x00007f422805a526 in CallMethod (callType=<optimized out>, callArgs=0x4, engine=<optimized out>, argTypes=<optimized out>, argCount=<optimized out>, returnType=<optimized out>, 
    index=<optimized out>, object=...) at /usr/include/qt5/QtCore/qvarlengtharray.h:189
#9  CallPrecise (object=..., data=..., engine=engine@entry=0x560a791fa870, callArgs=callArgs@entry=0x7f4204291a58, callType=callType@entry=QMetaObject::InvokeMetaMethod)
    at jsruntime/qv4qobjectwrapper.cpp:1568
#10 0x00007f422805c3cb in CallOverloaded (callType=<optimized out>, propertyCache=<optimized out>, callArgs=<optimized out>, engine=<optimized out>, data=..., object=...)
    at jsruntime/qv4qobjectwrapper.cpp:1644
#11 QV4::QObjectMethod::callInternal (this=<optimized out>, thisObject=<optimized out>, argv=<optimized out>, argc=<optimized out>) at jsruntime/qv4qobjectwrapper.cpp:2132
#12 0x00007f422808c24d in QV4::FunctionObject::call (argc=3, argv=0x7f4204291a10, thisObject=0x7f42042919f8, this=0x7fffade187b8) at jsruntime/qv4functionobject_p.h:202
#13 QV4::Runtime::CallPropertyLookup::call (engine=0x560a791fa870, base=..., index=<optimized out>, argv=0x7f4204291a10, argc=3) at jsruntime/qv4runtime.cpp:1460
#14 0x00007f41fc1f2911 in ?? ()
#15 0x0000000000000000 in ?? ()
(gdb) l workspace.cpp:2288
2283	       effectiveOutput = kwinApp()->platform()->findOutput(screen_number);
2284	   }
2285	
2286	   QRect screenArea = m_screenAreas[desktop][effectiveOutput];
2287	   if (screenArea.isNull()) { // screens may be missing during KWin initialization or screen config changes
2288	       screenArea = effectiveOutput->geometry();
2289	   }
2290	
2291	   if (is_multihead) {
2292	       workArea = m_workAreas[desktop];
(gdb) p effectiveOutput->geometry()
Cannot access memory at address 0x0
(gdb) p effectiveOutput
$6 = (const KWin::AbstractOutput *) 0x0
                                    
                                    
                                    
                                
I've read through multiple tickets on bugs.kde.org and some of them were from crashes while using bismuth. Also, here's a step to reproduce this:
Prerequisites
- bismuth enabled (Window TIling -> Enable window tiling)
 - multiple monitors connected
 
Steps
- Open more than 1 window on each monitors
 - Disable monitors via display configuration
 
Note
- After inducing this bug, plasmashell/kwin could behave incorrectly. "Log out" will not work, neither 
loginctl kill-session. Usepkill -9 kwin_waylandto restart the session. - I can reproduce this in VMWare with multiple monitors attached to VM, using Plasma Wayland
 - See https://bugs.kde.org/show_bug.cgi?id=449957
 
I've tracked down the issue. The issue is within kwin - it doesn't account for some instances where screen won't exist (e.g. while changing outputs)
You may use some kind of patch like this into kwin. I am not sure whether this will cause any other side effects, but at least it stops kwin from crashing. I will test this patched kwin along with bismuth for a while before I try to submit it to kwin.
From cc5579a99a8a32d7986642fb3baca6c3a357d3b7 Mon Sep 17 00:00:00 2001
From: Ta-Lun Yen <[email protected]>
Date: Thu, 9 Jun 2022 05:02:19 +0800
Subject: [PATCH] monkey
---
 src/workspace.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/workspace.cpp b/src/workspace.cpp
index e4e3e1972..de49bee8a 100644
--- a/src/workspace.cpp
+++ b/src/workspace.cpp
@@ -2284,7 +2284,7 @@ QRect Workspace::clientArea(clientAreaOption opt, const AbstractOutput *output,
     }
 
     QRect screenArea = m_screenAreas[desktop][effectiveOutput];
-    if (screenArea.isNull()) { // screens may be missing during KWin initialization or screen config changes
+    if (screenArea.isNull() && effectiveOutput) { // screens may be missing during KWin initialization or screen config changes
         screenArea = effectiveOutput->geometry();
     }
 
-- 
2.36.1
                                    
                                    
                                    
                                
I've been using the patch to kwin for a couple of days under heavy usage. It appears to have no side-effects and fixed the initial problem. Submitted to upstream: https://invent.kde.org/plasma/kwin/-/merge_requests/2509
Probably fixed by https://invent.kde.org/plasma/kwin/-/merge_requests/2517.
I think it's fixed and will be in kwin 5.25. Can we somehow mention this in README.md about using kwin<5.25 will cause crashes?
On Tue, Jun 14, 2022 at 18:38, Philipp Reichmuth @.***> wrote:
Probably fixed by https://invent.kde.org/plasma/kwin/-/merge_requests/2517.
— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you commented.Message ID: @.***>