> -----Original Message-----
> From: Alberto Massari [mailto:[EMAIL PROTECTED] 
> Sent: Friday, January 11, 2008 3:20 AM
> To: Kong Posh Bhat
> Cc: [email protected]
> Subject: Re: Transferring nodes from one DOM tree to another -----
possible?
>
> In this case I need to have a look at the full source....
>
> Alberto
>
> P.S. Please keep [email protected] in the CC list

Hi,

I have been able to reproduce the problem with a dummy class (that I
have named CreateCoreDump).  The listing for the class is provided
below.

In this class I am dynamically allocating an instance of the
XercesDOMParser class.  If I try to delete this in the destructor, core
dump ensues.

Here are the details of my execution environment:
        - gcc version 3.3.1
        - Linux 2.4.20-31.9smp #1 SMP



//////// Source code begin ////////////////
#include <iostream>
#include <stdexcept>
#include <string>

#include "xercesc/parsers/XercesDOMParser.hpp"

using namespace std;
XERCES_CPP_NAMESPACE_USE

#define DST_BLOCK_SIZE 8192

//---------------------------------------------------
//
//---------------------------------------------------
class CreateCoreDump
{
public:
  CreateCoreDump(const string& inputXMLFileName) throw (bad_alloc)
  {
    m_parser = new XercesDOMParser;

    try
    {
      m_parser->parse(inputXMLFileName.c_str());
    }
    catch(...)
    {
#ifdef DEBUG
      cerr << "Error in parsing file " << inputXMLFileName << " ---
issuing exception\n";
      delete m_parser;
      m_parser = NULL;

      throw bad_alloc();
 #endif // DEBUG
    }

    DOMDocument* domPtr = m_parser->adoptDocument();
    //
    // Do something useful here
    //
  }

  virtual ~CreateCoreDump()
  {
    if(m_parser)
      delete m_parser;   // This is the statement that causes the core
dump
  }
  
protected:

  XercesDOMParser*    m_parser;
};


//
------------------------------------------------------------------------
---
//
//  main
//
//
------------------------------------------------------------------------
---
int main(int argC, char* argV[])
{
  // Check command line arguments.
  if (argC < 2)
  {
      cout << "usage: " << argV[1] << " <input XML file>\n";;
      XMLPlatformUtils::Terminate();
      return 1;
  }

  // Initialize the XML4C2 system
  try
  {
      XMLPlatformUtils::Initialize();
  }
  catch(const XMLException &toCatch)
  {
      XERCES_STD_QUALIFIER cerr << "Error during Xerces-c
Initialization.\n"
            << "  Exception message:"
           << XMLString::transcode(toCatch.getMessage()) <<
XERCES_STD_QUALIFIER endl;
      return 1;
  }

  CreateCoreDump ccd(argV[1]);

  // Call the termination method
  XMLPlatformUtils::Terminate();

  return 0;
}

//////// Source code end ////////////////





Reply via email to