Bug 406452

Summary: Crash when current virtual desktop is removed using a kwin script
Product: [Plasma] kwin Reporter: Aritz Beobide-Cardinal <aritz>
Component: generalAssignee: KWin default assignee <kwin-bugs-null>
Status: RESOLVED FIXED    
Severity: crash CC: kde, nate
Priority: NOR Keywords: drkonqi
Version: 5.12.7Flags: vlad.zahorodnii: ReviewRequest+
Target Milestone: ---   
Platform: Ubuntu   
OS: Linux   
URL: https://phabricator.kde.org/D21064
Latest Commit: Version Fixed In: 5.16.0
Sentry Crash Report:

Description Aritz Beobide-Cardinal 2019-04-11 22:20:26 UTC
Application: kwin_x11 (5.12.7)

Qt Version: 5.9.5
Frameworks Version: 5.44.0
Operating System: Linux 4.18.0-17-generic x86_64
Distribution: Ubuntu 18.04.2 LTS

-- Information about the crash:
Created custom shortcut:
- Name: Close current Desktop
- Trigger: Meta+Ctrl+F4
- Action: /opt/themestuff/kwinscript /opt/themestuff/kwinscripts/removeDesktop.kwinscript

themestuff is a folder I created containing verious customizations

Contents of /opt/themestuff/kwinscript:
#!/bin/bash
script=$1;
echo $1;
num=$(qdbus org.kde.KWin \
    /Scripting \
    loadScript \
    $script);
echo $num;
qdbus org.kde.KWin \
    /Scripting \
    start;
#eof

Contents of /opt/themestuff/kwinscripts/removeDesktop.kwinscript:

if (workspace.desktops > 1){
    var desktopToRemove = workspace.currentDesktop;
    workspace.currentDesktop -= 1;
    if (desktopToRemove == 1){
        desktopToRemove = workspace.desktops;
    }
    
    var clients = workspace.clientList();
    for (var i=0; i<clients.length; i += 1) {
        if(clients[i].desktop >= desktopToRemove){
            clients[i].desktop -= 1;
        }
    }
    workspace.desktops -= 1;
}
//eof

If it is relevent, the cube rotation animation is enabled

The crash can be reproduced every time.

-- Backtrace:
Application: KWin (kwin_x11), signal: Segmentation fault
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
[Current thread is 1 (Thread 0x7f1859374cc0 (LWP 24554))]

Thread 5 (Thread 0x7f18162d1700 (LWP 24567)):
#0  0x00007f1851d3a9f3 in futex_wait_cancelable (private=<optimized out>, expected=0, futex_word=0x7f18552d1fb8) at ../sysdeps/unix/sysv/linux/futex-internal.h:88
#1  0x00007f1851d3a9f3 in __pthread_cond_wait_common (abstime=0x0, mutex=0x7f18552d1f68, cond=0x7f18552d1f90) at pthread_cond_wait.c:502
#2  0x00007f1851d3a9f3 in __pthread_cond_wait (cond=0x7f18552d1f90, mutex=0x7f18552d1f68) at pthread_cond_wait.c:655
#3  0x00007f1854fdb5f4 in  () at /usr/lib/x86_64-linux-gnu/libQt5Script.so.5
#4  0x00007f1854fdb639 in  () at /usr/lib/x86_64-linux-gnu/libQt5Script.so.5
#5  0x00007f1851d346db in start_thread (arg=0x7f18162d1700) at pthread_create.c:463
#6  0x00007f1858cdb88f in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

Thread 4 (Thread 0x7f183598c700 (LWP 24563)):
#0  0x00007f1858ccecf6 in __GI_ppoll (fds=0x7f1824000d28, nfds=1, timeout=<optimized out>, sigmask=0x0) at ../sysdeps/unix/sysv/linux/ppoll.c:39
#1  0x00007f18560d0671 in qt_safe_poll(pollfd*, unsigned long, timespec const*) () at /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#2  0x00007f18560d1d8e in QEventDispatcherUNIX::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) () at /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#3  0x00007f1856079a1a in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) () at /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#4  0x00007f1855e9823a in QThread::exec() () at /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#5  0x00007f18508206f5 in  () at /usr/lib/x86_64-linux-gnu/libQt5Qml.so.5
#6  0x00007f1855e9d17d in  () at /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#7  0x00007f1851d346db in start_thread (arg=0x7f183598c700) at pthread_create.c:463
#8  0x00007f1858cdb88f in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

Thread 3 (Thread 0x7f183d392700 (LWP 24558)):
#0  0x00007f1858ccecf6 in __GI_ppoll (fds=0x7f183000e828, nfds=1, timeout=<optimized out>, sigmask=0x0) at ../sysdeps/unix/sysv/linux/ppoll.c:39
#1  0x00007f18560d0671 in qt_safe_poll(pollfd*, unsigned long, timespec const*) () at /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#2  0x00007f18560d1d8e in QEventDispatcherUNIX::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) () at /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#3  0x00007f1856079a1a in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) () at /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#4  0x00007f1855e9823a in QThread::exec() () at /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#5  0x00007f184f6f9d45 in  () at /usr/lib/x86_64-linux-gnu/libQt5DBus.so.5
#6  0x00007f1855e9d17d in  () at /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#7  0x00007f1851d346db in start_thread (arg=0x7f183d392700) at pthread_create.c:463
#8  0x00007f1858cdb88f in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

Thread 2 (Thread 0x7f183f9ed700 (LWP 24556)):
#0  0x00007f1858ccebf9 in __GI___poll (fds=0x7f183f9ecc68, nfds=1, timeout=-1) at ../sysdeps/unix/sysv/linux/poll.c:29
#1  0x00007f1857bd8747 in  () at /usr/lib/x86_64-linux-gnu/libxcb.so.1
#2  0x00007f1857bda36a in xcb_wait_for_event () at /usr/lib/x86_64-linux-gnu/libxcb.so.1
#3  0x00007f18408cc2a9 in  () at /usr/lib/x86_64-linux-gnu/libQt5XcbQpa.so.5
#4  0x00007f1855e9d17d in  () at /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#5  0x00007f1851d346db in start_thread (arg=0x7f183f9ed700) at pthread_create.c:463
#6  0x00007f1858cdb88f in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

Thread 1 (Thread 0x7f1859374cc0 (LWP 24554)):
[KCrash Handler]
#6  0x00007f18587ffc92 in KWin::Workspace::clientArea(KWin::clientAreaOption, int, int) const () at /usr/lib/x86_64-linux-gnu/libkwin.so.5
#7  0x00007f1855569f55 in  () at /usr/lib/x86_64-linux-gnu/libkwin4_effect_builtins.so.1
#8  0x00007f185883d681 in KWin::EffectsHandlerImpl::prePaintWindow(KWin::EffectWindow*, KWin::WindowPrePaintData&, int) () at /usr/lib/x86_64-linux-gnu/libkwin.so.5
#9  0x00007f185883d681 in KWin::EffectsHandlerImpl::prePaintWindow(KWin::EffectWindow*, KWin::WindowPrePaintData&, int) () at /usr/lib/x86_64-linux-gnu/libkwin.so.5
#10 0x00007f185882c4c0 in KWin::Scene::paintGenericScreen(int, KWin::ScreenPaintData) () at /usr/lib/x86_64-linux-gnu/libkwin.so.5
#11 0x00007f1834381462 in  () at /usr/lib/x86_64-linux-gnu/qt5/plugins/org.kde.kwin.scenes/KWinSceneOpenGL.so
#12 0x00007f185882f1b0 in KWin::Scene::finalPaintScreen(int, QRegion, KWin::ScreenPaintData&) () at /usr/lib/x86_64-linux-gnu/libkwin.so.5
#13 0x00007f185883d4d5 in KWin::EffectsHandlerImpl::paintScreen(int, QRegion, KWin::ScreenPaintData&) () at /usr/lib/x86_64-linux-gnu/libkwin.so.5
#14 0x00007f1855844401 in KWin::Effect::paintScreen(int, QRegion, KWin::ScreenPaintData&) () at /usr/lib/x86_64-linux-gnu/libkwineffects.so.11
#15 0x00007f185883d47d in KWin::EffectsHandlerImpl::paintScreen(int, QRegion, KWin::ScreenPaintData&) () at /usr/lib/x86_64-linux-gnu/libkwin.so.5
#16 0x00007f1855844401 in KWin::Effect::paintScreen(int, QRegion, KWin::ScreenPaintData&) () at /usr/lib/x86_64-linux-gnu/libkwineffects.so.11
#17 0x00007f185883d47d in KWin::EffectsHandlerImpl::paintScreen(int, QRegion, KWin::ScreenPaintData&) () at /usr/lib/x86_64-linux-gnu/libkwin.so.5
#18 0x00007f185556ad05 in  () at /usr/lib/x86_64-linux-gnu/libkwin4_effect_builtins.so.1
#19 0x00007f185556b0be in  () at /usr/lib/x86_64-linux-gnu/libkwin4_effect_builtins.so.1
#20 0x00007f185883d47d in KWin::EffectsHandlerImpl::paintScreen(int, QRegion, KWin::ScreenPaintData&) () at /usr/lib/x86_64-linux-gnu/libkwin.so.5
#21 0x00007f1855844401 in KWin::Effect::paintScreen(int, QRegion, KWin::ScreenPaintData&) () at /usr/lib/x86_64-linux-gnu/libkwineffects.so.11
#22 0x00007f185883d47d in KWin::EffectsHandlerImpl::paintScreen(int, QRegion, KWin::ScreenPaintData&) () at /usr/lib/x86_64-linux-gnu/libkwin.so.5
#23 0x00007f185882ee5e in KWin::Scene::paintScreen(int*, QRegion const&, QRegion const&, QRegion*, QRegion*, QMatrix4x4 const&, QRect const&) () at /usr/lib/x86_64-linux-gnu/libkwin.so.5
#24 0x00007f183437b541 in KWin::SceneOpenGL::paint(QRegion, QList<KWin::Toplevel*>) () at /usr/lib/x86_64-linux-gnu/qt5/plugins/org.kde.kwin.scenes/KWinSceneOpenGL.so
#25 0x00007f18588213e2 in KWin::Compositor::performCompositing() () at /usr/lib/x86_64-linux-gnu/libkwin.so.5
#26 0x00007f18560ab18b in QObject::event(QEvent*) () at /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#27 0x00007f1856df983c in QApplicationPrivate::notify_helper(QObject*, QEvent*) () at /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#28 0x00007f1856e01104 in QApplication::notify(QObject*, QEvent*) () at /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#29 0x00007f185607b9e8 in QCoreApplication::notifyInternal2(QObject*, QEvent*) () at /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#30 0x00007f18560d3e3e in QTimerInfoList::activateTimers() () at /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#31 0x00007f18560d1ff2 in QEventDispatcherUNIX::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) () at /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#32 0x00007f184092f5cd in  () at /usr/lib/x86_64-linux-gnu/libQt5XcbQpa.so.5
#33 0x00007f1856079a1a in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) () at /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#34 0x00007f1856082ac4 in QCoreApplication::exec() () at /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#35 0x00007f1858fb3dbb in kdemain () at /usr/lib/x86_64-linux-gnu/libkdeinit5_kwin_x11.so
#36 0x00007f1858bdbb97 in __libc_start_main (main=0x55b5e5e6d730, argc=3, argv=0x7fffa6727718, init=<optimized out>, fini=<optimized out>, rtld_fini=<optimized out>, stack_end=0x7fffa6727708) at ../csu/libc-start.c:310
#37 0x000055b5e5e6d76a in _start ()

Reported using DrKonqi
Comment 1 Aritz Beobide-Cardinal 2019-04-11 22:25:52 UTC
Update:
After some additional testing, It would appear that only the cube desktop switching animation causes a crash. Fade and slide work fine.
Comment 2 Vlad Zahorodnii 2019-04-12 11:06:32 UTC
Could you please install kwin debug packages and submit a new backtrace?
Comment 3 Aritz Beobide-Cardinal 2019-04-12 21:12:36 UTC
Hello, there!
Which packages would that be? I've installed kwin-dev but the stack trace appears to be nearly identical.
Comment 4 Vlad Zahorodnii 2019-04-13 16:53:59 UTC
Sorry, I have no idea what packages you have to install on Ubuntu or Debian. I suggest to seek for help on your distro's forum.
Comment 5 David Edmundson 2019-04-13 17:39:40 UTC
Ran the script that @Aritz supplied:

Thread 1 (Thread 0x7fe1cb67f140 (LWP 4696)):
[KCrash Handler]
#6  0x00007fe1c8b27d7f in raise () at /usr/lib/libc.so.6
#7  0x00007fe1c8b12672 in abort () at /usr/lib/libc.so.6
#8  0x00007fe1c90922d4 in qt_message_fatal(QtMsgType, QMessageLogContext const&, QString const&) (context=..., message=...) at /home/david/projects/qt5/qtbase/src/corelib/global/qlogging.cpp:1904
#9  0x00007fe1c9092f1f in QMessageLogger::fatal(char const*, ...) const (this=this@entry=0x7ffe38aa64d0, msg=msg@entry=0x7fe1c9357e20 "ASSERT failure in %s: \"%s\", file %s, line %d") at /home/david/projects/qt5/qtbase/src/corelib/global/qlogging.cpp:888
#10 0x00007fe1c908cc8e in qt_assert_x(char const*, char const*, char const*, int) (where=<optimized out>, what=<optimized out>, file=<optimized out>, line=<optimized out>) at ../../include/QtCore/../../../../qt5/qtbase/src/corelib/global/qlogging.h:91
#11 0x00007fe1cd25c8e5 in QVector<QVector<QRect> >::operator[](int) const (this=0x560e26ccb5a8, i=2) at /opt/qt5/include/QtCore/qvector.h:433
#12 0x00007fe1cd2482cd in KWin::Workspace::clientArea(KWin::clientAreaOption, int, int) const (this=0x560e26ccb410, opt=KWin::FullArea, screen=0, desktop=2) at /home/david/projects/kde5/src/kde/workspace/kwin/geometry.cpp:368
#13 0x00007fe1cd2a83db in KWin::EffectsHandlerImpl::clientArea(KWin::clientAreaOption, int, int) const (this=0x560e270d8e20, opt=KWin::FullArea, screen=0, desktop=2) at /home/david/projects/kde5/src/kde/workspace/kwin/effects.cpp:1249
#14 0x00007fe1cce1b559 in KWin::CubeSlideEffect::prePaintWindow(KWin::EffectWindow*, KWin::WindowPrePaintData&, int) (this=0x560e2779f300, w=0x560e279cf450, data=..., time=44) at /home/david/projects/kde5/src/kde/workspace/kwin/effects/cubeslide/cubeslide.cpp:196
#15 0x00007fe1cd2a4c47 in KWin::EffectsHandlerImpl::prePaintWindow(KWin::EffectWindow*, KWin::WindowPrePaintData&, int) (this=0x560e270d8e20, w=0x560e279cf450, data=..., time=44) at /home/david/projects/kde5/src/kde/workspace/kwin/effects.cpp:427
#16 0x00007fe1ccf9d322 in KWin::AnimationEffect::prePaintWindow(KWin::EffectWindow*, KWin::WindowPrePaintData&, int) (this=0x7fe1bc003230, w=0x560e279cf450, data=..., time=44) at /home/david/projects/kde5/src/kde/workspace/kwin/libkwineffects/kwinanimationeffect.cpp:612
#17 0x00007fe1cd2a4c47 in KWin::EffectsHandlerImpl::prePaintWindow(KWin::EffectWindow*, KWin::WindowPrePaintData&, int) (this=0x560e270d8e20, w=0x560e279cf450, data=..., time=44) at /home/david/projects/kde5/src/kde/workspace/kwin/effects.cpp:427
#18 0x00007fe1cd2876c2 in KWin::Scene::paintGenericScreen(int, KWin::ScreenPaintData) (this=0x560e276eff20, orig_mask=112) at /home/david/projects/kde5/src/kde/workspace/kwin/scene.cpp:226
Comment 6 David Edmundson 2019-04-13 17:41:48 UTC
Similar, but not identical to 390247
Comment 7 Vlad Zahorodnii 2019-05-07 12:14:33 UTC
Git commit e8b45cce1168859e58fe98b45f8060052ed861a7 by Vlad Zagorodniy.
Committed on 07/05/2019 at 12:13.
Pushed by vladz into branch 'master'.

[effects/cubeslide] Cancel active animation when number of desktops has changed

Summary:
If a virtual desktop is removed, then desktopChanged will be followed by
numberDesktopsChanged signal. In which case, we have to cancel the
active animation because front_desktop might be no longer valid when
it's time to perform compositing.

Reviewers: #kwin, davidedmundson

Reviewed By: #kwin, davidedmundson

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D21064

M  +24   -0    effects/cubeslide/cubeslide.cpp
M  +1    -0    effects/cubeslide/cubeslide.h

https://commits.kde.org/kwin/e8b45cce1168859e58fe98b45f8060052ed861a7