Bug 445335

Summary: kwin_wayland crashed in KWin::EffectWindow::isOnAllDesktops() when activating desktop effect
Product: [Plasma] kwin Reporter: Nicolas Fella <nicolas.fella>
Component: effects-desktop-gridAssignee: KWin default assignee <kwin-bugs-null>
Status: RESOLVED FIXED    
Severity: crash CC: isma.af, leszek.lesner, nate, postix
Priority: NOR    
Version: git master   
Target Milestone: ---   
Platform: Other   
OS: Linux   
Latest Commit: Version Fixed In: 5.24
Sentry Crash Report:
Attachments: New crash information added by DrKonqi

Description Nicolas Fella 2021-11-11 13:53:55 UTC
STEPS TO REPRODUCE
1. Boot system, no windows open
2. Have one virtual desktop
3. trigger desktop overview by touchpad swipe up

OBSERVED RESULT
kwin_wayland crashes

Subsequent activations of the effect work fine

Everything from master

#0  0x00007f0dba5a1a0e in KWin::EffectWindow::isOnAllDesktops() const (this=0x0) at /home/nico/kde/src/kwin/src/libkwineffects/kwineffects.cpp:815
#1  0x000055bc624b5bfc in KWin::DesktopGridEffect::desktopList(KWin::EffectWindow const*) const (this=0x55bc62e27060, w=0x0) at /home/nico/kde/src/kwin/src/effects/desktopgrid/desktopgrid.cpp:1449
#2  0x000055bc624ae56b in KWin::DesktopGridEffect::slotWindowClosed(KWin::EffectWindow*) (this=0x55bc62e27060, w=0x55bc637f3740) at /home/nico/kde/src/kwin/src/effects/desktopgrid/desktopgrid.cpp:448
#3  0x000055bc624bec69 in QtPrivate::FunctorCall<QtPrivate::IndexesList<0>, QtPrivate::List<KWin::EffectWindow*>, void, void (KWin::DesktopGridEffect::*)(KWin::EffectWindow*)>::call(void (KWin::DesktopGridEffect::*)(KWin::EffectWindow*), KWin::DesktopGridEffect*, void**) (f=
    (void (KWin::DesktopGridEffect::*)(KWin::DesktopGridEffect * const, KWin::EffectWindow *)) 0x55bc624ae474 <KWin::DesktopGridEffect::slotWindowClosed(KWin::EffectWindow*)>, o=0x55bc62e27060, arg=0x7ffcb26b4430) at /home/nico/kde/usr/include/QtCore/qobjectdefs_impl.h:152
#4  0x000055bc624bddbd in QtPrivate::FunctionPointer<void (KWin::DesktopGridEffect::*)(KWin::EffectWindow*)>::call<QtPrivate::List<KWin::EffectWindow*>, void>(void (KWin::DesktopGridEffect::*)(KWin::EffectWindow*), KWin::DesktopGridEffect*, void**) (f=
    (void (KWin::DesktopGridEffect::*)(KWin::DesktopGridEffect * const, KWin::EffectWindow *)) 0x55bc624ae474 <KWin::DesktopGridEffect::slotWindowClosed(KWin::EffectWindow*)>, o=0x55bc62e27060, arg=0x7ffcb26b4430) at /home/nico/kde/usr/include/QtCore/qobjectdefs_impl.h:185
#5  0x000055bc624bc63f in QtPrivate::QSlotObject<void (KWin::DesktopGridEffect::*)(KWin::EffectWindow*), QtPrivate::List<KWin::EffectWindow*>, void>::impl(int, QtPrivate::QSlotObjectBase*, QObject*, void**, bool*) (which=1, this_=0x55bc62c53d70, r=0x55bc62e27060, a=0x7ffcb26b4430, ret=0x0) at /home/nico/kde/usr/include/QtCore/qobjectdefs_impl.h:418
#6  0x00007f0db7eba443 in QtPrivate::QSlotObjectBase::call(QObject*, void**) (a=0x7ffcb26b4430, r=0x55bc62e27060, this=0x55bc62c53d70) at ../../include/QtCore/../../src/corelib/kernel/qobjectdefs_impl.h:398
#7  doActivate<false>(QObject*, int, void**) (sender=0x55bc62eec700, signal_index=12, argv=0x7ffcb26b4430) at kernel/qobject.cpp:3886
#8  0x00007f0dba5817a8 in KWin::EffectsHandler::windowClosed(KWin::EffectWindow*) (this=0x55bc62eec700, _t1=0x55bc637f3740)
    at /home/nico/kde/build/kwin/src/libkwineffects/kwineffects_autogen/EWIEGA46WW/moc_kwineffects.cpp:1631
#9  0x00007f0dbacd884f in KWin::EffectsHandlerImpl::slotWindowClosed(KWin::Toplevel*, KWin::Deleted*) (this=0x55bc62eec700, c=0x55bc62e042f0, d=0x55bc63e653c0) at /home/nico/kde/src/kwin/src/effects.cpp:559
#10 0x00007f0dbacf2075 in QtPrivate::FunctorCall<QtPrivate::IndexesList<0, 1>, QtPrivate::List<KWin::Toplevel*, KWin::Deleted*>, void, void (KWin::EffectsHandlerImpl::*)(KWin::Toplevel*, KWin::Deleted*)>::call(void (KWin::EffectsHandlerImpl::*)(KWin::Toplevel*, KWin::Deleted*), KWin::EffectsHandlerImpl*, void**) (f=
    (void (KWin::EffectsHandlerImpl::*)(KWin::EffectsHandlerImpl * const, KWin::Toplevel *, KWin::Deleted *)) 0x7f0dbacd8800 <KWin::EffectsHandlerImpl::slotWindowClosed(KWin::Toplevel*, KWin::Deleted*)>, o=0x55bc62eec700, arg=0x7ffcb26b4650) at /home/nico/kde/usr/include/QtCore/qobjectdefs_impl.h:152
#11 0x00007f0dbacf0ea0 in QtPrivate::FunctionPointer<void (KWin::EffectsHandlerImpl::*)(KWin::Toplevel*, KWin::Deleted*)>::call<QtPrivate::List<KWin::Toplevel*, KWin::Deleted*>, void>(void (KWin::EffectsHandlerImpl::*)(KWin::Toplevel*, KWin::Deleted*), KWin::EffectsHandlerImpl*, void**) (f=
    (void (KWin::EffectsHandlerImpl::*)(KWin::EffectsHandlerImpl * const, KWin::Toplevel *, KWin::Deleted *)) 0x7f0dbacd8800 <KWin::EffectsHandlerImpl::slotWindowClosed(KWin::Toplevel*, KWin::Deleted*)>, o=0x55bc62eec700, arg=0x7ffcb26b4650) at /home/nico/kde/usr/include/QtCore/qobjectdefs_impl.h:185
#12 0x00007f0dbacef049 in QtPrivate::QSlotObject<void (KWin::EffectsHandlerImpl::*)(KWin::Toplevel*, KWin::Deleted*), QtPrivate::List<KWin::Toplevel*, KWin::Deleted*>, void>::impl(int, QtPrivate::QSlotObjectBase*, QObject*, void**, bool*) (which=1, this_=0x55bc62af2f40, r=0x55bc62eec700, a=0x7ffcb26b4650, ret=0x0) at /home/nico/kde/usr/include/QtCore/qobjectdefs_impl.h:418
#13 0x00007f0db7eba443 in QtPrivate::QSlotObjectBase::call(QObject*, void**) (a=0x7ffcb26b4650, r=0x55bc62eec700, this=0x55bc62af2f40) at ../../include/QtCore/../../src/corelib/kernel/qobjectdefs_impl.h:398
#14 doActivate<false>(QObject*, int, void**) (sender=0x55bc62e042f0, signal_index=10, argv=0x7ffcb26b4650) at kernel/qobject.cpp:3886
#15 0x00007f0dbac1f262 in KWin::Toplevel::windowClosed(KWin::Toplevel*, KWin::Deleted*) (this=0x55bc62e042f0, _t1=0x55bc62e042f0, _t2=0x55bc63e653c0)
    at /home/nico/kde/build/kwin/src/kwin_autogen/EWIEGA46WW/moc_toplevel.cpp:821
#16 0x00007f0dbaec1715 in KWin::XdgSurfaceClient::destroyClient() (this=0x55bc62e042f0) at /home/nico/kde/src/kwin/src/xdgshellclient.cpp:327
#17 0x00007f0dbaed0ad2 in QtPrivate::FunctorCall<QtPrivate::IndexesList<>, QtPrivate::List<>, void, void (KWin::XdgSurfaceClient::*)()>::call(void (KWin::XdgSurfaceClient::*)(), KWin::XdgSurfaceClient*, void**)
    (f=&virtual table offset 808, o=0x55bc62e042f0, arg=0x7ffcb26b4800) at /home/nico/kde/usr/include/QtCore/qobjectdefs_impl.h:152
#18 0x00007f0dbaed0189 in QtPrivate::FunctionPointer<void (KWin::XdgSurfaceClient::*)()>::call<QtPrivate::List<>, void>(void (KWin::XdgSurfaceClient::*)(), KWin::XdgSurfaceClient*, void**)
    (f=&virtual table offset 808, o=0x55bc62e042f0, arg=0x7ffcb26b4800) at /home/nico/kde/usr/include/QtCore/qobjectdefs_impl.h:185
#19 0x00007f0dbaecf0e5 in QtPrivate::QSlotObject<void (KWin::XdgSurfaceClient::*)(), QtPrivate::List<>, void>::impl(int, QtPrivate::QSlotObjectBase*, QObject*, void**, bool*)
    (which=1, this_=0x55bc63d15d30, r=0x55bc62e042f0, a=0x7ffcb26b4800, ret=0x0) at /home/nico/kde/usr/include/QtCore/qobjectdefs_impl.h:418
#20 0x00007f0db7eba443 in QtPrivate::QSlotObjectBase::call(QObject*, void**) (a=0x7ffcb26b4800, r=0x55bc62e042f0, this=0x55bc63d15d30) at ../../include/QtCore/../../src/corelib/kernel/qobjectdefs_impl.h:398
#21 doActivate<false>(QObject*, int, void**) (sender=0x55bc63d23ef0, signal_index=3, argv=0x7ffcb26b4800) at kernel/qobject.cpp:3886
#22 0x00007f0dba6755bb in KWaylandServer::XdgToplevelInterface::aboutToBeDestroyed() (this=0x55bc63d23ef0)
    at /home/nico/kde/build/kwayland-server/src/server/KWaylandServer_autogen/EWIEGA46WW/moc_xdgshell_interface.cpp:693
#23 0x00007f0dba7114c8 in KWaylandServer::XdgToplevelInterfacePrivate::xdg_toplevel_destroy_resource(QtWaylandServer::xdg_toplevel::Resource*) (this=0x55bc63d42c40, resource=0x55bc63bba0a0)
    at /home/nico/kde/src/kwayland-server/src/server/xdgshell_interface.cpp:357
#24 0x00007f0dba79dfe6 in QtWaylandServer::xdg_toplevel::destroy_func(wl_resource*) (client_resource=0x55bc63d23e60) at /home/nico/kde/build/kwayland-server/src/server/qwayland-server-xdg-shell.cpp:1178
#25 0x00007f0dba5d282a in  () at /usr/lib/libwayland-server.so.0
#26 0x00007f0dba5d2f51 in wl_resource_destroy () at /usr/lib/libwayland-server.so.0
#27 0x00007f0dba71150e in KWaylandServer::XdgToplevelInterfacePrivate::xdg_toplevel_destroy(QtWaylandServer::xdg_toplevel::Resource*) (this=0x55bc63d42c40, resource=0x55bc63bba0a0)
Comment 1 postix 2021-11-23 20:46:00 UTC
*** Bug 445997 has been marked as a duplicate of this bug. ***
Comment 2 postix 2021-11-23 20:48:18 UTC
Is it really Wayland generic? My stacktrace in #445997 looks rather similar but it happened on X11.
Comment 3 Nicolas Fella 2021-12-06 01:14:13 UTC
I haven't tried on X11.

It doesn't seem related to the first activation. It happens seemingly random on some activations
Comment 4 Ismael Asensio 2022-01-07 12:43:28 UTC
Created attachment 145188 [details]
New crash information added by DrKonqi

kwin_x11 (5.23.80) using Qt 5.15.2

I can replicate it on X11, by moving any window between desktops and then exiting the effect

-- Backtrace (Reduced):
#5  0x00007eff7a2d0558 in KWin::EffectWindow::isOnAllDesktops() const (this=0x0) at /home/isma/kde/src/kwin/src/libkwineffects/kwineffects.cpp:815
#6  0x000055ccd363f9e6 in KWin::DesktopGridEffect::desktopList(KWin::EffectWindow const*) const (this=0x55ccd58e1ec0, w=0x0) at /home/isma/kde/src/kwin/src/effects/desktopgrid/desktopgrid.cpp:1449
#7  0x000055ccd36382d7 in KWin::DesktopGridEffect::slotWindowClosed(KWin::EffectWindow*) (this=0x55ccd58e1ec0, w=0x7eff6c014e40) at /home/isma/kde/src/kwin/src/effects/desktopgrid/desktopgrid.cpp:448
#8  0x000055ccd364efa1 in QtPrivate::FunctorCall<QtPrivate::IndexesList<0>, QtPrivate::List<KWin::EffectWindow*>, void, void (KWin::DesktopGridEffect::*)(KWin::EffectWindow*)>::call(void (KWin::DesktopGridEffect::*)(KWin::EffectWindow*), KWin::DesktopGridEffect*, void**) (f=(void (KWin::DesktopGridEffect::*)(class KWin::DesktopGridEffect * const, class KWin::EffectWindow *)) 0x55ccd36381dc <KWin::DesktopGridEffect::slotWindowClosed(KWin::EffectWindow*)>, o=0x55ccd58e1ec0, arg=0x7ffde9a3e270) at /usr/include/x86_64-linux-gnu/qt5/QtCore/qobjectdefs_impl.h:152
#9  0x000055ccd364daa6 in QtPrivate::FunctionPointer<void (KWin::DesktopGridEffect::*)(KWin::EffectWindow*)>::call<QtPrivate::List<KWin::EffectWindow*>, void>(void (KWin::DesktopGridEffect::*)(KWin::EffectWindow*), KWin::DesktopGridEffect*, void**) (f=(void (KWin::DesktopGridEffect::*)(class KWin::DesktopGridEffect * const, class KWin::EffectWindow *)) 0x55ccd36381dc <KWin::DesktopGridEffect::slotWindowClosed(KWin::EffectWindow*)>, o=0x55ccd58e1ec0, arg=0x7ffde9a3e270) at /usr/include/x86_64-linux-gnu/qt5/QtCore/qobjectdefs_impl.h:185
Comment 5 Bug Janitor Service 2022-01-07 20:48:03 UTC
A possibly relevant merge request was started @ https://invent.kde.org/plasma/kwin/-/merge_requests/1852
Comment 6 Ismael Asensio 2022-01-07 21:16:11 UTC
Git commit 72c0974a0604f50ca38138814942b6cedfccfc0e by Ismael Asensio.
Committed on 07/01/2022 at 21:16.
Pushed by iasensio into branch 'master'.

DesktopGridEffect: Fix crash when closing the effect

If the first condition would match (for instance after moving a window),
`windowMove` would be `nullptr`, triggering the crash later.

By the looks of it, it was maybe a typo.
FIXED-IN: 5.24

CC: @nicolasfella

M  +1    -1    src/effects/desktopgrid/desktopgrid.cpp

https://invent.kde.org/plasma/kwin/commit/72c0974a0604f50ca38138814942b6cedfccfc0e
Comment 7 Vlad Zahorodnii 2022-01-10 10:18:25 UTC
*** Bug 422275 has been marked as a duplicate of this bug. ***