Bug 102222 - Crash when creating PSDs
Summary: Crash when creating PSDs
Status: RESOLVED FIXED
Alias: None
Product: kst
Classification: Applications
Component: general (show other bugs)
Version: 1.x
Platform: Compiled Sources Linux
: NOR crash
Target Milestone: ---
Assignee: kst
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-03-23 00:50 UTC by Andrew Walker
Modified: 2005-03-23 05:14 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 Andrew Walker 2005-03-23 00:50:31 UTC
Version:           HEAD (using KDE KDE 3.3.0)
Installed from:    Compiled From Sources
OS:                Linux

PROBLEM:
Kst crashes when requesting a PSD

STEPS TO REPRODUCE:
Start Kst
Start the data wizard
Select a large data source with many columns
Select the "XY and power spectrum" option
Select the FFT length to be 2^24
Click Finish on the wizard

RESULTS:
Crash (this depends on the amount of free memory you have).
If you have too much run a memory stress testing application
before running Kst.

EXPECTED RESULTS:
No crash. No PSD is created, but a warning message is added to the debug log.

STACK TRACE:
Using host libthread_db library "/lib/tls/libthread_db.so.1".
[Thread debugging using libthread_db enabled]
[New Thread -174471488 (LWP 7739)]
[New Thread -178676816 (LWP 7740)]
[Thread debugging using libthread_db enabled]
[New Thread -174471488 (LWP 7739)]
[New Thread -178676816 (LWP 7740)]
[Thread debugging using libthread_db enabled]
[New Thread -174471488 (LWP 7739)]
[New Thread -178676816 (LWP 7740)]
[KCrash handler]
#4  KstVector::zero (this=0x9dce5d0) at kstvector.cpp:229
#5  0x081c32f7 in KstVector (this=0x9dce5d0, name=@0xfee847b0, size=8388608, 
    isScalarList=false) at kstvector.cpp:78
#6  0x08197c45 in KstPSD::commonConstructor (this=0x9dcc230, 
    in_tag=@0xfee84f80, in_V={ptr = 0x9db4fe8}, in_freq=) at qstring.h:1042
#7  0x081997c3 in KstPSD (this=0x9dcc230, in_tag=@0xfee84f80, in_V=)
    at kstsharedptr.h:48
#8  0x0817a672 in DataWizard::finished (this=0x9d9c8c0) at qcheckbox.h:85
#9  0x0817061e in DataWizard::qt_invoke (this=0x9d9c8c0, _id=71, _o=0xfee85090)
    at datawizard.moc:150
#10 0xf60bbda0 in QObject::activate_signal ()
   from /usr/lib/qt-3.3/lib/libqt-mt.so.3
#11 0xf60bc47a in QObject::activate_signal ()
   from /usr/lib/qt-3.3/lib/libqt-mt.so.3
#12 0xf63f3fc0 in QButton::clicked () from /usr/lib/qt-3.3/lib/libqt-mt.so.3
#13 0xf614b9f7 in QButton::mouseReleaseEvent ()
   from /usr/lib/qt-3.3/lib/libqt-mt.so.3
#14 0xf60f1cfa in QWidget::event () from /usr/lib/qt-3.3/lib/libqt-mt.so.3
#15 0xf605d249 in QApplication::internalNotify ()
   from /usr/lib/qt-3.3/lib/libqt-mt.so.3
#16 0xf605d489 in QApplication::notify ()
   from /usr/lib/qt-3.3/lib/libqt-mt.so.3
#17 0xf66a54c8 in KApplication::notify () from /usr/lib/libkdecore.so.4
#18 0xf5ffc3de in QETWidget::translateMouseEvent ()
   from /usr/lib/qt-3.3/lib/libqt-mt.so.3
#19 0xf5ffac78 in QApplication::x11ProcessEvent ()
   from /usr/lib/qt-3.3/lib/libqt-mt.so.3
#20 0xf600d086 in QEventLoop::processEvents ()
   from /usr/lib/qt-3.3/lib/libqt-mt.so.3
#21 0xf6072875 in QEventLoop::enterLoop ()
   from /usr/lib/qt-3.3/lib/libqt-mt.so.3
#22 0xf605c471 in QApplication::enter_loop ()
   from /usr/lib/qt-3.3/lib/libqt-mt.so.3
#23 0xf623caf0 in QDialog::exec () from /usr/lib/qt-3.3/lib/libqt-mt.so.3
#24 0x08141475 in KstApp::showDataWizard (this=0x99810a8) at kst.cpp:1620
#25 0x08146d5e in KstApp::qt_invoke (this=0x99810a8, _id=208, _o=0xfee85c00)
    at kst.moc:455
#26 0xf60bbda0 in QObject::activate_signal ()
   from /usr/lib/qt-3.3/lib/libqt-mt.so.3
#27 0xf60bc47a in QObject::activate_signal ()
   from /usr/lib/qt-3.3/lib/libqt-mt.so.3
#28 0xf695dea9 in KAction::activated () from /usr/lib/libkdeui.so.4
#29 0xf695decd in KAction::slotActivated () from /usr/lib/libkdeui.so.4
#30 0xf695df7c in KAction::qt_invoke () from /usr/lib/libkdeui.so.4
#31 0xf60bbda0 in QObject::activate_signal ()
   from /usr/lib/qt-3.3/lib/libqt-mt.so.3
#32 0xf63ecf9d in QSignal::signal () from /usr/lib/qt-3.3/lib/libqt-mt.so.3
#33 0xf60d4add in QSignal::activate () from /usr/lib/qt-3.3/lib/libqt-mt.so.3
#34 0xf61bdf56 in QPopupMenu::mouseReleaseEvent ()
   from /usr/lib/qt-3.3/lib/libqt-mt.so.3
#35 0xf60f1cfa in QWidget::event () from /usr/lib/qt-3.3/lib/libqt-mt.so.3
#36 0xf605d249 in QApplication::internalNotify ()
   from /usr/lib/qt-3.3/lib/libqt-mt.so.3
#37 0xf605d489 in QApplication::notify ()
   from /usr/lib/qt-3.3/lib/libqt-mt.so.3
#38 0xf66a54c8 in KApplication::notify () from /usr/lib/libkdecore.so.4
#39 0xf5ffc64c in QETWidget::translateMouseEvent ()
   from /usr/lib/qt-3.3/lib/libqt-mt.so.3
#40 0xf5ffac78 in QApplication::x11ProcessEvent ()
   from /usr/lib/qt-3.3/lib/libqt-mt.so.3
#41 0xf600d086 in QEventLoop::processEvents ()
   from /usr/lib/qt-3.3/lib/libqt-mt.so.3
#42 0xf6072875 in QEventLoop::enterLoop ()
   from /usr/lib/qt-3.3/lib/libqt-mt.so.3
#43 0xf60727ce in QEventLoop::exec () from /usr/lib/qt-3.3/lib/libqt-mt.so.3
#44 0xf605c44b in QApplication::exec () from /usr/lib/qt-3.3/lib/libqt-mt.so.3
#45 0x0814e13a in main (argc=1, argv=0xfee872d4) at main.cpp:740
Comment 1 George Staikos 2005-03-23 05:14:12 UTC
CVS commit by staikos: 

Add PSDs to the memory check algorithm in the data wizard and also add a
check for the malloc() in KstVector::KstVector, temporary until Kst2 when
isValid() becomes KstObject-wide.  We need this check for javascript too, even
though it's an ugly hack and gives somewhat unexpected behaviour in the case
that malloc fails
BUG: 102222


  M +11 -3     datawizard.ui.h   1.128
  M +11 -0     kstpsd.cpp   1.29
  M +7 -1      kstvector.cpp   1.102


--- kdeextragear-2/kst/kst/datawizard.ui.h  #1.127:1.128
@@ -486,9 +486,17 @@ void DataWizard::finished()
 
                 if (_kstDataRange->DoSkip->isChecked()) {
+                    if (_radioButtonPlotPSD->isChecked()) {
+                        memoryRequested += 3 * frames / _kstDataRange->Skip->value()*sizeof(double);
+                    } else {
                     memoryRequested += frames / _kstDataRange->Skip->value()*sizeof(double);
+                    }
+                } else {
+                    if (_radioButtonPlotPSD->isChecked()) {
+                        memoryRequested += 3 * frames * ds->samplesPerFrame(field)*sizeof(double);
                 } else {
                     memoryRequested += frames * ds->samplesPerFrame(field)*sizeof(double);
                 }                
             }
+            }
             ++it;
         }

--- kdeextragear-2/kst/kst/kstpsd.cpp  #1.28:1.29
@@ -30,4 +30,5 @@
 #include "dialoglauncher.h"
 #include "kstdatacollection.h"
+#include "kstdebug.h"
 #include "kstpsd.h"
 #include "kstvectordefaults.h"
@@ -156,4 +157,9 @@ void KstPSD::commonConstructor(const QSt
 
   KstVectorPtr ov = new KstVector(in_tag+"-freq", _PSDLen);
+  if (ov->length() != _PSDLen) {
+    _PSDLen = 1;
+    _Len = 1;
+    KstDebug::self()->log(i18n("Attempted to create a PSD that used all memory."), KstDebug::Error);
+  }
   KST::addVectorToList(ov);
   ov->setProvider(this);
@@ -162,4 +168,9 @@ void KstPSD::commonConstructor(const QSt
 
   ov = new KstVector(in_tag+"-sv", _PSDLen);
+  if (ov->length() != _PSDLen) {
+    _PSDLen = 1;
+    _Len = 1;
+    KstDebug::self()->log(i18n("Attempted to create a PSD that used all memory."), KstDebug::Error);
+  }
   KST::addVectorToList(ov);
   ov->setProvider(this);

--- kdeextragear-2/kst/kst/kstvector.cpp  #1.101:1.102
@@ -72,5 +72,10 @@ KstVector::KstVector(const QString& name
 
   _v = static_cast<double*>(KST::malloc(size*sizeof(double)));
+  if (!_v) { // Malloc failed
+    _v = static_cast<double*>(KST::malloc(sizeof(double)));
+    _size = 1;
+  } else {
   _size = size;
+  }
   _is_rising = false;