Thanks.

Actually you are seeing all of the code, I actually removed the code where
it says "code removed" and I still get an issue.

Is there any object which I'm not deleting or releasing, but should be?

-Rob


On 4/3/07, Alberto Massari <[EMAIL PROTECTED]> wrote:

Hi Westy,
if you get an error when main() exits, it could be that you have some
static object which destructors get called after the
XMLPlatformUtils::Terminate() call has been performed. If the crash
disappears after you comment the call to Terminate, you will have to
discover where they have been declared (maybe in the comment "// -
code removed for brevity"?) and clean them up before Terminate.

Alberto

At 16.16 03/04/2007 -0400, Westy wrote:
>Hi,
>
>I'm using Xerces 2.7.0, with Visual Studio 2005.
>
>I am experiencing what appears to be a heap corruption issue with the
>DOMWriter in the code below, the error doesn't occur until main() is
>exitting.
>
>I read where others had similar issues, but their problems seemed to go
away
>when then added a call to release() of the DOMWriter.  I have the call to
>release and still have the same issue.
>
>Does anyone see anything else I'm doing wrong?
>
>Incidentally, I had the same issue with using the latest code from Xerces

>3.0.0 and the DOMSerializer, so it might be something I'm not doing in
terms
>of memory for the std::string ..
>
>Thanks,
>
>-Westy
>
>
>ERROR:
>
>In dbgheap.c:
>Windows has triggered a breakpoint in TestDomWriterD.exe.
>This may be due to a corruption of the heap, and indicates a bug in
>TestDomWriterD.exe or any of the DLLs it has loaded.
>The output window may have more diagnostic information
>
>CODE:
>
>int
>main(int argC, char* argV[])
>{
>  std::string outXML;
>  std::string aggregationXml = fileToString("./data/stips.xml" );
>  AggregationEngine::parseTest(aggregationXml, outXML);
>}
>
>int AggregationEngine::parseTest(std::string &aggregationXML, std::string
>&outXML)
>{
>  outXML = domToString(aggregationXML);
>}
>
>std::string domToString(std::string &xmlSrc)
>{
>  XercesDOMParser *parser;
>  std::string sXML;
>  DOMNode *doc;
>
>  try {
>    XMLPlatformUtils::Initialize();
>  } catch( const XMLException &toCatch) {
>    XERCES_STD_QUALIFIER cerr << StrX( toCatch.getMessage()) <<
>XERCES_STD_QUALIFIER endl;
>  }
>  // Parse DOM
>  parser = new XercesDOMParser;
>  MemBufInputSource* memBufIS = new
>MemBufInputSource((constXMLByte*)xmlSrc.c_str(), strlen(
>xmlSrc.c_str()+1)*sizeof(char ), "xmlSrc", false );
>  parser->parse(*memBufIS);
>  delete memBufIS;
>  doc = parser->getDocument();
>
>  // Add Attributes
>  // - code removed for brevity
>
>  // Write DOM
>  try
>  {
>    XMLCh *pCore = XMLString::transcode("Core");
>    DOMImplementation* impl =
>DOMImplementationRegistry::getDOMImplementation(pCore);
>    DOMWriter *theWriter = impl->createDOMWriter();
>    XMLCh* xXml = theWriter->writeToString(*doc);
>    char *pChar = XMLString::transcode(xXml);
>    sXML = pChar;
>    XMLString::release(&pChar);
>    XMLString::release(&xXml);
>    XMLString::release(&pCore);
>    theWriter->release();
>  } catch (const XMLException& toCatch) {
>    XERCES_STD_QUALIFIER cerr << StrX( toCatch.getMessage ()) <<
>XERCES_STD_QUALIFIER endl;
>  }
>  delete parser;
>  XMLPlatformUtils::Terminate();
>  return sXML;
>}


Reply via email to