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

link! and unlink! in a loop of eachelement #168

Open
guo-yong-zhi opened this issue Dec 15, 2021 · 1 comment
Open

link! and unlink! in a loop of eachelement #168

guo-yong-zhi opened this issue Dec 15, 2021 · 1 comment

Comments

@guo-yong-zhi
Copy link

I have a function to stack SVG images together. it is

function svg_stack(svgs::AbstractVector)
    @assert !isempty(svgs)
    bg, rest = Iterators.peel(svgs)
    rt = root(bg|>string|>parsexml)
    for svg in rest
        for c in collect(eachelement(root(svg|>string|>parsexml)))
            unlink!(c)
            link!(rt, c)
        end
    end
    string(rt)
end

You can think of the svg as a xml string.
When I removed the collect before the eachelement, some elements are missed. It seems that the second and subsequent elements have never been traversed due to the existence of unlink!.
When I kept the collect before the eachelement, however, a segmentation fault occurred occasionally. Like this one:

signal (11): Segmentation fault
in expression starting at /home/runner/work/WordCloud.jl/WordCloud.jl/test/runtests.jl:9
unknown function (ip: 0x7f3954feb6a7)
xmlOutputBufferWriteString__internal_alias at /workspace/srcdir/libxml2-2.9.10/xmlIO.c:3653
xmlNodeDumpOutputInternal at /workspace/srcdir/libxml2-2.9.10/xmlsave.c:1042
xmlNodeListDumpOutput at /workspace/srcdir/libxml2-2.9.10/xmlsave.c:820
xmlNodeDumpOutputInternal at /workspace/srcdir/libxml2-2.9.10/xmlsave.c:1069
xmlNodeDumpOutput__internal_alias at /workspace/srcdir/libxml2-2.9.10/xmlsave.c:2377
xmlBufNodeDump__internal_alias at /workspace/srcdir/libxml2-2.9.10/xmlsave.c:2271
xmlNodeDump__internal_alias at /workspace/srcdir/libxml2-2.9.10/xmlsave.c:2207
macro expansion at /home/runner/.julia/packages/EzXML/ZNwhK/src/error.jl:50 [inlined]
dump_node at /home/runner/.julia/packages/EzXML/ZNwhK/src/node.jl:335
print at /home/runner/.julia/packages/EzXML/ZNwhK/src/node.jl:310
print_to_string at ./strings/io.jl:135
string at ./strings/io.jl:174 [inlined]
svg_stack at /home/runner/work/WordCloud.jl/WordCloud.jl/src/svg.jl:82

Did I miss anything? What is the right way to use them? Or is this a bug?

@BenjaminGalliot
Copy link

Maybe related to this old bug

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