Bug 309695

Summary: Crash in KWin::Screenedge::unreserve on deactivating Actos script
Product: [Plasma] kwin Reporter: Will Stephenson <wstephenson>
Component: generalAssignee: KWin default assignee <kwin-bugs-null>
Status: RESOLVED FIXED    
Severity: crash Flags: mgraesslin: ReviewRequest+
Priority: NOR    
Version: 4.9.2   
Target Milestone: 4.11   
Platform: unspecified   
OS: Linux   
URL: https://git.reviewboard.kde.org/r/108513/
Latest Commit: Version Fixed In: 4.11
Sentry Crash Report:

Description Will Stephenson 2012-11-07 14:02:21 UTC
Eeek!  No 4.9.3 component in bko!

How to trigger: Disable Actos Dashboard kwin script in script manager, click apply, nothing happens, run "kwin --replace" in krunner, bang in Thread 1:

Application: KWin (kwin), signal: Segmentation fault
Using host libthread_db library "/lib64/libthread_db.so.1".
[Current thread is 1 (Thread 0x7f52548bf780 (LWP 5482))]

Thread 5 (Thread 0x7f523b2e0700 (LWP 5486)):
#0  0x00007f52540eaf13 in select () from /lib64/libc.so.6
#1  0x00007f524fd0b602 in QProcessManager::run (this=0x7f52500844c0 <processManager()::processManager>) at io/qprocess_unix.cpp:245
#2  0x00007f524fc30f9c in QThreadPrivate::start (arg=0x7f52500844c0 <processManager()::processManager>) at thread/qthread_unix.cpp:338
#3  0x00007f524f99ae0e in start_thread () from /lib64/libpthread.so.0
#4  0x00007f52540f12bd in clone () from /lib64/libc.so.6

Thread 4 (Thread 0x7f5238a14700 (LWP 5492)):
#0  0x00007f524f99e8f4 in pthread_cond_wait@@GLIBC_2.3.2 () from /lib64/libpthread.so.0
#1  0x00007f5250fe6247 in QTWTF::TCMalloc_PageHeap::scavengerThread (this=0x7f52512f3640 <QTWTF::pageheap_memory>) at ../3rdparty/javascriptcore/JavaScriptCore/wtf/FastMalloc.cpp:2359
#2  0x00007f5250fe6279 in QTWTF::TCMalloc_PageHeap::runScavengerThread (context=<optimized out>) at ../3rdparty/javascriptcore/JavaScriptCore/wtf/FastMalloc.cpp:1464
#3  0x00007f524f99ae0e in start_thread () from /lib64/libpthread.so.0
#4  0x00007f52540f12bd in clone () from /lib64/libc.so.6

Thread 3 (Thread 0x7f52311fd700 (LWP 5495)):
#0  0x00007f52540eaf13 in select () from /lib64/libc.so.6
#1  0x00007f524fd58113 in qt_safe_select (nfds=27, fdread=0x7f5218000ac8, fdwrite=0x7f5218000d60, fdexcept=0x7f5218000ff8, orig_timeout=0x0) at kernel/qcore_unix.cpp:83
#2  0x00007f524fd5cac4 in QEventDispatcherUNIXPrivate::doSelect (this=this@entry=0x7f5218000910, flags=..., timeout=0x0) at kernel/qeventdispatcher_unix.cpp:223
#3  0x00007f524fd5dc52 in QEventDispatcherUNIX::processEvents (this=0x7f52180008f0, flags=...) at kernel/qeventdispatcher_unix.cpp:941
#4  0x00007f524fd2b85f in QEventLoop::processEvents (this=this@entry=0x7f52311fcdd0, flags=...) at kernel/qeventloop.cpp:149
#5  0x00007f524fd2bae8 in QEventLoop::exec (this=0x7f52311fcdd0, flags=...) at kernel/qeventloop.cpp:204
#6  0x00007f524fc2dfc0 in QThread::exec (this=<optimized out>) at thread/qthread.cpp:501
#7  0x00007f524fd0bfcf in QInotifyFileSystemWatcherEngine::run (this=0x2491310) at io/qfilesystemwatcher_inotify.cpp:248
#8  0x00007f524fc30f9c in QThreadPrivate::start (arg=0x2491310) at thread/qthread_unix.cpp:338
#9  0x00007f524f99ae0e in start_thread () from /lib64/libpthread.so.0
#10 0x00007f52540f12bd in clone () from /lib64/libc.so.6

Thread 2 (Thread 0x7f522603e700 (LWP 5529)):
#0  0x00007f52540eaf13 in select () from /lib64/libc.so.6
#1  0x00007f524fd58113 in qt_safe_select (nfds=31, fdread=0x7f5210000ac8, fdwrite=0x7f5210000d60, fdexcept=0x7f5210000ff8, orig_timeout=0x0) at kernel/qcore_unix.cpp:83
#2  0x00007f524fd5cac4 in QEventDispatcherUNIXPrivate::doSelect (this=this@entry=0x7f5210000910, flags=..., timeout=0x0) at kernel/qeventdispatcher_unix.cpp:223
#3  0x00007f524fd5dc52 in QEventDispatcherUNIX::processEvents (this=0x7f52100008f0, flags=...) at kernel/qeventdispatcher_unix.cpp:941
#4  0x00007f524fd2b85f in QEventLoop::processEvents (this=this@entry=0x7f522603de00, flags=...) at kernel/qeventloop.cpp:149
#5  0x00007f524fd2bae8 in QEventLoop::exec (this=0x7f522603de00, flags=...) at kernel/qeventloop.cpp:204
#6  0x00007f524fc2dfc0 in QThread::exec (this=<optimized out>) at thread/qthread.cpp:501
#7  0x00007f524fc30f9c in QThreadPrivate::start (arg=0x7f521c0022b0) at thread/qthread_unix.cpp:338
#8  0x00007f524f99ae0e in start_thread () from /lib64/libpthread.so.0
#9  0x00007f52540f12bd in clone () from /lib64/libc.so.6

Thread 1 (Thread 0x7f52548bf780 (LWP 5482)):
[KCrash Handler]
#6  detach (this=<optimized out>) at /usr/include/QtCore/qvector.h:147
#7  data (this=<optimized out>) at /usr/include/QtCore/qvector.h:152
#8  operator[] (i=<optimized out>, this=<optimized out>) at /usr/include/QtCore/qvector.h:360
#9  KWin::ScreenEdge::unreserve (this=0x78, border=KWin::ElectricTopLeft) at /usr/src/debug/kde-workspace-4.9.3/kwin/screenedge.cpp:191
#10 0x00007f525448ad68 in KWin::AbstractScript::~AbstractScript (this=0x155ebf0, __in_chrg=<optimized out>) at /usr/src/debug/kde-workspace-4.9.3/kwin/scripting/scripting.cpp:218
#11 0x00007f525448add9 in KWin::DeclarativeScript::~DeclarativeScript (this=0x155ebf0, __in_chrg=<optimized out>) at /usr/src/debug/kde-workspace-4.9.3/kwin/scripting/scripting.cpp:427
#12 0x00007f524fd3f232 in QObjectPrivate::deleteChildren (this=this@entry=0x1216af0) at kernel/qobject.cpp:1917
#13 0x00007f524fd44406 in QObject::~QObject (this=0xfc9ed0, __in_chrg=<optimized out>) at kernel/qobject.cpp:927
#14 0x00007f525448d5e8 in KWin::Scripting::~Scripting (this=0xfc9ed0, __in_chrg=<optimized out>) at /usr/src/debug/kde-workspace-4.9.3/kwin/scripting/scripting.cpp:618
#15 0x00007f525448d5f9 in KWin::Scripting::~Scripting (this=0xfc9ed0, __in_chrg=<optimized out>) at /usr/src/debug/kde-workspace-4.9.3/kwin/scripting/scripting.cpp:622
#16 0x00007f524fd3f232 in QObjectPrivate::deleteChildren (this=this@entry=0x1193060) at kernel/qobject.cpp:1917
#17 0x00007f524fd44406 in QObject::~QObject (this=0x1199c50, __in_chrg=<optimized out>) at kernel/qobject.cpp:927
#18 0x00007f52543f9bca in KWin::Workspace::~Workspace (this=0x1199c50, __in_chrg=<optimized out>) at /usr/src/debug/kde-workspace-4.9.3/kwin/workspace.cpp:512
#19 0x00007f52543f9c09 in KWin::Workspace::~Workspace (this=0x1199c50, __in_chrg=<optimized out>) at /usr/src/debug/kde-workspace-4.9.3/kwin/workspace.cpp:564
#20 0x00007f5254416697 in KWin::Application::lostSelection (this=0x7ffff0ad29d0) at /usr/src/debug/kde-workspace-4.9.3/kwin/main.cpp:354
#21 0x00007f524fd4339f in QMetaObject::activate (sender=0x7ffff0ad29e8, m=<optimized out>, local_signal_index=<optimized out>, argv=0x0) at kernel/qobject.cpp:3556
#22 0x00007f5253c51db3 in KSelectionOwner::filterEvent (this=0x7ffff0ad29e8, ev_P=<optimized out>) at /usr/src/debug/kdelibs-4.9.3/kdeui/util/kmanagerselection.cpp:224
#23 0x00007f5253bf135e in publicx11Event (e=<optimized out>, this=<optimized out>) at /usr/src/debug/kdelibs-4.9.3/kdeui/kernel/kapplication.cpp:918
#24 KApplication::x11EventFilter (this=0x78, _event=0x7ffff0ad2470) at /usr/src/debug/kdelibs-4.9.3/kdeui/kernel/kapplication.cpp:930
#25 0x00007f524ef26a8c in qt_x11EventFilter (ev=0x7ffff0ad2470) at kernel/qapplication_x11.cpp:435
#26 qt_x11EventFilter (ev=0x7ffff0ad2470) at kernel/qapplication_x11.cpp:423
#27 0x00007f524ef3406b in QApplication::x11ProcessEvent (this=0x7ffff0ad29d0, event=0x7ffff0ad2470) at kernel/qapplication_x11.cpp:3353
#28 0x00007f524ef5b819 in QEventDispatcherX11::processEvents (this=0xf5aa70, flags=...) at kernel/qeventdispatcher_x11.cpp:132
#29 0x00007f524fd2b85f in QEventLoop::processEvents (this=this@entry=0x7ffff0ad26e0, flags=...) at kernel/qeventloop.cpp:149
#30 0x00007f524fd2bae8 in QEventLoop::exec (this=0x7ffff0ad26e0, flags=...) at kernel/qeventloop.cpp:204
#31 0x00007f524fd30788 in QCoreApplication::exec () at kernel/qcoreapplication.cpp:1187
#32 0x00007f52544177e4 in kdemain (argc=3, argv=0x7ffff0ad2b18) at /usr/src/debug/kde-workspace-4.9.3/kwin/main.cpp:545
#33 0x00007f525402e455 in __libc_start_main () from /lib64/libc.so.6
#34 0x0000000000400721 in _start () at ../sysdeps/x86_64/elf/start.S:113
Comment 1 Thomas Lübking 2012-11-07 20:49:26 UTC
> KWin::ScreenEdge::unreserve (this=0x78

Happens because of random order in QObjectPrivate::deleteChildren, m_screenEdge is gone before scripting

-> we need to export the shutdown state
Comment 2 Martin Flöser 2013-01-30 08:07:42 UTC
The screen edges review also contains a fix for this problem by no longer needing to manually call unregister in the dtor.
Comment 3 Martin Flöser 2013-02-07 09:02:01 UTC
Git commit 3358685a52be3c7cef1497b6f84b7d1af2f920d7 by Martin Gräßlin.
Committed on 22/01/2013 at 12:47.
Pushed by graesslin into branch 'master'.

Change the way how screen edges interact with Effects/Scripts

The main difference is that the activation of an edge is no longer
broadcasted to all effects and scripts, but instead a passed in slot of
the Effect/Script is invoked.

For this the EffectsHandler API is changed to take the Effect as an
argument to (un)reserveElectricBorder. As callback slot the existing
borderActivated is used.

In addition the ScreenEdge monitors the object for beeing destroyed and
unregisters the the edge automatically. This removes the need from the
Effect to call unregister in the dtor.
FIXED-IN: 4.11

M  +6    -13   kwin/effects.cpp
M  +2    -3    kwin/effects.h
M  +6    -15   kwin/effects/cube/cube.cpp
M  +2    -5    kwin/effects/desktopgrid/desktopgrid.cpp
M  +4    -10   kwin/effects/flipswitch/flipswitch.cpp
M  +5    -11   kwin/effects/presentwindows/presentwindows.cpp
M  +5    -4    kwin/libkwineffects/kwineffects.h
M  +52   -35   kwin/screenedge.cpp
M  +16   -19   kwin/screenedge.h
M  +2    -11   kwin/scripting/scriptedeffect.cpp
M  +1    -1    kwin/scripting/scriptedeffect.h
M  +2    -11   kwin/scripting/scripting.cpp
M  +1    -1    kwin/scripting/scripting.h
M  +1    -1    kwin/scripting/scriptingutils.h

http://commits.kde.org/kde-workspace/3358685a52be3c7cef1497b6f84b7d1af2f920d7