Bug 241273 - deadlock when zooming data
Summary: deadlock when zooming data
Status: RESOLVED FIXED
Alias: None
Product: kst
Classification: Applications
Component: general (show other bugs)
Version: 1.10.0
Platform: Compiled Sources Linux
: NOR normal
Target Milestone: ---
Assignee: kst
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-06-10 10:02 UTC by Timo Lindfors
Modified: 2010-06-16 01:28 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Timo Lindfors 2010-06-10 10:02:12 UTC
Version:           1.10.0_devel (using Devel) 
OS:                Linux

Steps to reproduce:
1) Follow the steps listed in bug #240597

Actual results:
9) kst stops responding.

More info:
1) gdb shows a deadlock:

(gdb) thread apply all bt

Thread 2 (Thread 0x7fd47a2da710 (LWP 15934)):
#0  pthread_cond_wait@@GLIBC_2.3.2 () at ../nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S:162
#1  0x00007fd489189ce2 in KstWaitCondition::wait(QMutex*, unsigned long) () from /home/lindi/scm/graphics/kst/src/libkst/libkstbase.so.1
#2  0x00007fd48914c9d9 in KstRWLock::writeLock() const () from /home/lindi/scm/graphics/kst/src/libkst/libkstbase.so.1
#3  0x00007fd4893f1eac in KstDataObject::writeLockInputsAndOutputs() const () from /home/lindi/scm/graphics/kst/src/libkstmath/libkstmath.so.1
#4  0x00007fd48940b3c5 in KstVCurve::update(int) () from /home/lindi/scm/graphics/kst/src/libkstmath/libkstmath.so.1
#5  0x00007fd48a0fd83b in UpdateThread::doUpdates(bool, bool*) () from /home/lindi/scm/graphics/kst/src/libkstapp/libkstapp.so.1
#6  0x00007fd48a0fed06 in UpdateThread::run() () from /home/lindi/scm/graphics/kst/src/libkstapp/libkstapp.so.1
#7  0x00007fd486b78e5b in QThreadInstance::start(void*) () from /usr/lib/libqt-mt.so.3
#8  0x00007fd4827348ba in start_thread (arg=<value optimized out>) at pthread_create.c:300
#9  0x00007fd4873bb01d in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:112
#10 0x0000000000000000 in ?? ()

Thread 1 (Thread 0x7fd48a656760 (LWP 15933)):
#0  pthread_cond_wait@@GLIBC_2.3.2 () at ../nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S:162
#1  0x00007fd489189ce2 in KstWaitCondition::wait(QMutex*, unsigned long) () from /home/lindi/scm/graphics/kst/src/libkst/libkstbase.so.1
#2  0x00007fd48914c723 in KstRWLock::readLock() const () from /home/lindi/scm/graphics/kst/src/libkst/libkstbase.so.1
#3  0x00007fd48940efee in KstVCurve::paint(KstCurveRenderContext const&) () from /home/lindi/scm/graphics/kst/src/libkstmath/libkstmath.so.1
#4  0x00007fd48a017729 in Kst2DPlot::draw(KstPainter&) () from /home/lindi/scm/graphics/kst/src/libkstapp/libkstapp.so.1
#5  0x00007fd48a017e83 in Kst2DPlot::draw() () from /home/lindi/scm/graphics/kst/src/libkstapp/libkstapp.so.1
#6  0x00007fd48a017f40 in Kst2DPlot::updateSelf() () from /home/lindi/scm/graphics/kst/src/libkstapp/libkstapp.so.1
#7  0x00007fd48a056b1d in KstViewObject::paintUpdate() () from /home/lindi/scm/graphics/kst/src/libkstapp/libkstapp.so.1
#8  0x00007fd48a059c93 in KstViewObject::paint(KstPainter&, QRegion const&) () from /home/lindi/scm/graphics/kst/src/libkstapp/libkstapp.so.1
#9  0x00007fd48a05a114 in KstViewObject::paint(KstPainter&, QRegion const&) () from /home/lindi/scm/graphics/kst/src/libkstapp/libkstapp.so.1
#10 0x00007fd48a06e09f in KstTopLevelView::paint(KstPainter::PaintType, QRegion const&) () from /home/lindi/scm/graphics/kst/src/libkstapp/libkstapp.so.1
#11 0x00007fd48a06e18b in KstTopLevelView::paint(KstPainter::PaintType) () from /home/lindi/scm/graphics/kst/src/libkstapp/libkstapp.so.1
#12 0x00007fd48a051a81 in KstViewWidget::paintEvent(QPaintEvent*) () from /home/lindi/scm/graphics/kst/src/libkstapp/libkstapp.so.1
#13 0x00007fd489ffd3b5 in Kst2DPlot::wheelEvent(QWidget*, QWheelEvent*) () from /home/lindi/scm/graphics/kst/src/libkstapp/libkstapp.so.1
#14 0x00007fd48a05446f in KstViewWidget::wheelEvent(QWheelEvent*) () from /home/lindi/scm/graphics/kst/src/libkstapp/libkstapp.so.1
#15 0x00007fd486c0fe30 in QWidget::event(QEvent*) () from /usr/lib/libqt-mt.so.3
#16 0x00007fd486b7e725 in QApplication::internalNotify(QObject*, QEvent*) () from /usr/lib/libqt-mt.so.3
#17 0x00007fd486b7fae3 in QApplication::notify(QObject*, QEvent*) () from /usr/lib/libqt-mt.so.3
#18 0x00007fd488e1e4a4 in KApplication::notify(QObject*, QEvent*) () from /usr/lib/libkdecore.so.4
#19 0x00007fd486b13bec in QETWidget::translateWheelEvent(int, int, int, int, Qt::Orientation) () from /usr/lib/libqt-mt.so.3
#20 0x00007fd486b1df49 in QETWidget::translateMouseEvent(_XEvent const*) () from /usr/lib/libqt-mt.so.3
#21 0x00007fd486b1cd68 in QApplication::x11ProcessEvent(_XEvent*) () from /usr/lib/libqt-mt.so.3
#22 0x00007fd486b2f35a in QEventLoop::processEvents(unsigned int) () from /usr/lib/libqt-mt.so.3
#23 0x00007fd486b94fa1 in QEventLoop::enterLoop() () from /usr/lib/libqt-mt.so.3
#24 0x00007fd486b94e62 in QEventLoop::exec() () from /usr/lib/libqt-mt.so.3
#25 0x000000000040d493 in main ()


Reproducible: Didn't try
Comment 1 Andrew Walker 2010-06-11 02:15:40 UTC
The problem appears to be that in KstVCurve::paint the vectors are locked in a defined order (namely xv, yv, [exv], [eyv], [exmv], [eymv]) while in KstVCurve::update (which uses KstdataObject::writeLockInputsAndOutputs for the actualt locking) the order may be different.

The solution is to lock the vectors in the same order in both cases, else we face a potential deadlock.
Comment 2 Andrew Walker 2010-06-11 19:22:18 UTC
SVN commit 1137113 by arwalker:

CCBUG:241273 This should solve the deadlock issue, by ensuring that all of the locks are obtained in one thread before any of the locks are obtained in the other. Will leave the bug report open for a while to allow for testing.

 M  +3 -1      kstdataobject.cpp  
 M  +2 -1      kstdataobject.h  
 M  +6 -0      kstvcurve.cpp  


WebSVN link: http://websvn.kde.org/?view=rev&revision=1137113
Comment 3 Nicolas Brisset 2010-06-14 08:31:55 UTC
Does this possibly also exist in kst 2.x?
Comment 4 Timo Lindfors 2010-06-14 09:57:57 UTC
I upgraded to svn 1137746 but I still see a deadlock if I resize the kst window a few times after step 10:

Thread 2 (Thread 0x7f784b483710 (LWP 16173)):
#0  pthread_cond_wait@@GLIBC_2.3.2 () at ../nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S:162
#1  0x00007f7856c96df2 in KstWaitCondition::wait(QMutex*, unsigned long) () from /home/lindi/scm/graphics/kst/src/libkst/libkstbase.so.1
#2  0x00007f7856c59ae9 in KstRWLock::writeLock() const () from /home/lindi/scm/graphics/kst/src/libkst/libkstbase.so.1
#3  0x00007f7856efcab4 in KstDataObject::writeLockInputsAndOutputs() () from /home/lindi/scm/graphics/kst/src/libkstmath/libkstmath.so.1
#4  0x00007f7856f184b5 in KstVCurve::update(int) () from /home/lindi/scm/graphics/kst/src/libkstmath/libkstmath.so.1
#5  0x00007f7857c0a85b in UpdateThread::doUpdates(bool, bool*) () from /home/lindi/scm/graphics/kst/src/libkstapp/libkstapp.so.1
#6  0x00007f7857c0bd26 in UpdateThread::run() () from /home/lindi/scm/graphics/kst/src/libkstapp/libkstapp.so.1
#7  0x00007f7854685e5b in QThreadInstance::start(void*) () from /usr/lib/libqt-mt.so.3
#8  0x00007f78502418ba in start_thread (arg=<value optimized out>) at pthread_create.c:300
#9  0x00007f7854ec801d in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:112
#10 0x0000000000000000 in ?? ()

Thread 1 (Thread 0x7f785815f760 (LWP 16157)):
#0  __lll_lock_wait () at ../nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.S:136
#1  0x00007f78502440e9 in _L_lock_953 () from /lib/libpthread.so.0
#2  0x00007f7850243f0b in __pthread_mutex_lock (mutex=0x13f01a8) at pthread_mutex_lock.c:61
#3  0x00007f785495fd7d in QRealMutexPrivate::lock() () from /usr/lib/libqt-mt.so.3
#4  0x00007f7856f1a6e0 in KstVCurve::paint(KstCurveRenderContext const&) () from /home/lindi/scm/graphics/kst/src/libkstmath/libkstmath.so.1
#5  0x00007f7857b24729 in Kst2DPlot::draw(KstPainter&) () from /home/lindi/scm/graphics/kst/src/libkstapp/libkstapp.so.1
#6  0x00007f7857b24e83 in Kst2DPlot::draw() () from /home/lindi/scm/graphics/kst/src/libkstapp/libkstapp.so.1
#7  0x00007f7857b24f40 in Kst2DPlot::updateSelf() () from /home/lindi/scm/graphics/kst/src/libkstapp/libkstapp.so.1
#8  0x00007f7857b63b2d in KstViewObject::paintUpdate() () from /home/lindi/scm/graphics/kst/src/libkstapp/libkstapp.so.1
#9  0x00007f7857b66ca3 in KstViewObject::paint(KstPainter&, QRegion const&) () from /home/lindi/scm/graphics/kst/src/libkstapp/libkstapp.so.1
#10 0x00007f7857b67124 in KstViewObject::paint(KstPainter&, QRegion const&) () from /home/lindi/scm/graphics/kst/src/libkstapp/libkstapp.so.1
#11 0x00007f7857b7b0af in KstTopLevelView::paint(KstPainter::PaintType, QRegion const&) () from /home/lindi/scm/graphics/kst/src/libkstapp/libkstapp.so.1
#12 0x00007f7857b7b19b in KstTopLevelView::paint(KstPainter::PaintType) () from /home/lindi/scm/graphics/kst/src/libkstapp/libkstapp.so.1
#13 0x00007f7857b5ea91 in KstViewWidget::paintEvent(QPaintEvent*) () from /home/lindi/scm/graphics/kst/src/libkstapp/libkstapp.so.1
#14 0x00007f7857b0a3b5 in Kst2DPlot::wheelEvent(QWidget*, QWheelEvent*) () from /home/lindi/scm/graphics/kst/src/libkstapp/libkstapp.so.1
#15 0x00007f7857b6147f in KstViewWidget::wheelEvent(QWheelEvent*) () from /home/lindi/scm/graphics/kst/src/libkstapp/libkstapp.so.1
#16 0x00007f785471ce30 in QWidget::event(QEvent*) () from /usr/lib/libqt-mt.so.3
#17 0x00007f785468b725 in QApplication::internalNotify(QObject*, QEvent*) () from /usr/lib/libqt-mt.so.3
#18 0x00007f785468cae3 in QApplication::notify(QObject*, QEvent*) () from /usr/lib/libqt-mt.so.3
#19 0x00007f785692b4a4 in KApplication::notify(QObject*, QEvent*) () from /usr/lib/libkdecore.so.4
#20 0x00007f7854620bec in QETWidget::translateWheelEvent(int, int, int, int, Qt::Orientation) () from /usr/lib/libqt-mt.so.3
#21 0x00007f785462af49 in QETWidget::translateMouseEvent(_XEvent const*) () from /usr/lib/libqt-mt.so.3
#22 0x00007f7854629d68 in QApplication::x11ProcessEvent(_XEvent*) () from /usr/lib/libqt-mt.so.3
#23 0x00007f785463c35a in QEventLoop::processEvents(unsigned int) () from /usr/lib/libqt-mt.so.3
#24 0x00007f78546a1fa1 in QEventLoop::enterLoop() () from /usr/lib/libqt-mt.so.3
#25 0x00007f78546a1e62 in QEventLoop::exec() () from /usr/lib/libqt-mt.so.3
#26 0x000000000040d493 in main ()
Comment 5 Andrew Walker 2010-06-14 21:27:05 UTC
This I can reproduce, without the need for steps 3 to 11 inclusive.
Comment 6 Andrew Walker 2010-06-15 20:00:54 UTC
SVN commit 1138336 by arwalker:

CCBUG:241273 lock all the inputs to a KstVCurve::paint at the same time, to avoid a potential deadlock

 M  +24 -26    kstvcurve.cpp  


WebSVN link: http://websvn.kde.org/?view=rev&revision=1138336
Comment 7 Andrew Walker 2010-06-16 01:28:01 UTC
Am now unable to reproduce the deadlock.