Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invalid pointer after unlink! #28

Closed
andyferris opened this issue Sep 13, 2017 · 4 comments
Closed

Invalid pointer after unlink! #28

andyferris opened this issue Sep 13, 2017 · 4 comments

Comments

@andyferris
Copy link

I'm trying to load an .xml file, mutate the xml document in memory, and save it to disk again. However, I get errors whenever I use unlink! to remove a subset of elements from my xml. Perhaps I'm misusing unlink! or I'm not allowed to mutate xml files that I've loaded - any help appreciated.

Minimal example. Create a file called tmp2.xml with content

<?xml version="1.0" encoding="UTF-8"?>
<Response bayid="597658" srid="32755">
    <Zones>
        <Zone id="260662925" typeid="52" spanid="12830086">
        </Zone>
        <Zone id="260662926" typeid="53" spanid="12830086">
        </Zone>
    </Zones>
</Response>

(this is a simplified and much reduced version of some data I have)

Then I run Julia v0.6 and get an pointer error from something calling free. To be clear, in my real example with more complex data, the error happens before exiting Julia - and is possibly happening during some Julia garbage collection event - but in the example below the "tmp3.xml" file is written successfully before the error happens. Speculatively, I'm wondering if unlink! free's some resources which are still referenced somewhere, and a finalizer or destructor or something then attempts to free it again later.

julia> using EzXML

julia> function f(in, out)
           xmldoc = readxml(in)
           nodes = find(xmldoc, "Response/Zones/Zone")
           unlink!.(nodes)
           open(out, "w") do io
               write(io, string(xmldoc))
           end
       end
f (generic function with 1 method)

julia> f("tmp2.xml","tmp3.xml")
121

julia> exit()
*** Error in `julia': free(): invalid pointer: 0x0000000002c5f237 ***
======= Backtrace: =========
/lib/x86_64-linux-gnu/libc.so.6(+0x777e5)[0x7fdbe347b7e5]
/lib/x86_64-linux-gnu/libc.so.6(+0x8037a)[0x7fdbe348437a]
/lib/x86_64-linux-gnu/libc.so.6(cfree+0x4c)[0x7fdbe348853c]
/usr/lib/x86_64-linux-gnu/libxml2.so.2(xmlFreeNodeList+0x232)[0x7fdbd50e8fd2]
/usr/lib/x86_64-linux-gnu/libxml2.so.2(xmlFreeNode+0x7c)[0x7fdbd50e92fc]
[0x7fdbc1de2aa2]
[0x7fdbc1de2ae3]
/home/ferris/julia-0.6/usr/bin/../lib/libjulia.so.0.6(jl_apply_generic+0x467)[0x7fdbe3e33077]
/home/ferris/julia-0.6/usr/bin/../lib/libjulia.so.0.6(+0x7f60e)[0x7fdbe3e7660e]
/home/ferris/julia-0.6/usr/bin/../lib/libjulia.so.0.6(+0x7f8c7)[0x7fdbe3e768c7]
/home/ferris/julia-0.6/usr/bin/../lib/libjulia.so.0.6(+0x83aee)[0x7fdbe3e7aaee]
/home/ferris/julia-0.6/usr/bin/../lib/libjulia.so.0.6(jl_atexit_hook+0x1eb)[0x7fdbe3e4ab1b]
/home/ferris/julia-0.6/usr/bin/../lib/libjulia.so.0.6(jl_exit+0x17)[0x7fdbe3e61c37]
/home/ferris/julia-0.6/usr/lib/julia/sys.so(+0x47bf1c)[0x7fdbde2e5f1c]
/home/ferris/julia-0.6/usr/lib/julia/sys.so(+0x47bf29)[0x7fdbde2e5f29]
/home/ferris/julia-0.6/usr/bin/../lib/libjulia.so.0.6(jl_apply_generic+0x467)[0x7fdbe3e33077]
/home/ferris/julia-0.6/usr/bin/../lib/libjulia.so.0.6(+0x5090e)[0x7fdbe3e4790e]
/home/ferris/julia-0.6/usr/bin/../lib/libjulia.so.0.6(+0x4f90a)[0x7fdbe3e4690a]
/home/ferris/julia-0.6/usr/bin/../lib/libjulia.so.0.6(+0x50844)[0x7fdbe3e47844]
/home/ferris/julia-0.6/usr/bin/../lib/libjulia.so.0.6(+0x67c4b)[0x7fdbe3e5ec4b]
/home/ferris/julia-0.6/usr/bin/../lib/libjulia.so.0.6(jl_toplevel_eval_in+0x126)[0x7fdbe3e41476]
/home/ferris/julia-0.6/usr/lib/julia/sys.so(+0x2716da)[0x7fdbde0db6da]
/home/ferris/julia-0.6/usr/lib/julia/sys.so(+0x2716f0)[0x7fdbde0db6f0]
/home/ferris/julia-0.6/usr/bin/../lib/libjulia.so.0.6(jl_apply_generic+0x467)[0x7fdbe3e33077]
/home/ferris/julia-0.6/usr/lib/julia/sys.so(+0x2df643)[0x7fdbde149643]
/home/ferris/julia-0.6/usr/lib/julia/sys.so(+0x2df860)[0x7fdbde149860]
/home/ferris/julia-0.6/usr/bin/../lib/libjulia.so.0.6(jl_apply_generic+0x467)[0x7fdbe3e33077]
[0x7fdbc1dd8036]
[0x7fdbc1dd82b0]
/home/ferris/julia-0.6/usr/bin/../lib/libjulia.so.0.6(jl_apply_generic+0x467)[0x7fdbe3e33077]
/home/ferris/julia-0.6/usr/bin/../lib/libjulia.so.0.6(+0x55f20)[0x7fdbe3e4cf20]
======= Memory map: ========
00400000-00403000 r-xp 00000000 fc:05 10120118                           /home/ferris/julia-0.6/usr/bin/julia
00602000-00603000 r--p 00002000 fc:05 10120118                           /home/ferris/julia-0.6/usr/bin/julia
00603000-00604000 rw-p 00003000 fc:05 10120118                           /home/ferris/julia-0.6/usr/bin/julia
00c6a000-02daa000 rw-p 00000000 00:00 0                                  [heap]
7fdbb8000000-7fdbb8021000 rw-p 00000000 00:00 0 
7fdbb8021000-7fdbbc000000 ---p 00000000 00:00 0 
7fdbbc01b000-7fdbbd8d1000 r-xp 00000000 fc:05 12853709                   /usr/lib/x86_64-linux-gnu/libicudata.so.55.1
7fdbbd8d1000-7fdbbdad0000 ---p 018b6000 fc:05 12853709                   /usr/lib/x86_64-linux-gnu/libicudata.so.55.1
7fdbbdad0000-7fdbbdad1000 r--p 018b5000 fc:05 12853709                   /usr/lib/x86_64-linux-gnu/libicudata.so.55.1
7fdbbdad1000-7fdbbdad2000 rw-p 018b6000 fc:05 12853709                   /usr/lib/x86_64-linux-gnu/libicudata.so.55.1
7fdbbdad2000-7fdbc1ad6000 rw-p 00000000 00:00 0 
7fdbc1ad6000-7fdbc1bd6000 r--s 00100000 00:05 2443422                    /memfd:julia-codegen (deleted)
7fdbc1bd6000-7fdbc1dd6000 r--s 00000000 00:05 2443422                    /memfd:julia-codegen (deleted)
7fdbc1dd6000-7fdbc1ed6000 r-xs 00000000 00:05 2443422                    /memfd:julia-codegen (deleted)
7fdbc1ed6000-7fdbc5ed6000 rw-p 00000000 00:00 0 
7fdbc5ed6000-7fdbc5ed7000 r-xp 00000000 fc:05 10120869                   /home/ferris/julia-0.6/usr/lib/libsuitesparse_wrapper.so
7fdbc5ed7000-7fdbc60d6000 ---p 00001000 fc:05 10120869                   /home/ferris/julia-0.6/usr/lib/libsuitesparse_wrapper.so
7fdbc60d6000-7fdbc60d7000 r--p 00000000 fc:05 10120869                   /home/ferris/julia-0.6/usr/lib/libsuitesparse_wrapper.so
7fdbc60d7000-7fdbc60d8000 rw-p 00001000 fc:05 10120869                   /home/ferris/julia-0.6/usr/lib/libsuitesparse_wrapper.so
7fdbc60d8000-7fdbc60da000 r-xp 00000000 fc:05 10120859                   /home/ferris/julia-0.6/usr/lib/libsuitesparseconfig.so
7fdbc60da000-7fdbc62d9000 ---p 00002000 fc:05 10120859                   /home/ferris/julia-0.6/usr/lib/libsuitesparseconfig.so
7fdbc62d9000-7fdbc62da000 r--p 00001000 fc:05 10120859                   /home/ferris/julia-0.6/usr/lib/libsuitesparseconfig.so
7fdbc62da000-7fdbc62db000 rw-p 00002000 fc:05 10120859                   /home/ferris/julia-0.6/usr/lib/libsuitesparseconfig.so
7fdbc62db000-7fdbc62e6000 r-xp 00000000 fc:05 10120863                   /home/ferris/julia-0.6/usr/lib/libccolamd.so
7fdbc62e6000-7fdbc64e6000 ---p 0000b000 fc:05 10120863                   /home/ferris/julia-0.6/usr/lib/libccolamd.so
7fdbc64e6000-7fdbc64e7000 r--p 0000b000 fc:05 10120863                   /home/ferris/julia-0.6/usr/lib/libccolamd.so
7fdbc64e7000-7fdbc64e8000 rw-p 0000c000 fc:05 10120863                   /home/ferris/julia-0.6/usr/lib/libccolamd.so
7fdbc64e8000-7fdbc64f2000 r-xp 00000000 fc:05 10120862                   /home/ferris/julia-0.6/usr/lib/libcamd.so
7fdbc64f2000-7fdbc66f2000 ---p 0000a000 fc:05 10120862                   /home/ferris/julia-0.6/usr/lib/libcamd.so
7fdbc66f2000-7fdbc66f3000 r--p 0000a000 fc:05 10120862                   /home/ferris/julia-0.6/usr/lib/libcamd.so
7fdbc66f3000-7fdbc66f4000 rw-p 0000b000 fc:05 10120862                   /home/ferris/julia-0.6/usr/lib/libcamd.so
7fdbc66f4000-7fdbc66fd000 r-xp 00000000 fc:05 10120860                   /home/ferris/julia-0.6/usr/lib/libamd.so
7fdbc66fd000-7fdbc68fc000 ---p 00009000 fc:05 10120860                   /home/ferris/julia-0.6/usr/lib/libamd.so
7fdbc68fc000-7fdbc68fd000 r--p 00008000 fc:05 10120860                   /home/ferris/julia-0.6/usr/lib/libamd.so
7fdbc68fd000-7fdbc68fe000 rw-p 00009000 fc:05 10120860                   /home/ferris/julia-0.6/usr/lib/libamd.so
7fdbc68fe000-7fdbc6905000 r-xp 00000000 fc:05 10120861                   /home/ferris/julia-0.6/usr/lib/libcolamd.so
7fdbc6905000-7fdbc6b04000 ---p 00007000 fc:05 10120861                   /home/ferris/julia-0.6/usr/lib/libcolamd.so
7fdbc6b04000-7fdbc6b05000 r--p 00006000 fc:05 10120861                   /home/ferris/julia-0.6/usr/lib/libcolamd.so
7fdbc6b05000-7fdbc6b06000 rw-p 00007000 fc:05 10120861                   /home/ferris/julia-0.6/usr/lib/libcolamd.so
7fdbc6b06000-7fdbc6c05000 r-xp 00000000 fc:05 10120865                   /home/ferris/julia-0.6/usr/lib/libcholmod.so
7fdbc6c05000-7fdbc6e05000 ---p 000ff000 fc:05 10120865                   /home/ferris/julia-0.6/usr/lib/libcholmod.so
7fdbc6e05000-7fdbc6e06000 r--p 000ff000 fc:05 10120865                   /home/ferris/julia-0.6/usr/lib/libcholmod.so
7fdbc6e06000-7fdbc6e07000 rw-p 00100000 fc:05 10120865                   /home/ferris/julia-0.6/usr/lib/libcholmod.so
7fdbc6e07000-7fdbc6e36000 r-xp 00000000 fc:05 10119158                   /home/ferris/julia-0.6/usr/lib/libssh2.so.1.0.1
7fdbc6e36000-7fdbc7036000 ---p 0002f000 fc:05 10119158                   /home/ferris/julia-0.6/usr/lib/libssh2.so.1.0.1
7fdbc7036000-7fdbc7037000 r--p 0002f000 fc:05 10119158                   /home/ferris/julia-0.6/usr/lib/libssh2.so.1.0.1
7fdbc7037000-7fdbc7038000 rw-p 00030000 fc:05 10119158                   /home/ferris/julia-0.6/usr/lib/libssh2.so.1.0.1
7fdbc7038000-7fdbc7086000 r-xp 00000000 fc:05 10118670                   /home/ferris/julia-0.6/usr/lib/libmbedcrypto.so.2.3.0
7fdbc7086000-7fdbc7285000 ---p 0004e000 fc:05 10118670                   /home/ferris/julia-0.6/usr/lib/libmbedcrypto.so.2.3.0
7fdbc7285000-7fdbc7288000 r--p 0004d000 fc:05 10118670                   /home/ferris/julia-0.6/usr/lib/libmbedcrypto.so.2.3.0
7fdbc7288000-7fdbc7289000 rw-p 00050000 fc:05 10118670                   /home/ferris/julia-0.6/usr/lib/libmbedcrypto.so.2.3.0
7fdbc7289000-7fdbc728c000 rw-p 00000000 00:00 0 
7fdbc728c000-7fdbc729e000 r-xp 00000000 fc:05 10118669                   /home/ferris/julia-0.6/usr/lib/libmbedx509.so.2.3.0
7fdbc729e000-7fdbc749e000 ---p 00012000 fc:05 10118669                   /home/ferris/julia-0.6/usr/lib/libmbedx509.so.2.3.0
7fdbc749e000-7fdbc749f000 r--p 00012000 fc:05 10118669                   /home/ferris/julia-0.6/usr/lib/libmbedx509.so.2.3.0
7fdbc749f000-7fdbc74a0000 rw-p 00013000 fc:05 10118669                   /home/ferris/julia-0.6/usr/lib/libmbedx509.so.2.3.0
7fdbc74a0000-7fdbc74c5000 r-xp 00000000 fc:05 10118677                   /home/ferris/julia-0.6/usr/lib/libmbedtls.so.2.3.0
7fdbc74c5000-7fdbc76c4000 ---p 00025000 fc:05 10118677                   /home/ferris/julia-0.6/usr/lib/libmbedtls.so.2.3.0
7fdbc76c4000-7fdbc76c6000 r--p 00024000 fc:05 10118677                   /home/ferris/julia-0.6/usr/lib/libmbedtls.so.2.3.0
7fdbc76c6000-7fdbc76c7000 rw-p 00026000 fc:05 10118677                   /home/ferris/julia-0.6/usr/lib/libmbedtls.so.2.3.0
7fdbc76c7000-7fdbc7729000 r-xp 00000000 fc:05 10119568                   /home/ferris/julia-0.6/usr/lib/libcurl.so.4.4.0
7fdbc7729000-7fdbc7928000 ---p 00062000 fc:05 10119568                   /home/ferris/julia-0.6/usr/lib/libcurl.so.4.4.0
7fdbc7928000-7fdbc792a000 r--p 00061000 fc:05 10119568                   /home/ferris/julia-0.6/usr/lib/libcurl.so.4.4.0
7fdbc792a000-7fdbc792b000 rw-p 00063000 fc:05 10119568                   /home/ferris/julia-0.6/usr/lib/libcurl.so.4.4.0
7fdbc792b000-7fdbc7a38000 r-xp 00000000 fc:05 10117458                   /home/ferris/julia-0.6/usr/lib/libgit2.so.0.25.1
7fdbc7a38000-7fdbc7c38000 ---p 0010d000 fc:05 10117458                   /home/ferris/julia-0.6/usr/lib/libgit2.so.0.25.1
7fdbc7c38000-7fdbc7c39000 r--p 0010d000 fc:05 10117458                   /home/ferris/julia-0.6/usr/lib/libgit2.so.0.25.1
7fdbc7c39000-7fdbc7c3c000 rw-p 0010e000 fc:05 10117458                   /home/ferris/julia-0.6/usr/lib/libgit2.so.0.25.1
7fdbc7c3c000-7fdbc9c3c000 rw-p 00000000 00:00 0 
7fdbc9c3c000-7fdbc9c3d000 ---p 00000000 00:00 0 
7fdbc9c3d000-7fdbca43d000 rw-p 00000000 00:00 0 
7fdbca43d000-7fdbcc43d000 rw-p 00000000 00:00 0 
7fdbcc43d000-7fdbcc43e000 ---p 00000000 00:00 0 
7fdbcc43e000-7fdbccc3e000 rw-p 00000000 00:00 0 
7fdbccc3e000-7fdbccc3f000 ---p 00000000 00:00 0 
7fdbccc3f000-7fdbcd43f000 rw-p 00000000 00:00 0 
7fdbcd43f000-7fdbd343f000 rw-p 00000000 00:00 0 
7fdbd343f000-7fdbd3440000 ---p 00000000 00:00 0 
7fdbd3440000-7fdbd3c40000 rw-p 00000000 00:00 0 
7fdbd4ad2000-7fdbd4af3000 r-xp 00000000 fc:05 9441741                    /lib/x86_64-linux-gnu/liblzma.so.5.0.0
7fdbd4af3000-7fdbd4cf2000 ---p 00021000 fc:05 9441741                    /lib/x86_64-linux-gnu/liblzma.so.5.0.0
7fdbd4cf2000-7fdbd4cf3000 r--p 00020000 fc:05 9441741                    /lib/x86_64-linux-gnu/liblzma.so.5.0.0
7fdbd4cf3000-7fdbd4cf4000 rw-p 00021000 fc:05 9441741                    /lib/x86_64-linux-gnu/liblzma.so.5.0.0
7fdbd4cf4000-7fdbd4e73000 r-xp 00000000 fc:05 12853750                   /usr/lib/x86_64-linux-gnu/libicuuc.so.55.1
7fdbd4e73000-7fdbd5073000 ---p 0017f000 fc:05 12853750                   /usr/lib/x86_64-linux-gnu/libicuuc.so.55.1
7fdbd5073000-7fdbd5083000 r--p 0017f000 fc:05 12853750                   /usr/lib/x86_64-linux-gnu/libicuuc.so.55.1
7fdbd5083000-7fdbd5084000 rw-p 0018f000 fc:05 12853750                   /usr/lib/x86_64-linux-gnu/libicuuc.so.55.1
7fdbd5084000-7fdbd5088000 rw-p 00000000 00:00 0 
7fdbd5088000-7fdbd5239000 r-xp 00000000 fc:05 12858710                   /usr/lib/x86_64-linux-gnu/libxml2.so.2.9.3
7fdbd5239000-7fdbd5438000 ---p 001b1000 fc:05 12858710                   /usr/lib/x86_64-linux-gnu/libxml2.so.2.9.3
7fdbd5438000-7fdbd5440000 r--p 001b0000 fc:05 12858710                   /usr/lib/x86_64-linux-gnu/libxml2.so.2.9.3
7fdbd5440000-7fdbd5442000 rw-p 001b8000 fc:05 12858710                   /usr/lib/x86_64-linux-gnu/libxml2.so.2.9.3
7fdbd5442000-7fdbd5443000 rw-p 00000000 00:00 0 
7fdbd5443000-7fdbd5481000 r-xp 00000000 fc:05 12850392                   /usr/lib/x86_64-linux-gnu/libquadmath.so.0.0.0
7fdbd5481000-7fdbd5680000 ---p 0003e000 fc:05 12850392                   /usr/lib/x86_64-linux-gnu/libquadmath.so.0.0.0
7fdbd5680000-7fdbd5681000 r--p 0003d000 fc:05 12850392                   /usr/lib/x86_64-linux-gnu/libquadmath.so.0.0.0
7fdbd5681000-7fdbd5682000 rw-p 0003e000 fc:05 12850392                   /usr/lib/x86_64-linux-gnu/libquadmath.so.0.0.0
7fdbd5682000-7fdbd57ab000 r-xp 00000000 fc:05 12849959                   /usr/lib/x86_64-linux-gnu/libgfortran.so.3.0.0
7fdbd57ab000-7fdbd59aa000 ---p 00129000 fc:05 12849959                   /usr/lib/x86_64-linux-gnu/libgfortran.so.3.0.0
7fdbd59aa000-7fdbd59ab000 r--p 00128000 fc:05 12849959                   /usr/lib/x86_64-linux-gnu/libgfortran.so.3.0.0
7fdbd59ab000-7fdbd59ad000 rw-p 00129000 fc:05 12849959                   /usr/lib/x86_64-linux-gnu/libgfortran.so.3.0.0
7fdbd59cd000-7fdbd7c8b000 r-xp 00000000 fc:05 10120848                   /home/ferris/julia-0.6/usr/lib/libopenblas64_.so
7fdbd7c8b000-7fdbd7e8a000 ---p 022be000 fc:05 10120848                   /home/ferris/julia-0.6/usr/lib/libopenblas64_.so
7fdbd7e8a000-7fdbd7e90000 r--p 022bd000 fc:05 10120848                   /home/ferris/julia-0.6/usr/lib/libopenblas64_.so
7fdbd7e90000-7fdbd7eaa000 rw-p 022c3000 fc:05 10120848                   /home/ferris/julia-0.6/usr/lib/libopenblas64_.so
7fdbd7eaa000-7fdbd7f0a000 rw-p 00000000 00:00 0 
7fdbd7f0a000-7fdbd7f0d000 r-xp 00000000 fc:05 10118665                   /home/ferris/julia-0.6/usr/lib/libdSFMT.so
7fdbd7f0d000-7fdbd810c000 ---p 00003000 fc:05 10118665                   /home/ferris/julia-0.6/usr/lib/libdSFMT.so
7fdbd810c000-7fdbd810d000 r--p 00002000 fc:05 10118665                   /home/ferris/julia-0.6/usr/lib/libdSFMT.so
7fdbd810d000-7fdbd810e000 rw-p 00003000 fc:05 10118665                   /home/ferris/julia-0.6/usr/lib/libdSFMT.so
7fdbd810e000-7fdbd816f000 r-xp 00000000 fc:05 10119187                   /home/ferris/julia-0.6/usr/lib/libmpfr.so.4.1.5
7fdbd816f000-7fdbd836e000 ---p 00061000 fc:05 10119187                   /home/ferris/julia-0.6/usr/lib/libmpfr.so.4.1.5
7fdbd836e000-7fdbd8370000 r--p 00060000 fc:05 10119187                   /home/ferris/julia-0.6/usr/lib/libmpfr.so.4.1.5
7fdbd8370000-7fdbd8371000 rw-p 00062000 fc:05 10119187                   /home/ferris/julia-0.6/usr/lib/libmpfr.so.4.1.5
7fdbd8371000-7fdbd83e6000 r-xp 00000000 fc:05 10118951                   /home/ferris/julia-0.6/usr/lib/libgmp.so.10.3.2
7fdbd83e6000-7fdbd85e5000 ---p 00075000 fc:05 10118951                   /home/ferris/julia-0.6/usr/lib/libgmp.so.10.3.2
7fdbd85e5000-7fdbd85e6000 r--p 00074000 fc:05 10118951                   /home/ferris/julia-0.6/usr/lib/libgmp.so.10.3.2
7fdbd85e6000-7fdbd85e7000 rw-p 00075000 fc:05 10118951                   /home/ferris/julia-0.6/usr/lib/libgmp.so.10.3.2
7fdbd85e7000-7fdbd86e7000 rw-p 00000000 00:00 0 
7fdbd86e7000-7fdbd8767000 r-xp 00000000 fc:05 10118933                   /home/ferris/julia-0.6/usr/lib/libpcre2-8.so.0.5.0
7fdbd8767000-7fdbd8966000 ---p 00080000 fc:05 10118933                   /home/ferris/julia-0.6/usr/lib/libpcre2-8.so.0.5.0
7fdbd8966000-7fdbd8967000 r--p 0007f000 fc:05 10118933                   /home/ferris/julia-0.6/usr/lib/libpcre2-8.so.0.5.0
7fdbd8967000-7fdbd8968000 rw-p 00080000 fc:05 10118933                   /home/ferris/julia-0.6/usr/lib/libpcre2-8.so.0.5.0
7fdbd8968000-7fdbd9665000 rw-p 00000000 00:00 0 
7fdbd9665000-7fdbdd669000 rw-p 00000000 00:00 0 
7fdbdd669000-7fdbdd66a000 ---p 00000000 00:00 0 
7fdbdd66a000-7fdbdde6a000 rw-p 00000000 00:00 0 
7fdbdde6a000-7fdbdfda4000 r-xp 00000000 fc:05 10120254                   /home/ferris/julia-0.6/usr/lib/julia/sys.so
7fdbdfda4000-7fdbdffa4000 ---p 01f3a000 fc:05 10120254                   /home/ferris/julia-0.6/usr/lib/julia/sys.so
7fdbdffa4000-7fdbdfffe000 r--p 01f3a000 fc:05 10120254                   /home/ferris/julia-0.6/usr/lib/julia/sys.so
7fdbdfffe000-7fdbdffff000 rw-p 01f94000 fc:05 10120254                   /home/ferris/julia-0.6/usr/lib/julia/sys.so
7fdbdffff000-7fdbe0027000 rw-p 00000000 00:00 0 
7fdbe0027000-7fdbe0028000 ---p 00000000 00:00 0 
7fdbe0028000-7fdbe0828000 rw-p 00000000 00:00 0 
7fdbe0828000-7fdbe0b00000 r--p 00000000 fc:05 12845269                   /usr/lib/locale/locale-archive
7fdbe0b00000-7fdbe0b19000 r-xp 00000000 fc:05 9437571                    /lib/x86_64-linux-gnu/libz.so.1.2.8
7fdbe0b19000-7fdbe0d18000 ---p 00019000 fc:05 9437571                    /lib/x86_64-linux-gnu/libz.so.1.2.8
7fdbe0d18000-7fdbe0d19000 r--p 00018000 fc:05 9437571                    /lib/x86_64-linux-gnu/libz.so.1.2.8
7fdbe0d19000-7fdbe0d1a000 rw-p 00019000 fc:05 9437571                    /lib/x86_64-linux-gnu/libz.so.1.2.8
7fdbe0d1a000-7fdbe0d30000 r-xp 00000000 fc:05 9441712                    /lib/x86_64-linux-gnu/libgcc_s.so.1
7fdbe0d30000-7fdbe0f2f000 ---p 00016000 fc:05 9441712                    /lib/x86_64-linux-gnu/libgcc_s.so.1
7fdbe0f2f000-7fdbe0f30000 rw-p 00015000 fc:05 9441712                    /lib/x86_64-linux-gnu/libgcc_s.so.1
7fdbe0f30000-7fdbe1038000 r-xp 00000000 fc:05 9447363                    /lib/x86_64-linux-gnu/libm-2.23.so
7fdbe1038000-7fdbe1237000 ---p 00108000 fc:05 9447363                    /lib/x86_64-linux-gnu/libm-2.23.so
7fdbe1237000-7fdbe1238000 r--p 00107000 fc:05 9447363                    /lib/x86_64-linux-gnu/libm-2.23.so
7fdbe1238000-7fdbe1239000 rw-p 00108000 fc:05 9447363                    /lib/x86_64-linux-gnu/libm-2.23.so
7fdbe1239000-7fdbe13ab000 r-xp 00000000 fc:05 12845454                   /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.21
7fdbe13ab000-7fdbe15ab000 ---p 00172000 fc:05 12845454                   /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.21
7fdbe15ab000-7fdbe15b5000 r--p 00172000 fc:05 12845454                   /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.21
7fdbe15b5000-7fdbe15b7000 rw-p 0017c000 fc:05 12845454                   /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.21
7fdbe15b7000-7fdbe15bb000 rw-p 00000000 00:00 0 
7fdbe15bb000-7fdbe307a000 r-xp 00000000 fc:05 10117732                   /home/ferris/julia-0.6/usr/lib/libLLVM-3.9.so
7fdbe307a000-7fdbe3279000 ---p 01abf000 fc:05 10117732                   /home/ferris/julia-0.6/usr/lib/libLLVM-3.9.so
7fdbe3279000-7fdbe33c4000 r--p 01abe000 fc:05 10117732                   /home/ferris/julia-0.6/usr/lib/libLLVM-3.9.so
7fdbe33c4000-7fdbe33da000 rw-p 01c09000 fc:05 10117732                   /home/ferris/julia-0.6/usr/lib/libLLVM-3.9.so
7fdbe33da000-7fdbe3404000 rw-p 00000000 00:00 0 
7fdbe3404000-7fdbe35c4000 r-xp 00000000 fc:05 9447368                    /lib/x86_64-linux-gnu/libc-2.23.so
7fdbe35c4000-7fdbe37c4000 ---p 001c0000 fc:05 9447368                    /lib/x86_64-linux-gnu/libc-2.23.so
7fdbe37c4000-7fdbe37c8000 r--p 001c0000 fc:05 9447368                    /lib/x86_64-linux-gnu/libc-2.23.so
7fdbe37c8000-7fdbe37ca000 rw-p 001c4000 fc:05 9447368                    /lib/x86_64-linux-gnu/libc-2.23.so
7fdbe37ca000-7fdbe37ce000 rw-p 00000000 00:00 0 
7fdbe37ce000-7fdbe37e6000 r-xp 00000000 fc:05 9447351                    /lib/x86_64-linux-gnu/libpthread-2.23.so
7fdbe37e6000-7fdbe39e5000 ---p 00018000 fc:05 9447351                    /lib/x86_64-linux-gnu/libpthread-2.23.so
7fdbe39e5000-7fdbe39e6000 r--p 00017000 fc:05 9447351                    /lib/x86_64-linux-gnu/libpthread-2.23.so
7fdbe39e6000-7fdbe39e7000 rw-p 00018000 fc:05 9447351                    /lib/x86_64-linux-gnu/libpthread-2.23.so
7fdbe39e7000-7fdbe39eb000 rw-p 00000000 00:00 0 
7fdbe39eb000-7fdbe39f2000 r-xp 00000000 fc:05 9447354                    /lib/x86_64-linux-gnu/librt-2.23.so
7fdbe39f2000-7fdbe3bf1000 ---p 00007000 fc:05 9447354                    /lib/x86_64-linux-gnu/librt-2.23.so
7fdbe3bf1000-7fdbe3bf2000 r--p 00006000 fc:05 9447354                    /lib/x86_64-linux-gnu/librt-2.23.so
7fdbe3bf2000-7fdbe3bf3000 rw-p 00007000 fc:05 9447354                    /lib/x86_64-linux-gnu/librt-2.23.so
7fdbe3bf3000-7fdbe3bf6000 r-xp 00000000 fc:05 9447357                    /lib/x86_64-linux-gnu/libdl-2.23.so
7fdbe3bf6000-7fdbe3df5000 ---p 00003000 fc:05 9447357                    /lib/x86_64-linux-gnu/libdl-2.23.so
7fdbe3df5000-7fdbe3df6000 r--p 00002000 fc:05 9447357                    /lib/x86_64-linux-gnu/libdl-2.23.so
7fdbe3df6000-7fdbe3df7000 rw-p 00003000 fc:05 9447357                    /lib/x86_64-linux-gnu/libdl-2.23.so
7fdbe3df7000-7fdbe3fca000 r-xp 00000000 fc:05 10117689                   /home/ferris/julia-0.6/usr/lib/libjulia.so.0.6.0
7fdbe3fca000-7fdbe41ca000 ---p 001d3000 fc:05 10117689                   /home/ferris/julia-0.6/usr/lib/libjulia.so.0.6.0
7fdbe41ca000-7fdbe41cd000 r--p 001d3000 fc:05 10117689                   /home/ferris/julia-0.6/usr/lib/libjulia.so.0.6.0
7fdbe41cd000-7fdbe420e000 rw-p 001d6000 fc:05 10117689                   /home/ferris/julia-0.6/usr/lib/libjulia.so.0.6.0
7fdbe420e000-7fdbe44fb000 rw-p 00000000 00:00 0 
7fdbe44fb000-7fdbe4521000 r-xp 00000000 fc:05 9447346                    /lib/x86_64-linux-gnu/ld-2.23.so
7fdbe4540000-7fdbe46fe000 rw-p 00000000 00:00 0 
7fdbe4709000-7fdbe470a000 rw-p 00000000 00:00 0 
7fdbe470a000-7fdbe471a000 rwxp 00000000 00:00 0 
7fdbe471a000-7fdbe471b000 r--p 00000000 fc:05 927527                     /usr/share/locale-langpack/en_AU/LC_MESSAGES/libc.mo
7fdbe471b000-7fdbe471e000 r--p 00000000 00:00 0 
7fdbe471e000-7fdbe4720000 rw-p 00000000 00:00 0 
7fdbe4720000-7fdbe4721000 r--p 00025000 fc:05 9447346                    /lib/x86_64-linux-gnu/ld-2.23.so
7fdbe4721000-7fdbe4722000 rw-p 00026000 fc:05 9447346                    /lib/x86_64-linux-gnu/ld-2.23.so
7fdbe4722000-7fdbe4723000 rw-p 00000000 00:00 0 
7ffe93b60000-7ffe93d30000 rw-p 00000000 00:00 0                          [stack]
7ffe93d7c000-7ffe93d7e000 r--p 00000000 00:00 0                          [vvar]
7ffe93d7e000-7ffe93d80000 r-xp 00000000 00:00 0                          [vdso]
ffffffffff600000-ffffffffff601000 r-xp 00000000 00:00 0                  [vsyscall]

signal (6): Aborted
while loading no file, in expression starting on line 0
raise at /build/glibc-bfm8X4/glibc-2.23/signal/../sysdeps/unix/sysv/linux/raise.c:54
abort at /build/glibc-bfm8X4/glibc-2.23/stdlib/abort.c:89
__libc_message at /build/glibc-bfm8X4/glibc-2.23/libio/../sysdeps/posix/libc_fatal.c:175
malloc_printerr at /build/glibc-bfm8X4/glibc-2.23/malloc/malloc.c:5006 [inlined]
_int_free at /build/glibc-bfm8X4/glibc-2.23/malloc/malloc.c:3867
__libc_free at /build/glibc-bfm8X4/glibc-2.23/malloc/malloc.c:2968
xmlFreeNodeList at /usr/lib/x86_64-linux-gnu/libxml2.so.2 (unknown line)
xmlFreeNode at /usr/lib/x86_64-linux-gnu/libxml2.so.2 (unknown line)
finalize_node at /home/ferris/.julia/v0.6/EzXML/src/node.jl:323
unknown function (ip: 0x7fdbc1de2ae2)
jl_call_fptr_internal at /home/ferris/julia-0.6/src/julia_internal.h:339 [inlined]
jl_call_method_internal at /home/ferris/julia-0.6/src/julia_internal.h:358 [inlined]
jl_apply_generic at /home/ferris/julia-0.6/src/gf.c:1933
jl_apply at /home/ferris/julia-0.6/src/julia.h:1424 [inlined]
run_finalizer at /home/ferris/julia-0.6/src/gc.c:111
jl_gc_run_finalizers_in_list at /home/ferris/julia-0.6/src/gc.c:200
run_finalizers at /home/ferris/julia-0.6/src/gc.c:234 [inlined]
jl_gc_run_all_finalizers at /home/ferris/julia-0.6/src/gc.c:276
jl_atexit_hook at /home/ferris/julia-0.6/src/init.c:265
jl_exit at /home/ferris/julia-0.6/src/jl_uv.c:551
exit at ./initdefs.jl:22
unknown function (ip: 0x7fdbde2e5f28)
jl_call_fptr_internal at /home/ferris/julia-0.6/src/julia_internal.h:339 [inlined]
jl_call_method_internal at /home/ferris/julia-0.6/src/julia_internal.h:358 [inlined]
jl_apply_generic at /home/ferris/julia-0.6/src/gf.c:1933
do_call at /home/ferris/julia-0.6/src/interpreter.c:75
eval at /home/ferris/julia-0.6/src/interpreter.c:242
jl_interpret_toplevel_expr at /home/ferris/julia-0.6/src/interpreter.c:34
jl_toplevel_eval_flex at /home/ferris/julia-0.6/src/toplevel.c:577
jl_toplevel_eval_in at /home/ferris/julia-0.6/src/builtins.c:496
eval at ./boot.jl:235
unknown function (ip: 0x7fdbde0db6ef)
jl_call_fptr_internal at /home/ferris/julia-0.6/src/julia_internal.h:339 [inlined]
jl_call_method_internal at /home/ferris/julia-0.6/src/julia_internal.h:358 [inlined]
jl_apply_generic at /home/ferris/julia-0.6/src/gf.c:1933
eval_user_input at ./REPL.jl:66
unknown function (ip: 0x7fdbde14985f)
jl_call_fptr_internal at /home/ferris/julia-0.6/src/julia_internal.h:339 [inlined]
jl_call_method_internal at /home/ferris/julia-0.6/src/julia_internal.h:358 [inlined]
jl_apply_generic at /home/ferris/julia-0.6/src/gf.c:1933
macro expansion at ./REPL.jl:97 [inlined]
#1 at ./event.jl:73
unknown function (ip: 0x7fdbc1dd82af)
jl_call_fptr_internal at /home/ferris/julia-0.6/src/julia_internal.h:339 [inlined]
jl_call_method_internal at /home/ferris/julia-0.6/src/julia_internal.h:358 [inlined]
jl_apply_generic at /home/ferris/julia-0.6/src/gf.c:1933
jl_apply at /home/ferris/julia-0.6/src/julia.h:1424 [inlined]
start_task at /home/ferris/julia-0.6/src/task.c:267
unknown function (ip: 0xffffffffffffffff)
Allocations: 1574356 (Pool: 1573174; Big: 1182); GC: 0
Aborted (core dumped)
@bicycle1885
Copy link
Member

Thank you for reporting. I think this is a bug of ExXML.jl and may have found the reason. So, I'll fix that soon.

Below is a note for myself.

function unlink!(node::Node)
    @show unsafe_load(convert(Ptr{_Element}, node.ptr)).name
    ccall(
        (:xmlUnlinkNode, libxml2),
        Void,
        (Ptr{Void},),
        node.ptr)
    update_owners!(node, node)
    # Unlinking must remove documents as well because
    # a node can free resources its document owns.
    unset_documents!(node)
    return node
end

bug.jl

using EzXML

# This results in SIGABRT.
xmldoc = readxml("X.xml")
nodes = find(xmldoc, "X")
unlink!(nodes[1])

X.xml

<?xml version="1.0" encoding="UTF-8"?>
<X/>
~/.j/v/EzXML ((v0.5.0)|✚1…) $ julia bug.jl
unsafe_load(convert(Ptr{_Element}, node.ptr)).name = Cstring(0x00007f8bea1b7057)
julia(38822,0x7fffc20e13c0) malloc: *** error for object 0x7f8bea1b7057: pointer being freed was not allocated
*** set a breakpoint in malloc_error_break to debug

signal (6): Abort trap: 6
while loading no file, in expression starting on line 0
__pthread_kill at /usr/lib/system/libsystem_kernel.dylib (unknown line)
Allocations: 984957 (Pool: 983841; Big: 1116); GC: 0
fish: 'julia bug.jl' terminated by signal SIGABRT (Abort)

Loading an XML document from a file fills the .name field to each node to indicate the file name. So, I need to remove the .name fields under the node.

@andyferris
Copy link
Author

Thanks for the quick response!

@bicycle1885
Copy link
Member

Try v0.5.1 once it is registered in METADATA (or check out the tag).

@andyferris
Copy link
Author

Awesome, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants