Re: [xml] Curious Segmentation Fault
- From: Daniel Veillard <veillard redhat com>
- To: Anthony Carrico <acarrico memebeam org>
- Cc: libxml <xml gnome org>
- Subject: Re: [xml] Curious Segmentation Fault
- Date: Mon, 5 Apr 2004 03:14:54 -0400
On Sun, Apr 04, 2004 at 11:33:05PM -0400, Anthony Carrico wrote:
This python program has a segmentation fault:
import libxml2
libxml2.debugMemory(1)
doc = libxml2.newDoc("1.0")
element = doc.newChild(None, "test", None)
element.unlinkNode()
doc.freeDoc()
element.freeNode()
This is fine:
import libxml2
libxml2.debugMemory(1)
doc = libxml2.newDoc("1.0")
element = doc.newChild(None, "test", None)
element.unlinkNode()
element.freeNode()
doc.freeDoc()
This is fine too:
import libxml2
libxml2.debugMemory(1)
doc = libxml2.newDoc("1.0")
element = doc.newChild(None, "test", None)
element.unlinkNode()
doc.freeDoc()
doc = libxml2.newDoc("1.0")
doc.addChild(element)
element.unlinkNode()
element.freeNode()
doc.freeDoc()
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.
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]