After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 663588 - Dtd header built by libxml cannot be parsed by libxml
Dtd header built by libxml cannot be parsed by libxml
Status: RESOLVED FIXED
Product: libxml2
Classification: Platform
Component: general
2.7.8
Other Windows
: Normal normal
: ---
Assigned To: Daniel Veillard
libxml QA maintainers
Depends on:
Blocks:
 
 
Reported: 2011-11-07 21:03 UTC by Michael Cronenworth
Modified: 2012-05-10 03:41 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
dtd parse patch (428 bytes, patch)
2012-01-12 18:11 UTC, Michael Cronenworth
none Details | Review

Description Michael Cronenworth 2011-11-07 21:03:03 UTC
I called:
xmlNewDtd( doc, BAD_CAST "res", BAD_CAST "SYSTEM", BAD_CAST "res.dtd" );

which generates:
<!DOCTYPE res PUBLIC "SYSTEM" "res.dtd">

Under windows, xmllint parsing chokes on "SYSTEM" and says it is an error. Under Linux, no error is output and the parsing works fine.

test1.xml - xmllint parses fine under linux, errors under windows
<?xml version="1.0"?>
<!DOCTYPE res PUBLIC "SYSTEM" "res.dtd">
<res><version><foo>0.9.0</foo></version></res>

test2.xml - xmllint parses fine under linux and windows
<?xml version="1.0"?>
<res><version><foo>0.9.0</foo></version></res>

Error output on Windows:
S:\libxml2>xmllint.exe test1.xml

test1.xml:2: parser error : Unfinished System or Public ID " or ' expected
<!DOCTYPE res PUBLIC "SYSTEM" "res.dtd">
                      ^
test1.xml:2: parser error : Space required after the Public Identifier
<!DOCTYPE res PUBLIC "SYSTEM" "res.dtd">
                      ^
test1.xml:2: parser error : SystemLiteral " or ' expected
<!DOCTYPE res PUBLIC "SYSTEM" "res.dtd">
                      ^
test1.xml:2: parser error : SYSTEM or PUBLIC, the URI is missing
<!DOCTYPE res PUBLIC "SYSTEM" "res.dtd">
                      ^
test1.xml:2: parser error : DOCTYPE improperly terminated
<!DOCTYPE res PUBLIC "SYSTEM" "res.dtd">
                      ^
test1.xml:2: parser error : Start tag expected, '<' not found
<!DOCTYPE res PUBLIC "SYSTEM" "res.dtd">
Comment 1 Erik van Pienbroek 2011-11-07 21:15:47 UTC
Additional info:
This issue occurs when libxml2 is compiled for the win32 target using the mingw.org toolchain (which is in Fedora) and for the win32+win64 targets when using the mingw-w64 toolchain. All these targets suffer from this issue.

Small detail: libxml2 is built using win32 threads instead of pthreads.

The native (Fedora) linux version of xmllint doesn't give any parser errors on this xml document
Comment 2 Michael Cronenworth 2011-12-20 18:07:18 UTC
The problem is the compiler. Compiling libxml2 with -O0 allows parsing to work successfully.

The problem block of code is in the xmlParsePubidLiteral() function. The while() loop is being optimized poorly by the MinGW compilers.
Comment 3 Michael Cronenworth 2012-01-12 18:11:24 UTC
Created attachment 205122 [details] [review]
dtd parse patch

Ends up that this is a bug (Windows only).

The attached patch fixes this issue. (was from bug 561340)
Comment 4 Daniel Veillard 2012-05-10 03:41:32 UTC
Okay, the patch lacks context since the modified block appears multiple time
in the given file, but based on line number and description this really looks
like it should be applied to the part labelled

/* Windows platform with GNU compiler (Mingw) */
#if defined(_WIN32) && defined(__MINGW32__)

This modifies only the export for data, not for library entry points, so
the impact sounds limited, I'm willing to try this, so I'm applying to git
head and I will warn people to test it on the candidate release, based on
feedback I will keep that patch or fix things accordingly,

http://git.gnome.org/browse/libxml2/commit/?id=1eabc31401b7b8c3b5273993778f37eeef37a055

  thanks for researching the issue !

Daniel