Crash in xerces while validating XML

1k views Asked by At

My application is crashing sometimes when I am trying to validate XML using Xerces-c.

Here is the stack trace :

#0  0x000000000064ead0 in xercesc_3_2::XMLMutex::lock() ()
#1  0x000000000064eb32 in xercesc_3_2::XMLMutexLock::XMLMutexLock(xercesc_3_2::XMLMutex*) ()
#2  0x00000000005c8d5d in xercesc_3_2::XMLScanner::commonInit() ()
#3  0x00000000005c6ff7 in xercesc_3_2::XMLScanner::XMLScanner(xercesc_3_2::XMLValidator*, xercesc_3_2::GrammarResolver*, xercesc_3_2::MemoryManager*) ()
#4  0x00000000006caf59 in xercesc_3_2::IGXMLScanner::IGXMLScanner(xercesc_3_2::XMLValidator*, xercesc_3_2::GrammarResolver*, xercesc_3_2::MemoryManager*) ()
#5  0x00000000006858aa in xercesc_3_2::XMLScannerResolver::getDefaultScanner(xercesc_3_2::XMLValidator*, xercesc_3_2::GrammarResolver*, xercesc_3_2::MemoryManager*) ()
#6  0x00000000005da3f8 in xercesc_3_2::AbstractDOMParser::initialize() ()
#7  0x00000000005da163 in xercesc_3_2::AbstractDOMParser::AbstractDOMParser(xercesc_3_2::XMLValidator*, xercesc_3_2::MemoryManager*, xercesc_3_2::XMLGrammarPool*) ()
#8  0x00000000005e81bc in xercesc_3_2::XercesDOMParser::XercesDOMParser(xercesc_3_2::XMLValidator*, xercesc_3_2::MemoryManager*, xercesc_3_2::XMLGrammarPool*) ()
#9  0x00000000004f0323 in KEventUtils::validateXML(std::string) (this=0xdbb030, xmlFile="/mnt/lprsResults3//2017/09/18/C01/P00C013-2017091803862.xml.1.xml") at src/KEventUtils.cpp:315
#10 0x00000000004c3861 in ACSTrigger::transcodeVideo(int) (this=0xdbe170, id=0) at src/acsTrigger.cpp:1314
#11 0x00000000004cacaa in std::_Mem_fn<void (ACSTrigger::*)(int)>::operator()<int, void>(ACSTrigger*, int&&) const (this=0xdbdb50, __object=0xdbe170)
    at /usr/local/include/c++/4.8.5/functional:601
#12 0x00000000004ca9eb in std::_Bind_simple<std::_Mem_fn<void (ACSTrigger::*)(int)> (ACSTrigger*, int)>::_M_invoke<0ul, 1ul>(std::_Index_tuple<0ul, 1ul>) (this=0xdbdb40) at /usr/local/include/c++/4.8.5/functional:1732
#13 0x00000000004ca707 in std::_Bind_simple<std::_Mem_fn<void (ACSTrigger::*)(int)> (ACSTrigger*, int)>::operator()() (this=0xdbdb40)
    at /usr/local/include/c++/4.8.5/functional:1720
#14 0x00000000004ca5d0 in std::thread::_Impl<std::_Bind_simple<std::_Mem_fn<void (ACSTrigger::*)(int)> (ACSTrigger*, int)> >::_M_run() (this=0xdbdb28) at /usr/local/include/c++/4.8.5/thread:115
#15 0x00007f4635860220 in  () at /lib64/libstdc++.so.6
#16 0x00007f4634cbddc5 in start_thread () at /lib64/libpthread.so.0
#17 0x00007f4634fc821d in clone () at /lib64/libc.so.6

validateXML() is the function which returns true or false depending on the XML is valid or not.

I checked the XML passed into frame 9 and it is a valid XML. The code for checking the XML is given below:

bool KEventUtils::validateXML(string xmlFile)
{
  try 
  {
    XMLPlatformUtils::Initialize();
  }
  catch (const XMLException& toCatch) 
  {
    char* message = XMLString::transcode(toCatch.getMessage());
    cout << "Error during initialization! :\n"
      << message << "\n";
    XMLString::release(&message);
    return false;
  }
  XercesDOMParser* parser = new XercesDOMParser();
  parser->setValidationScheme(XercesDOMParser::Val_Auto);
  parser->setValidationSchemaFullChecking( true );
  parser->setValidationConstraintFatal(true);
  parser->setDoNamespaces(true);    // optional
  parser->setDoSchema(true);    // optional
  ErrorHandler* errHandler = (ErrorHandler*) new HandlerBase();
  parser->setErrorHandler(errHandler);
  try 
  {
    cout << "Parsing XML " << endl;
    parser->parse((char *)xmlFile.c_str());
  }
  catch (const XMLException& toCatch) 
  {
    char* message = XMLString::transcode(toCatch.getMessage());
    cout << "Exception message is: \n"
      << message << "\n";
    XMLString::release(&message);
    if (parser) delete parser;
    if (errHandler) delete errHandler;
    return false;
  }
  catch (const DOMException& toCatch) 
  {
    char* message = XMLString::transcode(toCatch.msg);
    cout << "Exception message is: \n"
      << message << "\n";
    XMLString::release(&message);
    if (parser) delete parser;
    if (errHandler) delete errHandler;
    return false;
  }
  catch (...) 
  {
    cout << "Unexpected Exception \n" ; 
    if (parser) delete parser;
    if (errHandler) delete errHandler;
    return false;
  }

  if(parser) delete parser;
  if(errHandler) delete errHandler;
  return true;
}
0

There are 0 answers