JuliaIO / LightXML.jl

A light-weight Julia package for XML based on libxml2.
MIT License
91 stars 39 forks source link

Crash on _xmlfree on Windows #1

Open tknopp opened 10 years ago

tknopp commented 10 years ago

Hi,

This is really a great package!

Still, I have to report one bug I have on windows. The complete Julia shell crashes when I call e.g. the content function. I have traced it down to the tri_xmlfree(p) function. Do you have any idea or should this got to the Julia bug tracker as it seems to be not related to LightXML.

I use a windows dll of libxml2 to get this work.

P.S.: using MiniXML in Readme.md should be propably using LightXML

lindahua commented 10 years ago

would you please post the code that led to the crash?

tknopp commented 10 years ago

I do not have the code at hand (and the windows machine...) but I can generate a minimal example next week. The code works fine on linux and I am pretty sure that it is the "tri_xmlfree" function as the code works, when I change this function to do nothing.

tknopp commented 10 years ago

Here on windows it crashes on:

using LightXML xdoc = parse_string("MyContent")

when I remove _xmlfree(p) from _xcopystr(p::Xstr) in clib.jl everything works. Using xmlFree instead of libc free does also crash Julia.

digital-carver commented 8 years ago

I'm guessing the following errors fall under the same category:

julia> xdoc = parse_file("D:/tempstuff/filename.xml")
ERROR: error compiling parse_file:

julia> xs = parse_string("<head><mouth>tongue</mouth></head>")
ERROR: error compiling parse_string:

julia>
G:\> julia .\myxmlparse.jl
ERROR: error compiling parse_file:
 in include at boot.jl:245
 in include_from_node1 at loading.jl:128
 in process_options at client.jl:285
 in _start at client.jl:354
while loading G:\progs\myxmlparse\myxmlparse.jl, in expression starting on line 4

but I don't yet have the knowledge to peek under the hood and verify it's the same _xmlfree that's causing the issue.

samoconnor commented 8 years ago

There is a comment next to _xcopystr() that says libc free is used instead of xmlFree: https://github.com/JuliaLang/LightXML.jl/blob/master/src/LightXML.jl#L37

However, the libxml2 manual is quite clear that xmlFree should be used: "It's up to the caller to free the memory with xmlFree()." : http://www.xmlsoft.org/html/libxml-tree.html#xmlNodeGetContent ...

This certainly smells NQR.

tkelman commented 8 years ago

Hard to say whether @digital-carver's errors are at all related here, but I suspect the "tests" referred to in the comment in https://github.com/JuliaLang/LightXML.jl/commit/b33d030cb052f05d528a7355f2237471103a394c were not run on windows. We should probably try using the libxml2 xmlFree instead.