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 Colin Paul Adams <co...@colina.demon.co.uk> on 2003/04/11 19:21:54 UTC
release()ing a DOMDocument
How do I release a DOMDocument? If I call release on a pointer to a
DOMDocument, then I get an abort with "pure virtual method called".
--
Colin Paul Adams
Preston Lancashire
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org
Re: release()ing a DOMDocument
Posted by Colin Paul Adams <co...@colina.demon.co.uk>.
>>>>> "david" == david n bertoni <da...@us.ibm.com> writes:
david> Have you checked for a double-delete scenario. That's
david> often the cause for this error.
Yes, that was the problem, two wrappers around the same pointer.
david> By the way, I'm curious as to why you're using a
david> static_cast in the constructor. A DOMDocument is-a
david> DOMNode, so it doesn't really seem necessary.
Yes, I've removed that too.
--
Colin Paul Adams
Preston Lancashire
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org
Re: release()ing a DOMDocument
Posted by da...@us.ibm.com.
Hi Colin,
Have you checked for a double-delete scenario. That's often the cause for
this error.
By the way, I'm curious as to why you're using a static_cast in the
constructor. A DOMDocument is-a DOMNode, so it doesn't really seem
necessary.
Dave
Colin Paul Adams
<colin@colina.de To: xerces-c-dev@xml.apache.org
mon.co.uk> cc: (bcc: David N Bertoni/Cambridge/IBM)
Subject: Re: release()ing a DOMDocument
04/14/2003 01:30
AM
Please respond
to xerces-c-dev
>>>>> "Gareth" == Gareth Reakes <ga...@decisionsoft.com> writes:
Gareth> Hi, can you post a snippet of your code? The method is
Gareth> certainly implemented.
In brief:
class xercesc_eiffel_dom_Document : public xercesc_eiffel_dom_Node
{
public:
xercesc_eiffel_dom_Document (DOMDocument * impl) :
xercesc_eiffel_dom_Node (static_cast<DOMNode *>(impl))
{
xercesc_document = impl;
}
~xercesc_eiffel_dom_Document () { xercesc_document->release(); }
private:
DOMDocument * xercesc_document;
};
--
Colin Paul Adams
Preston Lancashire
---------------------------------------------------------------------
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: release()ing a DOMDocument
Posted by Colin Paul Adams <co...@colina.demon.co.uk>.
>>>>> "Alberto" == Alberto Massari <am...@progress.com> writes:
Alberto> Just to state the obvious, do you check that the
Alberto> DOMDocument* returned by the parser is not NULL? If
Alberto> parsing fails (and you don't plug in an error handler),
Alberto> that's what you get ....
They certainly aren't null (I can see that from my debugging efforts
right now), and in any case, I do have an error handler for the
parser.
I am also creating empty DOMDocuments.
--
Colin Paul Adams
Preston Lancashire
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org
Re: release()ing a DOMDocument
Posted by Alberto Massari <am...@progress.com>.
At 12.38 14/04/2003 +0100, Colin Paul Adams wrote:
> >>>>> "Gareth" == Gareth Reakes <ga...@decisionsoft.com> writes:
>[...]
>Encouraging enough for me to try it once more, this time with a little
>more debugging. Now I discover that sometimes it works, and sometimes
>it doesn't.
>
>I now need to find out whether it's the way that the DOMDocument is
>created that makes the difference. Is there a rule on this, or should
>release() work for any DOMDocument?
Just to state the obvious, do you check that the DOMDocument* returned by
the parser is not NULL? If parsing fails (and you don't plug in an error
handler), that's what you get ....
Alberto
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org
Re: release()ing a DOMDocument
Posted by Colin Paul Adams <co...@colina.demon.co.uk>.
>>>>> "Colin" == Colin Paul Adams <co...@colina.demon.co.uk> writes:
Colin> I now need to find out whether it's the way that the
Colin> DOMDocument is created that makes the difference. Is there
Colin> a rule on this, or should release() work for any
Colin> DOMDocument?
Well, after some debugging, I can answer my own question a little - I
have to be more careful when wrapping DOMDocument * in classes - as
when I create such a wrapper class as a result from a call to
getOwnerDocument, I now have two wrappers wrapping the same
DOMDocument *.
So I guess that is how I got to call release() twice on the same
pointer.
Ah well, we live and learn. A simple boolean flag should solve this.
--
Colin Paul Adams
Preston Lancashire
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org
Re: release()ing a DOMDocument
Posted by Colin Paul Adams <co...@colina.demon.co.uk>.
>>>>> "Jason" == Jason E Stewart <ja...@openinformatics.com> writes:
Jason> Hey Colin,
Jason> Are there Eiffel bindings for Xerces? If so, that would
Yes, I wrote it :-)
In fact, that's what these messages have been about - debugging the
memory management problems.
Actually, it's only the DOM interface - I haven't touched SAX at all.
No call for it in my experience. <ducks for cover>
Jason> mean that there are Python, Perl, and Eiffel that I know
Jason> about. I'd like to coordinate this somehow with apache and
Jason> advertise these bindings more publicly.
the web page is eiffel-edom.sourceforge.net.
Jason> Likewise for scripting language bindings for other
Jason> xml.apache.org projects like Xalan.
Well eiffel-edom also covers pathan and xalan (well, much of
XalanTransformer, anyway).
--
Colin Paul Adams
Preston Lancashire
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org
Re: release()ing a DOMDocument
Posted by "Jason E. Stewart" <ja...@openinformatics.com>.
"Colin Paul Adams" <co...@colina.demon.co.uk> writes:
> >>>>> "Colin" == Colin Paul Adams <co...@colina.demon.co.uk> writes:
>
> Colin> I now need to find out whether it's the way that the
> Colin> DOMDocument is created that makes the difference.
>
> Never mind.
>
> Apparently I'm calling release on the same document twice
> (this is all being done via the Eiffel garbage collector, so it's not
> easy for me to know what's going on).
Hey Colin,
Are there Eiffel bindings for Xerces? If so, that would mean that
there are Python, Perl, and Eiffel that I know about. I'd like to
coordinate this somehow with apache and advertise these bindings more
publicly.
Likewise for scripting language bindings for other xml.apache.org
projects like Xalan.
Cheers,
jas.
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org
Re: release()ing a DOMDocument
Posted by da...@us.ibm.com.
Hi Colin,
When you called release the first time, the DOMDocument destroyed itself.
When you called it the second time, you were calling release() on an
already destroyed C++ object. There is nothing the object instance can do
to warn you of that. In fact, it's within the realm of "undefined
behavior" as defined in the C++ standard, and the behavior could be far
worse.
If your wrapper object's destructor is being called twice, that's a real
problem. That's also in the realm of undefined behavior. If you can't
solve it, you should set the DOMDocument pointer to 0, and check that in
the destructor to safeguard against this.
Dave
Colin Paul Adams
<colin@colina.de To: xerces-c-dev@xml.apache.org
mon.co.uk> cc: (bcc: David N Bertoni/Cambridge/IBM)
Subject: Re: release()ing a DOMDocument
04/14/2003 04:48
AM
Please respond
to xerces-c-dev
>>>>> "Colin" == Colin Paul Adams <co...@colina.demon.co.uk> writes:
Colin> I now need to find out whether it's the way that the
Colin> DOMDocument is created that makes the difference.
Never mind.
Apparently I'm calling release on the same document twice
(this is all being done via the Eiffel garbage collector, so it's not
easy for me to know what's going on).
Though the error message doesn't help - Pure virtual method called -
Release already called would be nicer.
--
Colin Paul Adams
Preston Lancashire
---------------------------------------------------------------------
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: release()ing a DOMDocument
Posted by Colin Paul Adams <co...@colina.demon.co.uk>.
>>>>> "Colin" == Colin Paul Adams <co...@colina.demon.co.uk> writes:
Colin> I now need to find out whether it's the way that the
Colin> DOMDocument is created that makes the difference.
Never mind.
Apparently I'm calling release on the same document twice
(this is all being done via the Eiffel garbage collector, so it's not
easy for me to know what's going on).
Though the error message doesn't help - Pure virtual method called -
Release already called would be nicer.
--
Colin Paul Adams
Preston Lancashire
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org
Re: release()ing a DOMDocument
Posted by Colin Paul Adams <co...@colina.demon.co.uk>.
>>>>> "Gareth" == Gareth Reakes <ga...@decisionsoft.com> writes:
Gareth> Hi, interesting. MIght have to expand on that code a
Gareth> little :)
I KNEW you were going to be unreasonable :-)
Gareth> This works fine for me
Gareth> XercesDOMParser *parser = new XercesDOMParser;
parser-> parse("foo.xml");
Gareth> DOMDocument *newDoc = parser->getDocument();
newDoc-> release();
That's encouraging.
Encouraging enough for me to try it once more, this time with a little
more debugging. Now I discover that sometimes it works, and sometimes
it doesn't.
I now need to find out whether it's the way that the DOMDocument is
created that makes the difference. Is there a rule on this, or should
release() work for any DOMDocument?
--
Colin Paul Adams
Preston Lancashire
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org
Re: release()ing a DOMDocument
Posted by Gareth Reakes <ga...@decisionsoft.com>.
Hi,
interesting. MIght have to expand on that code a little :) This
works fine for me
XercesDOMParser *parser = new XercesDOMParser;
parser->parse("foo.xml");
DOMDocument *newDoc = parser->getDocument();
newDoc->release();
Gareth
On 14 Apr 2003, Colin Paul Adams wrote:
> >>>>> "Gareth" == Gareth Reakes <ga...@decisionsoft.com> writes:
>
> Gareth> Hi, can you post a snippet of your code? The method is
> Gareth> certainly implemented.
>
>
> In brief:
>
> class xercesc_eiffel_dom_Document : public xercesc_eiffel_dom_Node
> {
> public:
>
> xercesc_eiffel_dom_Document (DOMDocument * impl) : xercesc_eiffel_dom_Node (static_cast<DOMNode *>(impl))
> {
> xercesc_document = impl;
> }
>
> ~xercesc_eiffel_dom_Document () { xercesc_document->release(); }
>
> private:
> DOMDocument * xercesc_document;
> };
>
>
>
--
Gareth Reakes, Head of Product Development +44-1865-203192
DecisionSoft Limited http://www.decisionsoft.com
XML Development and Services
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org
Re: release()ing a DOMDocument
Posted by Colin Paul Adams <co...@colina.demon.co.uk>.
>>>>> "Gareth" == Gareth Reakes <ga...@decisionsoft.com> writes:
Gareth> Hi, can you post a snippet of your code? The method is
Gareth> certainly implemented.
In brief:
class xercesc_eiffel_dom_Document : public xercesc_eiffel_dom_Node
{
public:
xercesc_eiffel_dom_Document (DOMDocument * impl) : xercesc_eiffel_dom_Node (static_cast<DOMNode *>(impl))
{
xercesc_document = impl;
}
~xercesc_eiffel_dom_Document () { xercesc_document->release(); }
private:
DOMDocument * xercesc_document;
};
--
Colin Paul Adams
Preston Lancashire
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org
Re: release()ing a DOMDocument
Posted by Gareth Reakes <ga...@decisionsoft.com>.
Hi,
can you post a snippet of your code? The method is certainly
implemented.
Gareth
On 11 Apr 2003, Colin Paul Adams wrote:
> How do I release a DOMDocument? If I call release on a pointer to a
> DOMDocument, then I get an abort with "pure virtual method called".
>
--
Gareth Reakes, Head of Product Development +44-1865-203192
DecisionSoft Limited http://www.decisionsoft.com
XML Development and Services
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org