Re: [xml] [Bug 143739] - incorrect line numbers in well-formedness error message

On Thu, Jul 01, 2004 at 06:58:09PM -0500, R. Steven Rainwater wrote:
My problem is that after upgrading from libxml2 v2.5.x to v.2.6.9
recently, we lost the ability to display the line number of
well-formedness errors. Prior to the upgrade the error messages appeared
in this form:

Well-formedness Error [line 29664810]: Char 0xD96B out of allowed

Now all error messages display the same, incorrect line number:

Well-formedness Error [line 65535]: Char 0xD96B out of allowed range

Daniel said this was due to a change in the code that now restricts the
line number to a small int. So features of libxml2 that rely on line
numbers don't work on large files anymore. It sounds like there's no
general solution to this problem without breaking the new node
structure. But in an email Daniel suggested there might be a fix that
would work in reader-based programs (like mine):

  Do you use specific error reporting mechanism ?
I made a breakpoint in xmllint --stream broken_xml_file.xml
in the __xmlRaiseError() function which acts as a central point for
error dispatching in the recent versions of the library, and it
indeed gather the line and filename used for error reporting
from the parser context, and should get an 32bit int value:

484         if (ctxt != NULL) {
485             if (file == NULL) {
486                 input = ctxt->input;
487                 if ((input != NULL) && (input->filename == NULL) &&
491                 if (input != NULL) {
492                     file = input->filename;
493                     line = input->line;

then it stores the context errors with full informations:

496             to = &ctxt->lastError;
(gdb) n
517         xmlResetError(to);
518         to->domain = domain;
519         to->code = code;
520         to->message = str;
521         to->level = level;
522         if (file != NULL)
523             to->file = (char *) xmlStrdup((const xmlChar *) file);
528         to->line = line;

and store them in the global variable xmlLastError too.

So it seems to me that if you have 16bits truncated line numbers reported,
this is because your error handling routine tries to get them from
the node and not from the contextual or global error informations
And without any idea about your code, I don't think I can suggest anything
more at this point. But everything in the error reporting chain seems to
be 32bits by default. Try with xmllint --stream on one of your example
under a debugger and see too what's happening, but you should really have
32bit line numbers there.
The 16bits is a restriction of xmlGetLineNo() really...


Daniel Veillard      | Red Hat Desktop team
veillard redhat com  | libxml GNOME XML XSLT toolkit | Rpmfind RPM search engine

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]