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 Matt Garman <ga...@raw-sewage.net> on 2004/06/04 17:25:06 UTC

DOMImplementation::createDocument() causing seg fault

Hello,

I'm trying to implment a method called createDOMDocument() in a custom
C++ class I wrote.  The intent of this method is to create a DOMDocument
that represents the internal data structure of the class (so I can in
turn use DOMWriter to write my data structure to an XML file).

My createDOMDocument() method is essentially the main() function from
the CreateDOMDocument.cpp example included with Xerces-C.  However,
whenever I run my application, it crashes with a segmentation fault on
the following line:

DOMDocument* doc = impl->createDocument(0, X("todolist"), 0);

Note that the impl object is instantiated as follows:

DOMImplementation* impl =
DOMImplementationRegistry::getDOMImplementation(X("Core"));

For what it's worth I'm doing this development on Linux with the
following complier:

g++ (GCC) 3.3.2 20031218 (Gentoo Linux 3.3.2-r5, propolice-3.3-7)

I'll gladly post my function if anyone would like to see it (but, it's
virtually identical to the main() in CreateDOMDocument.cpp).  Short of
building a debug version of Xerces-C and stepping through
createDocument(), does anyone have any ideas what might be causing the
crash?

Thanks,
Matt

-- 
Matt Garman
email at: http://raw-sewage.net/index.php?file=email

---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org


Re: DOMImplementation::createDocument() causing seg fault

Posted by "Jeroen N. Witmond" <jn...@xs4all.nl>.
> On Fri, Jun 04, 2004 at 05:50:40PM +0100, Tony Dodd wrote:
>> You did remember to initialise, Xerces, didn't you?
>
> Yup, I've got the following call in a try/catch block:
>
> 	XMLPlatformUtils::Initialize();
>
> Taking a second look at the CreateDOMDocument.cpp example, I noticed
> that most of the main() function (the part that does the "real work",
> i.e. actually creates the DOMDocument) is nested in an inner block.  Why
> is this?

The end of the block destroys all objects declared in that block. As a
result, the destructors of these objects (if any) are guaranteed to run
before the call to XMLPlatformUtils::Terminate().

Jeroen.

> I did that in my code as well, although the result was no
> different (still seg faults).
>
> Thanks again,
> Matt
>
> --
> Matt Garman
> email at: http://raw-sewage.net/index.php?file=email
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
> For additional commands, e-mail: xerces-c-dev-help@xml.apache.org
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org


Re: DOMImplementation::createDocument() causing seg fault

Posted by Matt Garman <ga...@raw-sewage.net>.
On Fri, Jun 04, 2004 at 05:50:40PM +0100, Tony Dodd wrote:
> You did remember to initialise, Xerces, didn't you?

Yup, I've got the following call in a try/catch block:

	XMLPlatformUtils::Initialize();

Taking a second look at the CreateDOMDocument.cpp example, I noticed
that most of the main() function (the part that does the "real work",
i.e. actually creates the DOMDocument) is nested in an inner block.  Why
is this?  I did that in my code as well, although the result was no
different (still seg faults).

Thanks again,
Matt

-- 
Matt Garman
email at: http://raw-sewage.net/index.php?file=email

---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org


RE: DOMImplementation::createDocument() causing seg fault

Posted by Tony Dodd <to...@btinternet.com>.
You did remember to initialise, Xerces, didn't you?

Tony Dodd
Oxford University Research Technology Group

>-----Original Message-----
>From: Matt Garman [mailto:garman@raw-sewage.net] 
>Sent: 04 June 2004 16:25
>To: xerces-c-dev@xml.apache.org
>Subject: DOMImplementation::createDocument() causing seg fault
>
>
>Hello,
>
>I'm trying to implment a method called createDOMDocument() in a custom
>C++ class I wrote.  The intent of this method is to create a 
>DOMDocument
>that represents the internal data structure of the class (so I 
>can in turn use DOMWriter to write my data structure to an XML file).
>
>My createDOMDocument() method is essentially the main() 
>function from the CreateDOMDocument.cpp example included with 
>Xerces-C.  However, whenever I run my application, it crashes 
>with a segmentation fault on the following line:
>
>DOMDocument* doc = impl->createDocument(0, X("todolist"), 0);
>
>Note that the impl object is instantiated as follows:
>
>DOMImplementation* impl =
>DOMImplementationRegistry::getDOMImplementation(X("Core"));
>
>For what it's worth I'm doing this development on Linux with 
>the following complier:
>
>g++ (GCC) 3.3.2 20031218 (Gentoo Linux 3.3.2-r5, propolice-3.3-7)
>
>I'll gladly post my function if anyone would like to see it 
>(but, it's virtually identical to the main() in 
>CreateDOMDocument.cpp).  Short of building a debug version of 
>Xerces-C and stepping through createDocument(), does anyone 
>have any ideas what might be causing the crash?
>
>Thanks,
>Matt
>
>--
>Matt Garman
>email at: http://raw-sewage.net/index.php?file=email
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
>For additional commands, e-mail: xerces-c-dev-help@xml.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org