Permalink
Browse files

Topic/ebsdlib memory crashing fixes (#859)

* Fix memory leaks and crashing issues in EBSDLib for Oxford readers

The last set of changes introduced memory leaks and crashes inside of the various
CTF readers. This was caused by too much optimization and creating too much
consistency to make the CTFReader look like the ANGReader even though the two
readers are implemented in vastly different ways.

+ Removed test files that are no longer relevant
+ Removed other debugging statements from the H5EspritReader
+ Applied clang-tidy suggestions where possible to all of EBSDLib
+ Fix warnings about classes with virtual methods but non-virtual destructor

Signed-off-by: Michael Jackson <mike.jackson@bluequartz.net>
  • Loading branch information...
imikejackson committed Jan 9, 2019
1 parent a541fad commit 1aa3edbc0dce01a59ed2ad215af26a11818605ee
Showing with 628 additions and 1,037 deletions.
  1. +2 −3 Source/EbsdLib/AbstractEbsdFields.h
  2. +2 −3 Source/EbsdLib/EbsdHeaderEntry.h
  3. +1 −1 Source/EbsdLib/EbsdImporter.h
  4. +20 −18 Source/EbsdLib/EbsdMacros.h
  5. +0 −6 Source/EbsdLib/EbsdReader.cpp
  6. +3 −2 Source/EbsdLib/EbsdReader.h
  7. +50 −45 Source/EbsdLib/EbsdSetGetMacros.h
  8. +8 −42 Source/EbsdLib/EbsdTransform.cpp
  9. +18 −47 Source/EbsdLib/H5EbsdVolumeInfo.cpp
  10. +19 −23 Source/EbsdLib/H5EbsdVolumeInfo.h
  11. +3 −3 Source/EbsdLib/HKL/CtfConstants.h
  12. +64 −22 Source/EbsdLib/HKL/CtfHeaderEntry.h
  13. +3 −10 Source/EbsdLib/HKL/CtfPhase.cpp
  14. +1 −2 Source/EbsdLib/HKL/CtfPhase.h
  15. +24 −29 Source/EbsdLib/HKL/CtfReader.cpp
  16. +23 −61 Source/EbsdLib/HKL/CtfReader.h
  17. +2 −2 Source/EbsdLib/HKL/DataParser.hpp
  18. +73 −80 Source/EbsdLib/HKL/H5CtfImporter.cpp
  19. +9 −9 Source/EbsdLib/HKL/H5CtfImporter.h
  20. +105 −11 Source/EbsdLib/HKL/H5CtfReader.cpp
  21. +20 −2 Source/EbsdLib/HKL/H5CtfReader.h
  22. +10 −25 Source/EbsdLib/HKL/H5CtfVolumeReader.cpp
  23. +6 −8 Source/EbsdLib/HKL/H5CtfVolumeReader.h
  24. +0 −5 Source/EbsdLib/TSL/AngConstants.h
  25. +28 −24 Source/EbsdLib/TSL/AngHeaderEntry.h
  26. +7 −21 Source/EbsdLib/TSL/AngPhase.cpp
  27. +1 −4 Source/EbsdLib/TSL/AngPhase.h
  28. +15 −16 Source/EbsdLib/TSL/H5AngImporter.cpp
  29. +5 −5 Source/EbsdLib/TSL/H5AngImporter.h
  30. +5 −10 Source/EbsdLib/TSL/H5AngReader.cpp
  31. +5 −4 Source/EbsdLib/TSL/H5AngReader.h
  32. +9 −8 Source/EbsdLib/TSL/H5AngVolumeReader.cpp
  33. +6 −6 Source/EbsdLib/TSL/H5AngVolumeReader.h
  34. +0 −7 Source/EbsdLib/TSL/H5OIMReader.cpp
  35. +1 −2 Source/EbsdLib/TSL/H5OIMReader.h
  36. +0 −124 Source/EbsdLib/Test/AngDirectoryPatternTest.cpp
  37. +8 −6 Source/EbsdLib/Test/AngImportTest.cpp
  38. +8 −9 Source/EbsdLib/Test/CtfReaderTest.cpp
  39. +0 −233 Source/EbsdLib/Test/EbsdImportTest.cpp
  40. +0 −23 Source/EbsdLib/Test/EbsdLibTest.cpp
  41. +8 −6 Source/EbsdLib/Test/EdaxOIMReaderTest.cpp
  42. +5 −1 Source/EbsdLib/Test/H5EspritReaderTest.cpp
  43. +39 −51 Source/{EbsdLib → OrientationLib}/Test/AngleFileLoaderTest.cpp
  44. +2 −2 Source/Plugins/OrientationAnalysis/Gui/FilterParameterWidgets/ReadH5EbsdWidget.cpp
  45. +0 −6 Source/Plugins/OrientationAnalysis/OrientationAnalysisFilters/ImportH5EspritData.cpp
  46. +6 −5 Source/Plugins/OrientationAnalysis/OrientationAnalysisFilters/ReadCtfData.cpp
  47. +4 −5 Source/Plugins/OrientationAnalysis/OrientationAnalysisFilters/ReadH5Ebsd.cpp
@@ -44,9 +44,8 @@
#include "EbsdLib/EbsdLib.h"
#include "EbsdLib/EbsdConstants.h"


/*
*
/**
* @brief The AbstractEbsdFields class
*/
class EbsdLib_EXPORT AbstractEbsdFields
{
@@ -80,7 +80,7 @@
EBSD_SHARED_POINTERS(EbsdHeaderEntry)
EBSD_TYPE_MACRO(EbsdHeaderEntry)

virtual ~EbsdHeaderEntry() {}
virtual ~EbsdHeaderEntry() = default;

/**
* @brief Returns the key of the header entry
@@ -106,8 +106,7 @@
virtual void print(std::ostream& out) = 0;

protected:
EbsdHeaderEntry() {}

EbsdHeaderEntry() = default;

public:
EbsdHeaderEntry(const EbsdHeaderEntry&) = delete; // Copy Constructor Not Implemented
@@ -58,7 +58,7 @@ class EbsdLib_EXPORT EbsdImporter
EBSD_SHARED_POINTERS(EbsdImporter)
EBSD_TYPE_MACRO(EbsdImporter)

virtual ~EbsdImporter() {}
virtual ~EbsdImporter() = default;

/**
* @brief Sets an Error Message
@@ -43,9 +43,9 @@
* @brief These macros are used to read header values from an HDF5 file, NOT From a .ang or .ctf file
*/

#define READ_EBSD_HEADER_DATA(cname, class, m_msgType, getName, key, gid) \
#define READ_EBSD_HEADER_DATA(cname, class, Type, getName, key, gid) \
{ \
m_msgType t = static_cast<m_msgType>(0); \
auto t = static_cast<Type>(0); \
err = QH5Lite::readScalarDataset(gid, key, t); \
if(err < 0) \
{ \
@@ -61,7 +61,7 @@
c->setValue(t); \
}

#define READ_EBSD_HEADER_STRING_DATA(cname, class, m_msgType, getName, key, gid) \
#define READ_EBSD_HEADER_STRING_DATA(cname, class, Type, getName, key, gid) \
{ \
QString t; \
err = QH5Lite::readStringDataset(gid, key, t); \
@@ -97,9 +97,9 @@
phase->set##key(t); \
}

#define READ_PHASE_HEADER_DATA(cname, pid, m_msgType, fqKey, key, phase) \
#define READ_PHASE_HEADER_DATA(cname, pid, Type, fqKey, key, phase) \
{ \
m_msgType t; \
Type t; \
err = QH5Lite::readScalarDataset(pid, fqKey, t); \
if(err < 0) \
{ \
@@ -115,9 +115,9 @@
phase->set##key(t); \
}

#define READ_PHASE_HEADER_DATA_CAST(cname, pid, cast, m_msgType, fqKey, key, phase) \
#define READ_PHASE_HEADER_DATA_CAST(cname, pid, cast, Type, fqKey, key, phase) \
{ \
m_msgType t; \
Type t; \
err = QH5Lite::readScalarDataset(pid, fqKey, t); \
if(err < 0) \
{ \
@@ -133,9 +133,9 @@
phase->set##key(static_cast<cast>(t)); \
}

#define READ_PHASE_HEADER_ARRAY(cname, pid, m_msgType, fqKey, key, phase) \
#define READ_PHASE_HEADER_ARRAY(cname, pid, Type, fqKey, key, phase) \
{ \
std::vector<m_msgType> t; \
std::vector<Type> t; \
err = QH5Lite::readVectorDataset(pid, fqKey, t); \
if(err < 0) \
{ \
@@ -148,17 +148,19 @@
H5Gclose(gid); \
return -1; \
} \
phase->set##key(QVector<m_msgType>::fromStdVector(t)); \
phase->set##key(QVector<Type>::fromStdVector(t)); \
}

#define SHUFFLE_ARRAY(name, var, m_msgType)\
{ m_msgType* f = allocateArray<m_msgType>(totalDataRows);\
for (size_t i = 0; i < totalDataRows; ++i)\
{\
size_t nIdx = shuffleTable[i];\
f[nIdx] = var[i];\
}\
set##name##Pointer(f); }
#define SHUFFLE_ARRAY(name, var, Type) \
{ \
Type* f = allocateArray<Type>(totalDataRows); \
for(size_t i = 0; i < totalDataRows; ++i) \
{ \
size_t nIdx = shuffleTable[i]; \
f[nIdx] = var[i]; \
} \
set##name##Pointer(f); \
}

#define ANG_READER_ALLOCATE_AND_READ(name, h5name, type) \
free##name##Pointer(); /* Always free the current data before reading new data */ \
@@ -52,8 +52,6 @@ EbsdReader::EbsdReader() :
m_HeaderIsComplete(false),
m_NumberOfElements(0)
{
m_EulerTransformationAxis.resize(3);
m_SampleTransformationAxis.resize(3);
}

// -----------------------------------------------------------------------------
@@ -68,7 +66,3 @@ void EbsdReader::appendOriginalHeader(const QString& more)
{
m_OriginalHeader.append(more);
}

// -----------------------------------------------------------------------------
//
// -----------------------------------------------------------------------------
@@ -70,13 +70,14 @@ class EbsdLib_EXPORT EbsdReader

EBSD_INSTANCE_STRING_PROPERTY(ErrorMessage)

using TransformationType = std::array<float, 3>;

/** @brief Allow the user to set the origin of the scan */
EBSD_INSTANCE_PROPERTY(uint32_t, UserZDir)
EBSD_INSTANCE_PROPERTY(float, SampleTransformationAngle)
EBSD_INSTANCE_PROPERTY(QVector<float>, SampleTransformationAxis)
EBSD_INSTANCE_PROPERTY(TransformationType, SampleTransformationAxis)
EBSD_INSTANCE_PROPERTY(float, EulerTransformationAngle)
EBSD_INSTANCE_PROPERTY(QVector<float>, EulerTransformationAxis)
EBSD_INSTANCE_PROPERTY(TransformationType, EulerTransformationAxis)

/** @brief Sets the file name of the ebsd file to be read */
EBSD_INSTANCE_STRING_PROPERTY(FileName)
Oops, something went wrong.

0 comments on commit 1aa3edb

Please sign in to comment.