zzycami / touchcode

Automatically exported from code.google.com/p/touchcode
0 stars 0 forks source link

memory stomp? #35

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago

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.

Original issue reported on code.google.com by sam.chri...@gmail.com on 4 Nov 2008 at 5:09

GoogleCodeExporter commented 8 years ago
Fixed in r226.

Now deleting the node pool BEFORE deleting the document. Can you confirm this 
fixes it for you?

Original comment by jwight on 7 Nov 2008 at 7:42

GoogleCodeExporter commented 8 years ago
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.

Original comment by mobyga...@gmail.com on 11 Mar 2009 at 6:20

GoogleCodeExporter commented 8 years ago
Downloads deprecated now.

Will add new downloads shortly. Thanks.

Original comment by jwight on 13 Mar 2009 at 1:18

GoogleCodeExporter commented 8 years ago
Hi, I have downloaded the 1.07 version (later one) and am stll getting this 
error when I free the XMLDocument.

Original comment by or...@studio6.com.br on 9 Mar 2010 at 1:14