Sfoglia il codice sorgente

Merge remote-tracking branch 'origin/closedown-4.2.x'

Signed-off-by: Richard Chapman <rchapman@hpccsystems.com>
Richard Chapman 11 anni fa
parent
commit
d0ff681b59

+ 3 - 0
ecl/eclcc/eclcc.cpp

@@ -1017,6 +1017,9 @@ void EclCC::processSingleQuery(EclCompileInstance & instance,
     const char * sourcePathname = queryContents ? queryContents->querySourcePath()->str() : NULL;
     const char * defaultErrorPathname = sourcePathname ? sourcePathname : queryAttributePath;
 
+    //The following is only here to provide information about the source file being compiled when reporting leaks
+    setActiveSource(instance.inputFile->queryFilename());
+
     {
         //Minimize the scope of the parse context to reduce lifetime of cached items.
         HqlParseContext parseCtx(instance.dataServer, instance.archive);

+ 35 - 0
ecl/hql/hqlexpr.cpp

@@ -58,6 +58,7 @@
 //#define NEW_VIRTUAL_DATASETS
 #define HQL_VERSION_NUMBER 30
 //#define ALL_MODULE_ATTRS_VIRTUAL
+//#define _REPORT_EXPRESSION_LEAKS
 
 //#define TRACE_THIS
 //#define CONSISTENCY_CHECK
@@ -194,6 +195,25 @@ static unsigned numNestedExtra;
 static unsigned insideCreate;
 #endif
 
+#ifdef _REPORT_EXPRESSION_LEAKS
+static char activeSource[256];
+void setActiveSource(const char * filename)
+{
+    if (filename)
+    {
+        strncpy(activeSource, filename, sizeof(activeSource));
+        activeSource[sizeof(activeSource)-1]= 0;
+    }
+    else
+        activeSource[0] = 0;
+}
+#else
+void setActiveSource(const char * filename)
+{
+}
+#endif
+
+
 MODULE_INIT(INIT_PRIORITY_HQLINTERNAL)
 {
     transformMutex = new Mutex;
@@ -256,6 +276,20 @@ MODULE_EXIT()
 
     ClearTypeCache();
 
+#ifdef _REPORT_EXPRESSION_LEAKS
+    if (exprCache->count())
+    {
+#if 0 // Place debugging code inside here
+        JavaHashIteratorOf<IHqlExpression> iter(*exprCache, false);
+        ForEach(iter)
+        {
+            IHqlExpression & ret = iter.query();
+        }
+#endif
+        fprintf(stderr, "%s Hash table contains %d entries\n", activeSource, exprCache->count());
+    }
+#endif
+
     ::Release(sourcePaths);
     delete sourcePathCS;
     delete unadornedCS;
@@ -9409,6 +9443,7 @@ CHqlScopeParameter::CHqlScopeParameter(IIdAtom * _id, unsigned _idx, ITypeInfo *
     idx = _idx;
     typeScope = ::queryScope(type);
     infoFlags |= HEFunbound;
+    uid = (idx == UnadornedParameterIndex) ? 0 : parameterSequence.next();
     if (!hasAttribute(_virtualSeq_Atom))
         addOperand(createSequence(no_attr, makeNullType(), _virtualSeq_Atom, virtualSequence.next()));
 }

+ 3 - 0
ecl/hql/hqlexpr.hpp

@@ -1867,4 +1867,7 @@ extern HQL_API bool queryLegacyImportSemantics();
 extern HQL_API bool queryLegacyWhenSemantics();
 void exportSymbols(IPropertyTree* data, IHqlScope * scope, HqlLookupContext & ctx);
 
+//The following is only here to provide information about the source file being compiled when reporting leaks
+extern HQL_API void setActiveSource(const char * filename);
+
 #endif

+ 4 - 5
ecl/hql/hqlgram2.cpp

@@ -2321,9 +2321,10 @@ IIdAtom * HqlGram::createUnnamedFieldId()
 
 
 /* In parms: type, value: linked */
-void HqlGram::addField(const attribute &errpos, IIdAtom * name, ITypeInfo *_type, IHqlExpression *value, IHqlExpression *attrs)
+void HqlGram::addField(const attribute &errpos, IIdAtom * name, ITypeInfo *_type, IHqlExpression * _value, IHqlExpression *attrs)
 {
     Owned<ITypeInfo> fieldType = _type;
+    OwnedHqlExpr value = _value;
     Linked<ITypeInfo> expectedType = fieldType;
     if (expectedType->getTypeCode() == type_alien)
     {
@@ -2339,9 +2340,7 @@ void HqlGram::addField(const attribute &errpos, IIdAtom * name, ITypeInfo *_type
             canNotAssignTypeWarn(fieldType,valueType,errpos);
         if (expectedType->getTypeCode() != type_row)
         {
-            IHqlExpression * newValue = ensureExprType(value, expectedType);
-            value->Release();
-            value = newValue;
+            value.setown(ensureExprType(value, expectedType));
         }
     }
 
@@ -2422,7 +2421,7 @@ void HqlGram::addField(const attribute &errpos, IIdAtom * name, ITypeInfo *_type
     if ((fieldType->getSize() != UNKNOWN_LENGTH) && (fieldType->getSize() > MAX_SENSIBLE_FIELD_LENGTH))
         reportError(ERR_BAD_FIELD_SIZE, errpos, "Field %s is too large", name->str());
 
-    OwnedHqlExpr newField = createField(name, fieldType.getClear(), value, attrs);
+    OwnedHqlExpr newField = createField(name, fieldType.getClear(), value.getClear(), attrs);
     OwnedHqlExpr annotated = createLocationAnnotation(LINK(newField), errpos.pos);
     addToActiveRecord(LINK(newField));
 }

+ 1 - 1
ecl/hql/hqlutil.cpp

@@ -629,7 +629,7 @@ IHqlExpression * removeCommonSubstringRange(IHqlExpression * expr)
     if (matchesConstantValue(from, 1))
         return LINK(value);
     OwnedHqlExpr newRange = createValue(no_rangefrom, makeNullType(), LINK(from));
-    return replaceChild(expr, 1, newRange.getClear());
+    return replaceChild(expr, 1, newRange);
 }
 
 void AtmostLimit::extractAtmostArgs(IHqlExpression * atmost)

+ 1 - 1
ecl/hqlcpp/hqlcppds.cpp

@@ -669,7 +669,7 @@ IReferenceSelector * HqlCppTranslator::ensureLinkCountedRow(BuildCtx & ctx, IRef
 {
     if (!source->isRoot() || !source->queryRootRow()->isLinkCounted())
     {
-        BoundRow * row = source->getRow(ctx);
+        Owned<BoundRow> row = source->getRow(ctx);
         BoundRow * lcrRow = ensureLinkCountedRow(ctx, row);
         assertex(row != lcrRow);
         return createReferenceSelector(lcrRow, source->queryExpr());

+ 1 - 1
ecl/hqlcpp/hqlhoist.cpp

@@ -318,7 +318,7 @@ void ConditionalContextTransformer::addDefinition(ConditionalContextInfo * locat
 
 void ConditionalContextTransformer::removeDefinition(ConditionalContextInfo * location, ConditionalContextInfo * candidate)
 {
-    location->definitions.zap(*LINK(candidate->original));
+    location->definitions.zap(*candidate->original);
     candidate->moveTo = NULL;
 }
 

+ 3 - 0
ecl/hqlcpp/hqlttcpp.cpp

@@ -1974,7 +1974,10 @@ IHqlExpression * ThorHqlTransformer::createTransformed(IHqlExpression * expr)
         if (!normalized)
             normalized = normalizeTableToAggregate(transformed, true);
         if (!normalized || (normalized == transformed))
+        {
+            ::Release(normalized);
             normalized = normalizePrefetchAggregate(transformed);
+        }
         break;
     case no_dedup:
         normalized = normalizeDedup(transformed);

+ 7 - 1
ecl/regress/regress.sh

@@ -60,7 +60,7 @@ if [[ $1 = '' ]]; then
     exit -1
 fi
 if [[ $* != '' ]]; then
-    while getopts "t:c:I:e:d:f:q:l:p:x:v" opt; do
+    while getopts "t:c:I:e:d:f:q:l:p:x:vw" opt; do
         case $opt in
             t)
                 target_dir=$OPTARG
@@ -97,6 +97,12 @@ if [[ $* != '' ]]; then
                	eclcc="$valgrind $eclcc"
                	compare_dir=
                	;;
+            w)
+                valgrind="valgrind --leak-check=full --suppressions=suppressions.txt --vgdb-error=0 "
+                valgrind="$valgrind --track-origins=yes "
+                eclcc="$valgrind $eclcc"
+                compare_dir=
+                ;;
             :)
                 echo $syntax
                 exit -1