Re: [xml] Curious Segmentation Fault



On Mon, Apr 05, 2004 at 11:45:39AM -0400, Anthony Carrico wrote:
On Mon, Apr 05, 2004 at 03:14:54AM -0400, Daniel Veillard wrote:
On Sun, Apr 04, 2004 at 11:33:05PM -0400, Anthony Carrico wrote:
Why?

  Because after element.unlinkNode(), the element still references
the document, and element.unlinkNode() checks it to find if the
strings from the element came from the document dictionary.
If you free the document after any element which references it you
don't have the problem. Allocation granularity in libxml2 is
at the document level.

So the third example (which seems to succed) is also illegal. Correct?
This one:

import libxml2
libxml2.debugMemory(1)
doc = libxml2.newDoc("1.0")
element = doc.newChild(None, "test", None)
element.unlinkNode()
doc.freeDoc()

  you free doc, element is linked to doc, you freed element underlying
data there.

doc = libxml2.newDoc("1.0")
doc.addChild(element)
element.unlinkNode()

  that should crash,  element underlying node has been freed.

Again, the main unit of memory allocation in libxml2 is the document.

Daniel

-- 
Daniel Veillard      | Red Hat Network https://rhn.redhat.com/
veillard redhat com  | libxml GNOME XML XSLT toolkit  http://xmlsoft.org/
http://veillard.com/ | Rpmfind RPM search engine http://rpmfind.net/



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]