Bläddra i källkod

HPCC-19695 valgrind error running aggds1.ecl

Could potentially have caused heap corruption when using dynamically-created
type info and ifblocks together.

Signed-off-by: Richard Chapman <rchapman@hpccsystems.com>
Richard Chapman 7 år sedan
förälder
incheckning
9a25471735
3 ändrade filer med 10 tillägg och 2 borttagningar
  1. 1 1
      common/fileview2/fvidxsource.ipp
  2. 1 1
      ecl/hql/hqlstack.hpp
  3. 8 0
      rtl/eclrtl/eclhelper_dyn.cpp

+ 1 - 1
common/fileview2/fvidxsource.ipp

@@ -78,7 +78,7 @@ protected:
     IArrayOf<IStringSet> values;
     Owned<DataSourceMetaData> diskMeta;
     HqlExprAttr diskRecord;
-    Owned<IRtlFieldTypeDeserializer> deserializer;
+    Owned<IRtlFieldTypeDeserializer> deserializer;  // Must be destroyed after diskRecordMeta
     Owned<IOutputMetaData> diskRecordMeta;
     Owned<IDistributedFile> df;
     Linked<FVDataSource> original;

+ 1 - 1
ecl/hql/hqlstack.hpp

@@ -90,7 +90,7 @@ private:
     char*      toFree[MAXARGS] = {};
     int        numToFree;
     bool       hasMeta;
-    Owned<IRtlFieldTypeDeserializer> deserializer;
+    Owned<IRtlFieldTypeDeserializer> deserializer;  // Must be destroyed after metas
     IArrayOf<IOutputMetaData> metas;
 #ifdef MAXFPREGS
  #ifdef FPREG_FIXEDSIZE

+ 8 - 0
rtl/eclrtl/eclhelper_dyn.cpp

@@ -43,6 +43,7 @@ public:
     CDeserializedOutputMetaData(MemoryBuffer &binInfo, bool isGrouped, IThorIndexCallback *callback);
     CDeserializedOutputMetaData(IPropertyTree &jsonInfo, bool isGrouped, IThorIndexCallback *callback);
     CDeserializedOutputMetaData(const char *json, bool isGrouped, IThorIndexCallback *callback);
+    ~CDeserializedOutputMetaData();
 
     virtual const RtlTypeInfo * queryTypeInfo() const override { return typeInfo; }
     virtual unsigned getMetaFlags() override { return flags; }
@@ -77,6 +78,13 @@ CDeserializedOutputMetaData::CDeserializedOutputMetaData(const char *json, bool
         flags |= MDFgrouped;
 }
 
+CDeserializedOutputMetaData::~CDeserializedOutputMetaData()
+{
+    // The record accessors need to be released before the deserializer is released
+    delete recordAccessor[0]; delete recordAccessor[1];
+    recordAccessor[0] = recordAccessor[1] = nullptr;
+}
+
 extern ECLRTL_API IOutputMetaData *createTypeInfoOutputMetaData(MemoryBuffer &binInfo, bool isGrouped, IThorIndexCallback *callback)
 {
     return new CDeserializedOutputMetaData(binInfo, isGrouped, callback);