xmlstarlet-1.2.1 segfaults when running fo on empty files.
Steps to reproduce:
$ touch file
$ xmlstarlet fo file
Output:
file:1.1: Document is empty
^
zsh: segmentation fault ./xml fo file
Backtrace:
#0 0x00007ffff7719420 in xmlTextReaderGetParserLineNumber () from /usr/lib/libxml2.so.2
#1 0x000000000040571c in reportError (ptr=0x7ffff762a880, error=0x61d738) at src/xml.c:130
#2 0x00007ffff7665af4 in __xmlRaiseError () from /usr/lib/libxml2.so.2
#3 0x00007ffff7669b81 in ?? () from /usr/lib/libxml2.so.2
#4 0x00007ffff76804c6 in xmlParseDocument () from /usr/lib/libxml2.so.2
#5 0x00007ffff7680955 in ?? () from /usr/lib/libxml2.so.2
#6 0x000000000040bab0 in foProcess (ops=0x619fe0, start=2, argc=3, argv=0x7fffffffe868) at src/xml_format.c:328
#7 0x000000000040bcca in foMain (argc=3, argv=0x7fffffffe868) at src/xml_format.c:413
#8 0x0000000000405cc3 in main (argc=3, argv=0x7fffffffe868) at src/xml.c:221
I'm unable to reproduce this. Can you post the output from xmlstarlet --version?
View and moderate all "bugs Discussion" comments posted by this user
Mark all as spam, and block user from posting to "Bugs"
$ ./xmlstarlet --version
1.2.1
compiled against libxml2 2.7.8, linked with 20708
compiled against libxslt 1.1.26, linked with 10126
Hmm, I don't understand how this is possible. Maybe some detail of ./configure arguments of xmlstarlet and libxml2, and OS/platform...
View and moderate all "bugs Discussion" comments posted by this user
Mark all as spam, and block user from posting to "Bugs"
Fwiw, I got a friend to reproduce the bug. We both use Debian. This is just to say that this is not supposed to be some particularly exotic config, though I agree this might indicate a downstream problem with libxml2 for instance. (For xmlstarlet itself, I tested on a version compiled from source, not on the Debian packaged version.)
Is there anything I could you to help you identify what's going on?
Argh, I was using the git version of libxml, I don't know why I didn't think to check that before.
So it is a bug in libxml, but easy enough to work around;
fixed in b6f011dcdddfb13ea082bf8f3dcb27a2dc868d34
View and moderate all "bugs Discussion" comments posted by this user
Mark all as spam, and block user from posting to "Bugs"
I take it that the libxml bug is known (it would be good to report it otherwise, I guess). In any case, your commit fixed the problem for me. Thanks a lot!
Yes, it is a known bug, it is fixed in the git version of libxml which is why I had trouble reproducing this crash at first.
View and moderate all "bugs Discussion" comments posted by this user
Mark all as spam, and block user from posting to "Bugs"
Yeah, I realized just after posting that you already answered my question. Everything's fine then--thanks again for the quick fix!