Bug 135176 - deadlock on exit with specific file
Summary: deadlock on exit with specific file
Status: RESOLVED FIXED
Alias: None
Product: kst
Classification: Applications
Component: general (show other bugs)
Version: 1.x
Platform: Compiled Sources Linux
: NOR grave
Target Milestone: ---
Assignee: kst
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-10-06 04:19 UTC by George Staikos
Modified: 2010-08-14 14:41 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description George Staikos 2006-10-06 04:19:24 UTC
in #135049 the file can cause a deadlock on exit:

#4  0x420d9676 in pthread_cond_wait@@GLIBC_2.3.2 ()
   from /lib/tls/libpthread.so.0
#5  0x40ad56ad in KstWaitCondition::wait (this=0x40b0c15c, mutex=0x40b0c14c,
    time=4294967295)
    at kst/src/libkst/kstwaitcondition_unix.cpp:309
#6  0x40a97ea5 in KstRWLock::writeLock (this=0x40b0c148)
    at kst/src/libkst/rwlock.cpp:93
#7  0x40425aa0 in KstDoc::deleteContents (this=0x8205ab0)
    at kst/src/libkstapp/kstdoc.cpp:803
#8  0x4041a2c0 in ~KstDoc (this=0x8205ab0)
    at kst/src/libkstapp/kstdoc.cpp:90
#9  0x419b7dae in ~QWidget (this=0x82074f0) at qwidget.cpp:973
#10 0x41a84a65 in ~QMainWindow (this=0x82074f0) at qmainwindow.cpp:917
#11 0x411bd374 in KMainWindow::~KMainWindow () at qcstring.h:65
#12 0x4125e4ad in KDockMainWindow::~KDockMainWindow () at qcstring.h:65
#13 0x40c35a6b in KParts::DockMainWindow::~DockMainWindow ()
   from /opt/kde-devel/lib/libkparts.so.2
#14 0x40bde391 in KMdiMainFrm::~KMdiMainFrm ()
   from /opt/kde-devel/lib/libkmdi.so.1
#15 0x404ab0e2 in ~KstApp (this=0x82074f0)
    at kst/src/libkstapp/kst.cpp:258
#16 0x0805e4d4 in main (argc=2, argv=0xbffff294)
    at kst/src/kst/main.cpp:821
Comment 1 George Staikos 2006-10-06 06:34:28 UTC
SVN commit 592888 by staikos:

Remove some deadlock cases
BUG: 135171
BUG: 135176


 M  +15 -12    kstdoc.cpp  
 M  +5 -3      updatethread.cpp  


--- trunk/extragear/graphics/kst/src/libkstapp/kstdoc.cpp #592887:592888
@@ -792,14 +792,25 @@
     }
   }
 
+  KST::dataObjectList.lock().writeLock();
+  // Avoid deadlock in DataObject destructor
+  KstDataObjectList tmpDol = QDeepCopy<KstDataObjectList>(KST::dataObjectList);
+  KST::dataObjectList.clear();
+  KST::dataObjectList.lock().unlock();
+  tmpDol.clear();
+
+  KST::dataSourceList.lock().writeLock();
+  KST::dataSourceList.clear();
+  KST::dataSourceList.lock().unlock();
+
+  KST::matrixList.lock().writeLock();
+  KST::matrixList.clear();
+  KST::matrixList.lock().unlock();
+
   KST::vectorList.lock().writeLock();
   KST::vectorList.clear();
   KST::vectorList.lock().unlock();
   
-  KST::matrixList.lock().writeLock();
-  KST::matrixList.clear();
-  KST::matrixList.lock().unlock();
-
   KST::scalarList.lock().writeLock();
   KST::scalarList.clear();
   KST::scalarList.lock().unlock();
@@ -808,14 +819,6 @@
   KST::stringList.clear();
   KST::stringList.lock().unlock();
 
-  KST::dataSourceList.lock().writeLock();
-  KST::dataSourceList.clear();
-  KST::dataSourceList.lock().unlock();
-
-  KST::dataObjectList.lock().writeLock();
-  KST::dataObjectList.clear();
-  KST::dataObjectList.lock().unlock();
-
   emit updateDialogs();
 }
 
--- trunk/extragear/graphics/kst/src/libkstapp/updatethread.cpp #592887:592888
@@ -19,6 +19,8 @@
 
 #include <assert.h>
 
+#include <qdeepcopy.h>
+
 #include "ksdebug.h"
 
 #include "kstdatacollection.h"
@@ -234,7 +236,9 @@
     KstScalar::clearScalarsDirty(); // Must do this first and take a risk of
                                     // falling slightly behind
     KST::scalarList.lock().readLock();
-    for (KstScalarList::ConstIterator i = KST::scalarList.begin(); i != KST::scalarList.end(); ++i) {
+    KstScalarList sl = QDeepCopy<KstScalarList>(KST::scalarList); // avoid deadlock on exit
+    KST::scalarList.lock().unlock();
+    for (KstScalarList::ConstIterator i = sl.begin(); i != sl.end(); ++i) {
       KstScalarPtr sp = *i;
 
       sp->writeLock();
@@ -246,11 +250,9 @@
       }
 
       if (_done) {
-        KST::scalarList.lock().unlock();
         return false;
       }
     }
-    KST::scalarList.lock().unlock();
   }
 
   if (U == KstObject::UPDATE) {
Comment 2 Peter Kümmel 2010-08-14 14:41:00 UTC
Change version to 1.x