[ 
http://issues.apache.org/jira/browse/XERCESC-1486?page=comments#action_12320586 
] 

Stephan Irrgang commented on XERCESC-1486:
------------------------------------------

Bad luck that this error only seems to exist on HP-UX. I forwarded this issue 
to HP; and guess what they answered: "This sounds like a bug caused by the way 
Xerxes accesses HP".

I strongly believe (and many times verified) that there is no general HP-UX 
problem in destroying exception objects. There must be some reason why this 
memory leak error appears only when using Xerces-C. Question is now, who is 
responsible for fixing this issue? As a user of both HP-UX and Xerces-C I'd 
assume that you guys should have a closer look...

> Memory leak in error cases
> --------------------------
>
>          Key: XERCESC-1486
>          URL: http://issues.apache.org/jira/browse/XERCESC-1486
>      Project: Xerces-C++
>         Type: Bug
>   Components: SAX/SAX2
>     Versions: 2.6.0
>  Environment: HP-UX B.11.11 U 9000/800
> aCC: HP ANSI C++ B3910B A.03.57
>     Reporter: Stephan Irrgang

>
> Hi,
> I found a memory leak using the SAX Parser  in error cases like file not 
> found or unexcepted end of file. I first detected it with Xerces C++ release 
> 2.3, and then verified that  it's still in contained in the latest release 
> (2.6). Here's the source code I used to test this issue; in this example the 
> XML file to parse is not existing.
> #include <xercesc/sax/HandlerBase.hpp>
> #include <xercesc/sax/AttributeList.hpp>
> #include <xercesc/parsers/SAXParser.hpp>
> #include <iostream.h>
> using namespace XERCES_CPP_NAMESPACE;
> class myCallbackHandler_c : public HandlerBase
> {
> public:
>   void fatalError (const SAXParseException& exception)
>   {
>     char chBuffer[256];
>     XMLString::transcode(exception.getMessage(), chBuffer, 255); 
>     throw chBuffer;
>   }
> };
> int main()
> {
>   int returnValue = 0;
>   XMLPlatformUtils::Initialize();
>   SAXParser *saxParserPtr = new SAXParser;
>   myCallbackHandler_c *callbackHandlerPtr = new myCallbackHandler_c;
>   saxParserPtr->setErrorHandler(callbackHandlerPtr);
>   
>   try
>     {
>       saxParserPtr->parse("FileNotFound.xml");
>     }
>   catch (const char* s)
>     {
>       cerr << s << endl;
>       returnValue = 1;
>     }
>   catch (...)
>     {
>       cerr << "Unknown exception!" << endl;
>       returnValue = 1;
>     }
>   
>   delete callbackHandlerPtr;
>   delete saxParserPtr;
>   XMLPlatformUtils::Terminate();
>   cout << "Returning: " << returnValue << endl;
>   return returnValue;
> }
> When running it with Rational Purify it shows following memory leaks (BTW, 
> the same leaks are shown when using HP WDB's memory check functionality).
>          MLK: 186 bytes leaked at 0x400bbd08
>          This memory was allocated from:
>                malloc         [rtlib.o]
>                __nW__fUl      [libCsup.2]
>                operator new(unsigned long) [rtlib.o]
>                xercesc_2_6::MemoryManagerImpl::allocate(unsigned long) 
> [libxerces-c.sl.26.0]
>                xercesc_2_6::XMLException::XMLException(const 
> xercesc_2_6::XMLException &)%2 [libxerces-c.sl.26.0]
>                xercesc_2_6::IGXMLScanner::scanReset(const 
> xercesc_2_6::InputSource &) [libxerces-c.sl.26.0]
>                xercesc_2_6::IGXMLScanner::scanDocument(const 
> xercesc_2_6::InputSource &) [libxerces-c.sl.26.0]
>                xercesc_2_6::XMLScanner::scanDocument(const unsigned short *) 
> [libxerces-c.sl.26.0]
>                xercesc_2_6::XMLScanner::scanDocument(const char *) 
> [libxerces-c.sl.26.0]
>                xercesc_2_6::SAXParser::parse(const char *) 
> [libxerces-c.sl.26.0]
>                main           [xerces_mlk.cc:29]
>                _start         [libc.2]
>                $START$        [crt0.o]
>                $START$        [crt0.o]
>          MLK: 18 bytes leaked at 0x400a7b18
>          This memory was allocated from:
>                malloc         [rtlib.o]
>                __nW__fUl      [libCsup.2]
>                operator new(unsigned long) [rtlib.o]
>                xercesc_2_6::MemoryManagerImpl::allocate(unsigned long) 
> [libxerces-c.sl.26.0]
>                static xercesc_2_6::XMLString::replicate(const char 
> *,xercesc_2_6::MemoryManager *) [libxerces-c.sl.26.0]
>                xercesc_2_6::XMLException::XMLException(const 
> xercesc_2_6::XMLException &)%2 [libxerces-c.sl.26.0]
>                xercesc_2_6::IGXMLScanner::scanReset(const 
> xercesc_2_6::InputSource &) [libxerces-c.sl.26.0]
>                xercesc_2_6::IGXMLScanner::scanDocument(const 
> xercesc_2_6::InputSource &) [libxerces-c.sl.26.0]
>                xercesc_2_6::XMLScanner::scanDocument(const unsigned short *) 
> [libxerces-c.sl.26.0]
>                xercesc_2_6::XMLScanner::scanDocument(const char *) 
> [libxerces-c.sl.26.0]
>                xercesc_2_6::SAXParser::parse(const char *) 
> [libxerces-c.sl.26.0]
>                main           [xerces_mlk.cc:29]
>                _start         [libc.2]
>                $START$        [crt0.o]
>                $START$        [crt0.o]
> To me it seems the XMLException object is not released in case an exception 
> is thrown in an error handler's fatalError method.  Any ideas? Thanks in 
> advance!
> Regards,
> Stephan

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to