You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-dev@xerces.apache.org by "Boris Kolpackov (JIRA)" <xe...@xml.apache.org> on 2009/11/04 10:07:32 UTC
[jira] Closed: (XERCESC-1486) Memory leak in error cases
[ https://issues.apache.org/jira/browse/XERCESC-1486?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Boris Kolpackov closed XERCESC-1486.
------------------------------------
Resolution: Fixed
Fix Version/s: 3.0.1
Assuming fixed in 3.0.1. Can you please try with 3.0.1 and reopen if the issue if the problem is still present.
> Memory leak in error cases
> --------------------------
>
> Key: XERCESC-1486
> URL: https://issues.apache.org/jira/browse/XERCESC-1486
> Project: Xerces-C++
> Issue Type: Bug
> Components: SAX/SAX2
> Affects Versions: 2.6.0
> Environment: HP-UX B.11.11 U 9000/800
> aCC: HP ANSI C++ B3910B A.03.57
> Reporter: Stephan Irrgang
> Fix For: 3.0.1
>
>
> 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.
-
You can reply to this email to add a comment to the issue online.
---------------------------------------------------------------------
To unsubscribe, e-mail: c-dev-unsubscribe@xerces.apache.org
For additional commands, e-mail: c-dev-help@xerces.apache.org