Bug 142701 - Cross power spectrum causes continuous asserts in KstRWLock
Summary: Cross power spectrum causes continuous asserts in KstRWLock
Status: RESOLVED FIXED
Alias: None
Product: kst
Classification: Applications
Component: general (show other bugs)
Version: 1.x
Platform: unspecified Linux
: NOR normal
Target Milestone: ---
Assignee: kst
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-03-08 20:54 UTC by Andrew Walker
Modified: 2007-04-03 20:19 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:


Attachments
Fixes asserts in plugin (2.19 KB, patch)
2007-04-03 19:57 UTC, Adam Treat
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Andrew Walker 2007-03-08 20:54:22 UTC
Version:           HEAD (using KDE KDE 3.5.1)
OS:                Linux

PROBLEM:

Cross power spectrum causes continuous asserts in KstRWLock

STEPS TO REPRODUCE:

Start Kst
Use the data wizard to plot 1 and 2 from gyrodata.dat against INDEX
Select Data... New Plugin...
Select the Cross Power Spectrum option in the Data Plugins dialog
Select reasonable values for the defaults in the New dialog
Select Vector One as 1
Select Vector Two as 2
Hit Ok
Add the resultant vector to a curve

RESULTS:

ASSERT: "myLockStatus() == KstRWLock::WRITELOCKED" in kstprimitive.cpp (41)
ASSERT: "myLockStatus() == KstRWLock::WRITELOCKED" in kstprimitive.cpp (41)
ASSERT: "myLockStatus() == KstRWLock::WRITELOCKED" in kstrvector.cpp (440)
ASSERT: "myLockStatus() == KstRWLock::WRITELOCKED" in kstrvector.cpp (440)
ASSERT: "myLockStatus() == KstRWLock::WRITELOCKED" in kstscalar.cpp (101)
ASSERT: "myLockStatus() == KstRWLock::WRITELOCKED" in kstscalar.cpp (101)

EXPECTED RESULTS:

There should be no asserts.
Comment 1 Andrew Walker 2007-03-08 21:32:24 UTC
This may also be an issue with other plugins.

It is possible the deadlock is related to the time spent processing the plugin.
Comment 2 Adam Treat 2007-04-03 19:57:39 UTC
Created attachment 20163 [details]
Fixes asserts in plugin
Comment 3 George Staikos 2007-04-03 20:08:43 UTC
Looks good.

--
George Staikos
KDE Developer				http://www.kde.org/
Staikos Computing Services Inc.		http://www.staikos.net/
Comment 4 Adam Treat 2007-04-03 20:19:17 UTC
SVN commit 650060 by treat:

* No more asserts

BUG:142701* No more asserts

BUG:142701* No more asserts

BUG:142701* No more asserts

BUG:142701* No more asserts

BUG:142701* No more asserts

BUG:142701* No more asserts

BUG:142701* No more asserts

BUG:142701


 M  +6 -0      crosspowerspectrum.cpp  
 M  +1 -16     crossspectrumdialog_i.cpp  


--- trunk/extragear/graphics/kst/src/plugins/crossspectrum/crosspowerspectrum.cpp #650059:650060
@@ -235,6 +235,8 @@
 
 
 KstObject::UpdateType CrossPowerSpectrum::update(int updateCounter) {
+  Q_ASSERT(myLockStatus() == KstRWLock::WRITELOCKED);
+
   bool force = dirty();
   setDirty(false);
 
@@ -248,6 +250,8 @@
 
   bool depUpdated = force;
 
+  writeLockInputsAndOutputs();
+
   depUpdated = UPDATE == v1()->update(updateCounter) || depUpdated;
   depUpdated = UPDATE == v2()->update(updateCounter) || depUpdated;
 
@@ -271,6 +275,8 @@
   frequency()->setNewAndShift(frequency()->length(), frequency()->numShift());
   frequency()->update(updateCounter);
 
+  unlockInputsAndOutputs();
+
   return setLastUpdateResult(depUpdated ? UPDATE : NO_CHANGE);
 }
 
--- trunk/extragear/graphics/kst/src/plugins/crossspectrum/crossspectrumdialog_i.cpp #650059:650060
@@ -91,15 +91,13 @@
   CrossPowerSpectrumPtr cps = kst_cast<CrossPowerSpectrum>(KstDataObject::createPlugin("Cross Power Spectrum"));
   Q_ASSERT(cps); //should never happen...
 
-  cps->writeLock();
+  KstWriteLocker pl(cps);
 
   if (tagName == defaultTag) {
     tagName = KST::suggestPluginName("crosspowerspectrum");
   }
   cps->setTagName(KstObjectTag::fromString(tagName));
 
-  cps->unlock();
-
   // Save the vectors and scalars
   if (!editSingleObject(cps) || !cps->isValid()) {
     KMessageBox::sorry(this, i18n("There is an error in the values you entered."));
@@ -144,19 +142,6 @@
 
   cps->setTagName(KstObjectTag::fromString(_tagName->text()));
 
-#if 0
-  // Must unlock before clear()
-  for (KstVectorMap::Iterator i = cps->inputVectors().begin(); i != cps->inputVectors().end(); ++i) {
-    (*i)->unlock();
-  }
-  for (KstScalarMap::Iterator i = cps->inputScalars().begin(); i != cps->inputScalars().end(); ++i) {
-    (*i)->unlock();
-  }
-  for (KstStringMap::Iterator i = cps->inputStrings().begin(); i != cps->inputStrings().end(); ++i) {
-    (*i)->unlock();
-  }
-#endif
-
   cps->inputVectors().clear();
   cps->inputScalars().clear();
   cps->inputStrings().clear();