-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
XML::Node#to_s truncates large files #4710
Comments
Not a dev,but figured I'll try to help. What crystal version and hardware are you on? I'm not reproducing this on 0.23.0 (or my oldest available version, 0.20.5). |
Hi @bmmcginty - thanks!
I also noticed that the compiler bombs when I try to build the above test script with --release:
Let me know if there's anything else I can help with! |
Just tried with that exact revision of crystal, so I suspect it's your LLVM version. What distro are you running? Maybe possible to upgrade llvm? If not, and you can give me the info on your distro, I can try and spin up a cloud VM and see what I can do to assist...though I'm not sure exactly what yet. |
Thanks! I'm away from my computer right now but it's Ubuntu 17.04 (x86_64), fully patched every day. |
@bmmcginty Just looking at it now - looks like my Crystal binary (from the official Crystal Ubuntu repo) is statically linked against LLVM 3.8.1, but my distro does have 4.0 installed. |
@pedantic-git I can't reproduce this. Is there any chance you can show us the output of that |
@asterite Huh - funny that you can't reproduce it with the EnragedBull.svg file. Since filing this I've got a new workstation and I've changed my distro from Ubuntu to Arch but the issue still manifests in the same way! Here are some links: |
I'm trying this on OSX, so it might be an issue only in linux. I'll try with docker. |
Thanks! I suspect it's somewhere in the interface with the underlying LibXML so it wouldn't surprise me if it was OS-specific. |
@pedantic-git I just tried it in docker and it worked fine. What OS are you using? |
@asterite I'm using Arch Linux but the same thing happened on Ubuntu. Try this Dockerfile: FROM base/devel
RUN pacman -Sy --noconfirm crystal libxml2
WORKDIR /tmp
ADD EnragedBull.svg test.cr /tmp/
RUN bash -c "crystal test.cr > output.svg"
CMD ls -lh For me when that's run it outputs:
|
No idea why you are getting different results... Could be #2713 . What if you write that string to a file, from inside Crystal? Using |
Same problem for me (originally I experienced this in a Kemal app). test.cr: require "xml"
f = File.open "EnragedBull.svg"
xml = XML.parse(f)
File.write "output.svg", xml.to_s Dockerfile: FROM base/devel
RUN pacman -Sy --noconfirm crystal libxml2
WORKDIR /tmp
ADD EnragedBull.svg test.cr /tmp/
RUN crystal test.cr
CMD ls -lh In a shell:
Could it be a difference between running Docker on a Linux kernel vs a Darwin kernel? Seems pretty unlikely! I would be inclined to blame my hardware but this is a new workstation since the bug was originally filed (they were both XPS13s with i7 processors, but 2 years apart). |
I can reproduce:
|
Even with writing in crystal! require "xml"
f = File.open "EnragedBull.svg"
xml = XML.parse(f)
File.write("test.xml", xml.to_s)
|
Considering me and @asterite have exactly the same Just as a sanity check, here's the sha1 of my EnragedBull.svg: |
@RX14 But outside docker it works fine? |
I know Docker on Mac no longer needs VirtualBox to run so perhaps it uses some more advanced Mac virtualization rather than a Linux kernel these days. I'm just trying it out on the official Docker VM using docker-machine - will report back shortly. |
Yep - same problem on the official Docker VM:
|
@asterite no, it's reproducible outside the container. |
Then you can try to debug it, if you want and have time. The code is here: https://github.com/crystal-lang/crystal/blob/master/src/xml/node.cr#L424-L453 Maybe inspecting the values of these will be helpful: https://github.com/crystal-lang/crystal/blob/master/src/xml/node.cr#L434 |
Unable to repro with
Maybe it was some now-fixed flushing issue or something... |
I suppose we can close this then. |
Hi Crystal devs! Thanks for fixing my earlier XML issue so quickly. I'm afraid I have another one.
It seems like the
XML::Node#to_s
truncates very large files, in my case at around 1.2MB.Try this:
(you can get the EnragedBull.svg here: https://openclipart.org/download/282790/EnragedBull.svg )
The file, which is 2.2MB to begin with, is cut short around 1.2MB.
I had a cursory look at the code but since it's making calls into LibXML I'm afraid I'm at a loss to fix it myself.
The text was updated successfully, but these errors were encountered: