Page MenuHomePhabricator

Statistics-Plugin crashes when toggeling "use default bin size"
Closed, ResolvedPublic

Description

If you use the statistics plugin you can provoke a null pointer exception -> crash, when toggeling the "use default bin size" while it still updates the statistic. Thus it is a bit tricky (in terms of timing) to provoke in release mode, but easy in debug mode (good for you 😄 ).

The exception is provoked in QmitkImageStatisticsCalculationThread::run() (line 255 ff; see below). For what ever reason m_StatisticsImage is a null pointer and GetTimePoint is called => 💣 *BAMM*

if(statisticCalculationSuccessful)
{
  this->m_StatisticsVector.clear();
  this->m_HistogramVector.clear();

  for (unsigned int i = 0; i < m_StatisticsImage->GetTimeSteps(); i++)
  {
    this->m_StatisticsVector.push_back(calculator->GetStatistics(i));
    this->m_HistogramVector.push_back((HistogramType*)this->m_StatisticsVector[i]->GetHistogram());
  }
}

Event Timeline

kleina claimed this task.

We added a Mutex to lock access to m_StatisticsImage to make sure it is not set to nullptr while the calculation thread is still using it to calculate the statistics.