Persistent leaks in the libxml2-based NCML parser.

Description

Calling xmlFreeParserCtxt(_context); works for the DMR and DMR++ parsers, but not for the NcML parser. In fact, we might be getting lucky with the first two. This post suggests that making a parser context might not be the best overall plan.

Thanks for reporting this problem.

In fact the good solution is probably to use xmlSAXUserParseFile and
xmlSAXUserParseMemory to create the contexts, and not
xmlCreateMemoryParserCtxt and xmlCreateFileParserCtxt which are to be used
only for DOM.

So a bit more research is needed. If the above is true, fix the leak in
void SaxParserWrapper::setupParser(const string& filename) that comes fromxmlFreeParserCtxt(_context);

 

Here’s info about the leak:

{code}

256 bytes in 1 blocks are definitely lost in loss record 507 of 651
==5734== at 0x4C29BC3: malloc (vg_replace_malloc.c:299)
==5734== by 0x66A096C: xmlInitParserCtxt (in /usr/lib64/libxml2.so.2.9.1)
==5734== by 0x66A0DAB: xmlNewParserCtxt (in /usr/lib64/libxml2.so.2.9.1)
==5734== by 0x66B47BD: xmlCreateURLParserCtxt (in /usr/lib64/libxml2.so.2.9.1)
==5734== by 0xE6775A5: ncml_module::SaxParserWrapper::setupParser(std::string const&) (SaxParserWrapper.cc:480)
==5734== by 0xE676D5D: ncml_module::SaxParserWrapper::parse(std::string const&) (SaxParserWrapper.cc:328)
==5734== by 0xE62E68C: ncml_module::NCMLParser::parseInto(std::string const&, agg_util::DDSLoader::ResponseType, BESDapResponse*) (NCMLParser.cc:185)
==5734== by 0xE646E92: ncml_module::NCMLRequestHandler::ncml_build_data(BESDataHandlerInterface&) (NCMLRequestHandler.cc:297)
==5734== by 0x4F16B71: BESRequestHandlerList::execute_current(BESDataHandlerInterface&) (BESRequestHandlerList.cc:273)
==5734== by 0x4F16691: BESRequestHandlerList::execute_each(BESDataHandlerInterface&) (BESRequestHandlerList.cc:167)
==5734== by 0xC30B1F3: BESDataResponseHandler::execute(BESDataHandlerInterface&) (BESDataResponseHandler.cc:148)
==5734== by 0x61FAB49: BESXMLInterface::execute_data_request_plan() (BESXMLInterface.cc:285)

{code}

Environment

None

Assignee

Sam Lloyd

Reporter

James Gallagher

Labels

Fix versions

Story Points

1

Epic Link

Priority

Medium
Configure