[prev in list] [next in list] [prev in thread] [next in thread]
List: xerces-c-dev
Subject: [jira] Commented: (XERCESC-1486) Memory leak in error cases
From: "David Bertoni (JIRA)" <xerces-c-dev () xml ! apache ! org>
Date: 2005-08-30 17:07:04
Message-ID: 247523118.1125421624801.JavaMail.jira () ajax ! apache ! org
[Download RAW message or body]
[ http://issues.apache.org/jira/browse/XERCESC-1486?page=comments#action_12320601 \
]
David Bertoni commented on XERCESC-1486:
----------------------------------------
I suggest you build a version of Xerces-C with some logging the XMLException \
constructor and destructor to ensure that it is called and that the pointer is freed. \
If it is, you will know that it's a problem with the memory leak detection tools. If \
it's not, you'll know it a problem with the compiler, and you can report it to HP.
It's often difficult for the Xerces-C committers to diagnose platform-specific \
problems, because none of us has access to every possible platform.
> 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: c-dev-unsubscribe@xerces.apache.org
For additional commands, e-mail: c-dev-help@xerces.apache.org
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic