On Mon, Mar 10, 2008 at 06:43:02PM -0700, William M. Brack wrote:
Martin (gzlist) wrote:I attach a simple python script (libxml2_crash.py) that seems to reference uninitialised memory, or crash the interpreter.<snip>I tried the simplest C equivalent I could cook up from the docs (attached libxml2_nocrash.c) which behaves itself, perhaps suggesting the problem's in the python bindings. Could someone with a good understanding of the lib can get a better idea of what exactly is up? MartinI traced through quite a bit, and was able to isolate where and what the problem is. Unfortunately, I can't spend much time on libxml2 for the next couple of weeks, so I have opened a bug (http://bugzilla.gnome.org/show_bug.cgi?id=521699) which describes how far I got with it.
yup, agreed with your analysis. That the only case where nodes returned from an XPath query do not pertain to the document and hence have a different lifetime. `
Perhaps another list member may be able to pursue this? Python bindings are always fun to work on....
I managed to find a minimalist but correct way to fix this, basically get python to destroy the namespace node when it garbage collect the associated python object and remove it from the nodeset before it is being freed, this seems to work quite well actually. Patch attached, I will also commit a specific regression test. Note that libxslt/python/types.c need to be patched too. Daniel -- Red Hat Virtualization group http://redhat.com/virtualization/ Daniel Veillard | virtualization library http://libvirt.org/ veillard redhat com | libxml GNOME XML XSLT toolkit http://xmlsoft.org/ http://veillard.com/ | Rpmfind RPM search engine http://rpmfind.net/
Description: Text document