Bug 321164 - KWin crashes if one changes compositing type fast enough
Summary: KWin crashes if one changes compositing type fast enough
Status: RESOLVED FIXED
Alias: None
Product: kwin
Classification: Plasma
Component: general (show other bugs)
Version: git master
Platform: openSUSE Linux
: NOR crash
Target Milestone: ---
Assignee: KWin default assignee
URL: https://git.reviewboard.kde.org/r/111...
Keywords: drkonqi
Depends on:
Blocks:
 
Reported: 2013-06-14 22:57 UTC by Hrvoje Senjan
Modified: 2013-06-26 10:42 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In: 4.11
thomas.luebking: ReviewRequest+


Attachments
Fix? (1022 bytes, patch)
2013-06-16 11:55 UTC, Thomas Lübking
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Hrvoje Senjan 2013-06-14 22:57:54 UTC
Application: kwin (4.10.80 "release 2")
KDE Platform Version: 4.10.80 "release 2"
Qt Version: 4.8.5
Operating System: Linux 3.10.0-rc4-3.gfc06ef7-desktop x86_64
Distribution: "openSUSE 13.1 Milestone 2 (x86_64)"

-- Information about the crash:
- What I was doing when the application crashed:

As per title. When changing type, or graphicssystem fast enough (via kcm!) in succession, KWin crashes.
I see possible dups, but those are about different settings (though all related to KConfigGroup)
Using master, workspace one commit prior to 4.10.80 tag (but had it also before when checking https://bugs.kde.org/show_bug.cgi?id=179042#c88), kdelibs & co ~at tag

The crash can be reproduced sometimes.

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

Thread 2 (Thread 0x7fe38b388700 (LWP 4578)):
#0  0x00007fe3a05d5d11 in pthread_cond_timedwait@@GLIBC_2.3.2 () from /lib64/libpthread.so.0
#1  0x00007fe3a0868187 in wait (time=30000, this=0x2100cb0) at thread/qwaitcondition_unix.cpp:84
#2  QWaitCondition::wait (this=<optimized out>, mutex=0x21325b8, time=30000) at thread/qwaitcondition_unix.cpp:158
#3  0x00007fe3a085b96f in QThreadPoolThread::run (this=0x2132330) at concurrent/qthreadpool.cpp:141
#4  0x00007fe3a0867ccc in QThreadPrivate::start (arg=0x2132330) at thread/qthread_unix.cpp:338
#5  0x00007fe3a05d1e0e in start_thread () from /lib64/libpthread.so.0
#6  0x00007fe3a67dab9d in clone () from /lib64/libc.so.6

Thread 1 (Thread 0x7fe3a6fe7780 (LWP 4577)):
[KCrash Handler]
#6  0x00007fe3a08696d0 in length (this=0x2022b10) at tools/qbytearray.h:356
#7  qstrcmp (str1=..., str2=...) at tools/qbytearray.cpp:344
#8  0x00007fe3a0fe9a73 in operator< (k2=..., k1=...) at /usr/src/debug/kdelibs-git/kdecore/config/kconfigdata.h:122
#9  qMapLessThanKey<KEntryKey> (key2=..., key1=...) at /usr/include/QtCore/qmap.h:107
#10 findNode (akey=..., this=0x1feeab0) at /usr/include/QtCore/qmap.h:487
#11 find (akey=..., this=0x1feeab0) at /usr/include/QtCore/qmap.h:608
#12 KEntryMap::findEntry (this=0x1feeab0, group=..., key=..., flags=...) at /usr/src/debug/kdelibs-git/kdecore/config/kconfigdata.cpp:78
#13 0x00007fe3a0fe30fa in getEntryOption (option=KEntryMap::EntryImmutable, flags=..., key=..., group=..., this=0x1feeab0) at /usr/src/debug/kdelibs-git/kdecore/config/kconfigdata.h:215
#14 KConfig::isGroupImmutableImpl (this=this@entry=0x1fbbf40, aGroup=...) at /usr/src/debug/kdelibs-git/kdecore/config/kconfig.cpp:744
#15 0x00007fe3a0fe936c in KConfigBase::isGroupImmutable (this=0x1fbbf40, aGroup=...) at /usr/src/debug/kdelibs-git/kdecore/config/kconfigbase.cpp:96
#16 0x00007fe3a0ff01b4 in KConfigGroup::KConfigGroup (this=0x7fffaeca7100, master=0x1fbbf40, _group=...) at /usr/src/debug/kdelibs-git/kdecore/config/kconfiggroup.cpp:468
#17 0x00007fe3a1003519 in KCoreConfigSkeleton::ItemUInt::readConfig (this=0x2022580, config=<optimized out>) at /usr/src/debug/kdelibs-git/kdecore/config/kcoreconfigskeleton.cpp:522
#18 0x00007fe3a100493d in KConfigSkeletonGenericItem<unsigned int>::readDefault (this=0x2022580, config=0x1fbbf40) at /usr/src/debug/kdelibs-git/kdecore/config/kcoreconfigskeleton.h:288
#19 0x00007fe3a1000c25 in KCoreConfigSkeleton::addItem (this=0x7fffaeca7290, item=0x2022580, name=...) at /usr/src/debug/kdelibs-git/kdecore/config/kcoreconfigskeleton.cpp:1113
#20 0x00007fe3a6bdd962 in KWin::Settings::Settings (this=0x7fffaeca7290, config=...) at /usr/src/debug/kde-workspace-git/build/kwin/settings.cpp:363
#21 0x00007fe3a6b2a015 in KWin::Screens::Screens (this=this@entry=0x2132610, parent=<optimized out>) at /usr/src/debug/kde-workspace-git/kwin/screens.cpp:47
#22 0x00007fe3a6b2a079 in KWin::DesktopWidgetScreens::DesktopWidgetScreens (this=0x2132610, parent=<optimized out>) at /usr/src/debug/kde-workspace-git/kwin/screens.cpp:135
#23 0x00007fe3a6b2a109 in KWin::Screens::create (parent=0x20ffb20) at /usr/src/debug/kde-workspace-git/kwin/screens.cpp:33
#24 0x00007fe3a6afd827 in KWin::Workspace::Workspace (this=0x20ffb20, restore=false) at /usr/src/debug/kde-workspace-git/kwin/workspace.cpp:158
#25 0x00007fe3a6b1ba6f in KWin::Application::Application (this=<optimized out>) at /usr/src/debug/kde-workspace-git/kwin/main.cpp:377
#26 0x00007fe3a6b1d3f6 in kdemain (argc=2, argv=0x7fffaeca7f18) at /usr/src/debug/kde-workspace-git/kwin/main.cpp:565
#27 0x00007fe3a6713a15 in __libc_start_main () from /lib64/libc.so.6
#28 0x0000000000400761 in _start () at ../sysdeps/x86_64/start.S:123

Possible duplicates by query: bug 306806, bug 302211.

Reported using DrKonqi
Comment 1 Hrvoje Senjan 2013-06-14 23:04:01 UTC
Please note that i didn't benchmark time :-) just tried changing type just about after kwin/plasma settled with the previous one
Comment 2 Thomas Lübking 2013-06-14 23:39:48 UTC
> When changing type, or graphicssystem

Changing the graphicssystem should (necessarily) restart kwin.
Do you get the same crash for that?
Comment 3 Martin Flöser 2013-06-15 07:49:43 UTC
It might be an idea to deactivate the interface while KWin is reconfiguring. In 
fact that could be interesting for all KCMs.
Comment 4 Thomas Lübking 2013-06-15 08:26:11 UTC
or just schedule reconfig calls inside kwin until all config has finished - should be more robust and long time fix than disabling some guis (to only forget the next one ;-)
Comment 5 Hrvoje Senjan 2013-06-15 19:27:07 UTC
(In reply to comment #2)
> Changing the graphicssystem should (necessarily) restart kwin.
> Do you get the same crash for that?
So far i couldn't reproduce if changing only graphicssystem.
Will try to write down which combos/type trigger it most easily/how to trigger it with lowest amount of effort ;-)
Comment 6 Thomas Lübking 2013-06-15 19:43:19 UTC
(In reply to comment #5)
> (In reply to comment #2)
> > Changing the graphicssystem should (necessarily) restart kwin.
> > Do you get the same crash for that?
> So far i couldn't reproduce if changing only graphicssystem.
Ok, i wouldn't have expected it either.

> Will try to write down which combos/type trigger
no need to, we'll start concurrent reconfigures, that's all - and KConfigGroup hates any concurrent access ;-)
-> see comment #4 - reconfiguration calls need to be scheduled until any current configration has finished.
Comment 7 Martin Flöser 2013-06-16 06:38:53 UTC
> no need to, we'll start concurrent reconfigures, that's all - and
> KConfigGroup hates any concurrent access ;-)
> -> see comment #4 - reconfiguration calls need to be scheduled until any
> current configration has finished.
That reminds me: the Screens::init() is called before the reading of 
KConfigGroup in another thread finished and can cause issues. At least I hit a 
crash a few times there when other things were broken. Didn't change yet as I 
couldn't reproduce when other things were not broken.
Comment 8 Thomas Lübking 2013-06-16 11:55:40 UTC
Created attachment 80548 [details]
Fix?

Ok, as we figured KConfigGroup is not the least threadsafe - this crash is predictable then :(

For the moment Screens::create() will have to move below waitForFinished() as all other config touchers.

@Hrvoje, try to click fast with the attached simple patch ;-)
Comment 9 Hrvoje Senjan 2013-06-16 21:35:02 UTC
(In reply to comment #8)
> @Hrvoje, try to click fast with the attached simple patch ;-)
Clicked like mad, some ~15 times, didn't get a crash :-)
Comment 10 Thomas Lübking 2013-06-17 22:24:39 UTC
Thanks to your rodent for its hard work ;-)
Comment 11 Thomas Lübking 2013-06-26 10:42:13 UTC
Git commit 0b0e9ecf9f038a1c438442189a58d4dfb5ca6f96 by Thomas Lübking.
Committed on 16/06/2013 at 11:56.
Pushed by luebking into branch 'master'.

move Screens::create post global config reading

It calls KConfigGroup what is not thread safe and
collides with threaded config reading.
FIXED-IN: 4.11
REVIEW: 111082

M  +5    -4    kwin/workspace.cpp

http://commits.kde.org/kde-workspace/0b0e9ecf9f038a1c438442189a58d4dfb5ca6f96