Uploaded image for project: 'ROOT'
  1. ROOT
  2. ROOT-10089

Memory leak in TFormula::HandleParamRanges

    Details

    • Type: Bug
    • Status: Closed (View Workflow)
    • Priority: High
    • Resolution: Fixed
    • Affects Version/s: 6.12/06
    • Fix Version/s: 6.18/00
    • Component/s: C++ modules
    • Labels:
      None
    • Environment:

      This issue was first found by running valgrind on the ProtoDUNE reconstruction software on a SL7 machine. The real problem was pointed out by Paul Russo (FNAL).

      Description

      1173 void TFormula::HandleParamRanges(TString &formula)
      1174 {
      1175 TRegexp rangePattern("\\[[0-9]\\.\\.[0-9]
      ]");
      1176 Ssiz_t *len = new Ssiz_t();
      1177 int matchIdx = 0;
      1178 while ((matchIdx = rangePattern.Index(formula, len, matchIdx)) != -1)

      { 1179 int startIdx = matchIdx + 1; 1180 int endIdx = formula.Index("..", startIdx) + 2; // +2 for ".." 1181 int startCnt = TString(formula(startIdx, formula.Length())).Atoi(); 1182 int endCnt = TString(formula(endIdx, formula.Length())).Atoi(); 1183 1184 if (endCnt <= startCnt) 1185 Error("HandleParamRanges", "End parameter (%d) <= start parameter (%d) in parameter range", endCnt, startCnt); 1186 1187 TString newString = "["; 1188 for (int cnt = startCnt; cnt < endCnt; cnt++) 1189 newString += TString::Format("%d],[", cnt); 1190 newString += TString::Format("%d]", endCnt); 1191 1192 // std::cout << "newString generated by HandleParamRanges is " << newString << std::endl; 1193 formula.Replace(matchIdx, formula.Index("]", matchIdx) + 1 - matchIdx, newString); 1194 1195 matchIdx += newString.Length(); 1196 }

      1197
      1198 // std::cout << "final formula is now " << formula << std::endl;
      1199 }

      The memory allocated with "new Ssiz_t()" and assigned to the pointer variable "len" on line 1176 is never released. Paul also verified that this bug still exists in the most recently released version of ROOT.

        Attachments

          Activity

            People

            • Assignee:
              dpiparo Danilo Piparo
              Reporter:
              tingjun Tingjun Yang
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: