Uploaded image for project: 'Xerces-C++'
  1. Xerces-C++
  2. XERCESC-196

Memory leaks from DTDValidator

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Resolution: Fixed
    • 1.5.1
    • None
    • None
    • Operating System: Windows NT/2K
      Platform: PC
    • 3422

    Description

      Running the debug build of SAXPrint.exe on Windows NT 4.0 with the command line
      'saxprint -v=always personal.xml' appears to expose a memory leak in the DTD
      validation layer. This was detected using Purify 6.0:

      [I] Searching for all memory leaks...
      [W] MLK: Memory leak of 18 bytes from 1 block allocated in QName::setPrefix(WORD
      const*)
      [W] MLK: Memory leak of 18 bytes from 1 block allocated in
      QName::setLocalPart(WORD const*)
      [W] MLK: Memory leak of 24 bytes from 1 block allocated in
      DFAContentModel::buildSyntaxTree(ContentSpecNode * const)
      [W] MLK: Memory leak of 24 bytes from 1 block allocated in
      DFAContentModel::buildSyntaxTree(ContentSpecNode * const)
      [W] MLK: Memory leak of 24 bytes from 1 block allocated in
      DFAContentModel::buildSyntaxTree(ContentSpecNode * const)
      [W] MLK: Memory leak of 28 bytes from 1 block allocated in
      DFAContentModel::buildSyntaxTree(ContentSpecNode * const)
      [W] MLK: Memory leak of 28 bytes from 1 block allocated in
      DFAContentModel::buildSyntaxTree(ContentSpecNode * const)
      [W] MLK: Memory leak of 28 bytes from 1 block allocated in
      DFAContentModel::buildSyntaxTree(ContentSpecNode * const)
      [W] MLK: Memory leak of 28 bytes from 1 block allocated in
      DFAContentModel::buildDFA(ContentSpecNode * const)
      [W] MLK: Memory leak of 20 bytes from 1 block allocated in
      CMNode::getFirstPos(void)const
      [W] MLK: Memory leak of 20 bytes from 1 block allocated in
      CMNode::getLastPos(void)const
      [W] MLK: Memory leak of 20 bytes from 1 block allocated in
      CMNode::getFirstPos(void)const
      [W] MLK: Memory leak of 20 bytes from 1 block allocated in
      CMNode::getLastPos(void)const
      [W] MLK: Memory leak of 20 bytes from 1 block allocated in
      CMNode::getFirstPos(void)const
      [W] MLK: Memory leak of 20 bytes from 1 block allocated in
      CMNode::getFirstPos(void)const
      [W] MLK: Memory leak of 20 bytes from 1 block allocated in
      CMNode::getFirstPos(void)const
      [W] MLK: Memory leak of 20 bytes from 1 block allocated in
      CMNode::getLastPos(void)const
      [W] MLK: Memory leak of 20 bytes from 1 block allocated in
      CMNode::getLastPos(void)const
      [W] MLK: Memory leak of 20 bytes from 1 block allocated in
      CMNode::getLastPos(void)const
      [W] MLK: Memory leak of 20 bytes from 1 block allocated in
      CMNode::getLastPos(void)const
      [W] MLK: Memory leak of 20 bytes from 1 block allocated in
      CMNode::getFirstPos(void)const
      [W] MLK: Memory leak of 20 bytes from 1 block allocated in
      CMNode::getFirstPos(void)const
      [W] MLK: Memory leak of 28 bytes from 1 block allocated in
      DFAContentModel::buildDFA(ContentSpecNode * const)

      These are likely to be related. Focusing on the last one, the call trace is

      new(UINT) [crtdbg.h:552]
      DFAContentModel::buildDFA(ContentSpecNode * const) [DFAContentModel.cpp:460]
      DFAContentModel::DFAContentModel(bool,XMLElementDecl * const)
      [DFAContentModel.cpp:171]
      DTDElementDecl::createChildModel(void) [DTDElementDecl.cpp:406]
      DTDElementDecl::makeContentModel(void) [DTDElementDecl.cpp:317]
      XMLElementDecl::getContentModel(void) [XMLElementDecl.hpp:639]
      DTDValidator::checkContent(XMLElementDecl * const,QName * * const,UINT)
      [DTDValidator.cpp:125]
      XMLScanner::scanEndTag(bool&) [XMLScanner.cpp:1673]
      XMLScanner::scanContent(bool) [XMLScanner.cpp:1502]
      XMLScanner::scanDocument(InputSource const&,bool) [XMLScanner.cpp:374]
      XMLScanner::scanDocument(WORD const* const,bool) [XMLScanner.cpp:320]
      XMLScanner::scanDocument(char const* const,bool) [XMLScanner.cpp:329]
      SAXParser::parse(char const* const,bool) [SAXParser.cpp:417]
      main [saxprint.cpp:309]
      mainCRTStartup [crtexe.c:338]

      and the relevent lines are

      DFAContentModel::buildDFA(ContentSpecNode * const) [DFAContentModel.cpp:460]
      // DFA state position and count the number of such leafs, which is left
      // in the fLeafCount member.
      //
      => QName* qname = new QName(XMLUni::fgZeroLenString,
      XMLUni::fgZeroLenString, XMLContentModel::gEOCFakeId);
      CMLeaf* nodeEOC = new CMLeaf(qname);
      CMNode* nodeOrgContent = buildSyntaxTree(curNode);
      fHeadNode = new CMBinaryOp

      suggesting that the DFAContentModel is not freeing all the objects it creates.

      /////////////////////////////
      In file 'src/validators/common/DFAContentModel.cpp'
      at function 'void DFAContentModel::buildDFA(ContentSpecNode* const curNode)'
      at line 460:

      QName* qname = new QName(XMLUni::fgZeroLenString, XMLUni::fgZeroLenString,
      XMLContentModel::gEOCFakeId);
      CMLeaf* nodeEOC = new CMLeaf(qname);
      delete qname; // The addition of this line remove the QName leaks.

      The remaining problems appear related to a failure to delete the memory
      associated with:

      fHeadNode = new CMBinaryOp
      (
      ContentSpecNode::Sequence
      , nodeOrgContent
      , nodeEOC
      );

      Curiously, there is an explicit comment about this

      // the CMBinary will be released by fLeafList[]
      //delete fHeadNode;

      which suggests that someone missed a case.

      Attachments

        Activity

          People

            Unassigned Unassigned
            jerry.carter@speechworks.com Jerry Carter
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: