Issue 35: memory stomp?
Status:  Fixed
Owner: ----
Closed:  Nov 2008
Reported by sam.chri...@gmail.com, Nov 3, 2008

I've been using touchxml for a bit and have been getting some random
crashes in my application.  Today, I decided to track them down once and
for all.  I turned on the "guard malloc" option, and was able to get a
reproduceable crash in TouchXML.  I believe the problem is in the order
that the document frees the low-level libxml nodes and the CXMLNodes.

Here is the CXMLDocument dealloc function:

- (void)dealloc
{
xmlFreeDoc((xmlDocPtr)_node);
_node = NULL;
//

[nodePool release];
nodePool = NULL;
//
[super dealloc];
}

Here is the CXMLNode dealloc:

- (void)dealloc
{
if (_node)
	{
	if (_node->_private == self)
		_node->_private = NULL;
	_node = NULL;
	}
//
[super dealloc];
}

The document is freed first, which calls the xmlFreeDoc function, which
according to libxml2 docs frees the entire tree structure.  Later, the node
dealloc function is called, and the CXMLNode class at this point has a
pointer to a node that has been freed.  It will set _node->private to NULL,
which stomps memory and can cause problems elsewhere.
Nov 7, 2008
Project Member #1 jwight
Fixed in r226.

Now deleting the node pool BEFORE deleting the document. Can you confirm this fixes it for you?
Status: Fixed
Mar 10, 2009
#2 mobyga...@gmail.com
I was getting this exact same problem, and I verified that the current trunk does indeed fix this problem.   I'm 
new to this project and initially downloaded 1.0 from the downloads tab.   Considering that this is a pretty big 
problem that will cause problems, maybe that link should be removed or a new release rolled up?   In any case, 
I'm a big fan of touchcode so far and look forward to working with it.
Mar 12, 2009
Project Member #3 jwight
Downloads deprecated now.

Will add new downloads shortly. Thanks.
Mar 9, 2010
#4 or...@studio6.com.br
Hi, I have downloaded the 1.07 version (later one) and am stll getting this error when I free the XMLDocument.