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

Memory leak in xerces library

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Resolution: Incomplete
    • 2.3.0
    • None
    • None
    • Operating System: Solaris
      Platform: Sun
    • 22693

    Description

      Hi,

      Am developing an application on Solaris 2.8 using the
      Xerces SAX2 parser (library
      version 2.3.0) in which I
      do validation using an external DTD. Am facing a memory
      leak in the
      app in both the following cases:

      a. XML document gets parsed successfully,
      b. XML
      document fails to parse due to DTD validation failure.

      To verify whether this leak is in the
      library code or
      my application, I instrumented the SAX2Count application
      (provided in the
      Xerces package) with purify (Version
      2003.06.00 Solaris 2) and ran the same giving it
      the
      XML document written below. I got the following purify
      report.

      -------------- Purify report for
      sample begin --------------
      MLK: 24 bytes leaked at 0xcceb8

      • This memory was allocated from:
        malloc
        [rtlib.o]
        new_eh_context [libgcc2.c]
        eh_context_specific
        [libgcc2.c]
        eh_context_initialize [libgcc2.c]
        __get_eh_info
        [libgcc2.c]
        __cp_push_exception
        [exception.cc:215]
        xercesc_2_3::XMLURL::setURL(const unsigned short*,const
        unsigned short*) [libxerces-
        c.so.23]
        xercesc_2_3::XMLURL::xercesc_2_3::XMLURL(const unsigned short*,const
        unsigned short*,xercesc_2_3::MemoryManager*) [libxerces-
        c.so.23]
        xercesc_2_3::ReaderMgr::createReader(const unsigned short*,const unsigned
        short*,bool,xercesc_2_3::XMLReader::RefFrom,xercesc_2_3::XMLReader::Types,xercesc_2_3::XMLReader::Sources,xercesc_2_3::InputSource*&,bool)
        [libxerces-c.so.23]
        xercesc_2_3::IGXMLScanner::scanDocTypeDecl() [libxerces-
        c.so.23]
        xercesc_2_3::XMLScanner::scanProlog() [libxerces-
        c.so.23]
        xercesc_2_3::IGXMLScanner::scanDocument(const
        xercesc_2_3::InputSource&) [libxerces-
        c.so.23]
        xercesc_2_3::XMLScanner::scanDocument(const unsigned short*) [libxerces-
        c.so.23]
        xercesc_2_3::XMLScanner::scanDocument(const char*) [libxerces-
        c.so.23]
        xercesc_2_3::SAX2XMLReaderImpl::parse(const char*) [libxerces-
        c.so.23]
        main [SAX2Count.o]
        _start [crt1.o]
                                  • Purify report for sample end ---------------

      The
      leak is not in the same location as where I got it
      for my app, but even my leak is caused due to an
      exception
      thrown within the Xerces DTDValidator code. Is there an
      issue in which the
      exceptions are thrown? Or is there
      some problem with purify?

      The difference between
      SAX2Count and my app is that I've
      implemented the resolveEntity(), error() and
      fatalError()
      callbacks in my cbk handler.

      -------------- Purify report for my app begin --------------
      MLK: 24 bytes
      leaked at 0x116f50

      • This memory was allocated from:
        malloc [rtlib.o]
        new_eh_context
        [libgcc2.c]
        eh_context_specific [libgcc2.c]
        eh_context_initialize
        [libgcc2.c]
        __get_eh_info [libgcc2.c]
        __cp_push_exception
        [exception.cc:215]
        xercesc_2_3::ReaderMgr::popReader() [libxerces-
        c.so.23]
        xercesc_2_3::ReaderMgr::skipPastSpaces() [libxerces-
        c.so.23]
        xercesc_2_3::DTDScanner::scanExtSubsetDecl(bool,bool) [libxerces-
        c.so.23]
        xercesc_2_3::IGXMLScanner::scanDocTypeDecl() [libxerces-
        c.so.23]
        xercesc_2_3::XMLScanner::scanProlog() [libxerces-
        c.so.23]
        xercesc_2_3::IGXMLScanner::scanDocument(const
        xercesc_2_3::InputSource&) [libxerces-
        c.so.23]
        xercesc_2_3::XMLScanner::scanDocument(const unsigned short*) [libxerces-
        c.so.23]
        xercesc_2_3::XMLScanner::scanDocument(const char*) [libxerces-
        c.so.23]
        xercesc_2_3::SAX2XMLReaderImpl::parse(const char*) [libxerces-
        c.so.23]
        Sdf_fn_parseCPL(const char*,Sdf_tg_cplStruct*,unsigned int)
        [sdfcplxerparser.cpp:1220]
        main [sdfcplutility.cpp:1443]
        _start [crt1.o]
                                  • Purify report for my app end ---------------

      Can you please investigate? Also, please let me know
      in case
      you need any further inputs? I would have liked
      to attatch the XML and the DTD files, but I don't
      see
      a way of doing that in the web interface. Please mail
      me in case you need those to
      investigate.

      Thanks for your help.
      Siddharth.

      Attachments

        1. ASF.LICENSE.NOT.GRANTED--cpl.dtd
          7 kB
          Siddharth Toshniwal
        2. ASF.LICENSE.NOT.GRANTED--cfu.xml
          0.3 kB
          Siddharth Toshniwal

        Activity

          People

            Unassigned Unassigned
            stoshniwal@hss.hns.com Siddharth Toshniwal
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: