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 562541 - "internal error, xpointer.c:2409" when using string-range()
"internal error, xpointer.c:2409" when using string-range()
Status: RESOLVED OBSOLETE
Product: libxml2
Classification: Platform
Component: xpointer
2.7.6
Other All
: Normal minor
: ---
Assigned To: Daniel Veillard
libxml QA maintainers
Depends on:
Blocks:
 
 
Reported: 2008-11-28 09:54 UTC by Piotr Banski
Modified: 2021-07-05 13:20 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
test case (631 bytes, application/octet-stream)
2010-05-31 14:53 UTC, Piotr Banski
Details

Description Piotr Banski 2008-11-28 09:54:16 UTC
Please describe the problem:
I get the message "Internal error at /usr/.../libxml2-2.6.32/xpointer.c:2409" under both libxml 2.6.32 (Cygwin) and 2.7.2 (win32), when processing string-range() in some cases. It doesn't seem to interfere with the results, it just pops up.



Steps to reproduce:
source.xml:

<?xml version="1.0" encoding="UTF-8"?>
<div><p>To make a prairie it takes a clover and one bee,
One clover, and a bee,
And revery.
The revery alone will do,
If bees are few</p></div>

include.xml:

<?xml version="1.0" encoding="UTF-8"?>
<body><p><xi:include  xmlns:xi="http://www.w3.org/2003/XInclude" href="source.xml" xpointer="xpointer(string-range(/div/p,'',1,47)[1])"/></p>
    <p><xi:include xmlns:xi="http://www.w3.org/2003/XInclude" href="source.xml" xpointer="xpointer(string-range(/div/p,'',50,22)[1])"/></p>
    <p><xi:include xmlns:xi="http://www.w3.org/2003/XInclude" href="source.xml" xpointer="xpointer(string-range(/div/p,'',73,11)[1])"/></p></body> 

(note: the first argument to string-range() can be just "/div" or "/" -- there is no change of behaviour; note that the error is produced by processing p[2] and p[3])

Actual results:
$ xmllint --xinclude --debug include.xml
Internal error at
/usr/src/ports/libs/libxml2/libxml2-2.6.32-2/src/libxml2-2.6.32/xpointer.c:2409
Internal error at
/usr/src/ports/libs/libxml2/libxml2-2.6.32-2/src/libxml2-2.6.32/xpointer.c:2409
DOCUMENT
version=1.0
encoding=UTF-8
URL=include.xml
standalone=true
  ELEMENT body
    ELEMENT p
      INCLUDE START
      TEXT
        content=To make a prairie it takes a clover and ...
      INCLUDE END
    TEXT compact
      content=     
    ELEMENT p
      INCLUDE START
      TEXT
        content=One clover, and a bee,
      INCLUDE END
    TEXT compact
      content=     
    ELEMENT p
      INCLUDE START
      TEXT
        content=And revery.
      INCLUDE END

Expected results:


Does this happen every time?
The error disappears in two cases: 
* when I comment out the two latter <p>s, or 
* when I put a designated character (e.g. &#160; = nbsp) at the the very beginning of the source.xml text, and match against it, as in:

<p><xi:include xmlns:xi="http://www.w3.org/2003/XInclude"
    href="source.xml"
    xpointer="xpointer(string-range(/div,'&#160;',3,48)[1])"/></p>

Other information:
The relevant fragment of the xpointer draft is at
http://www.w3.org/TR/xptr-xpointer/#stringrange
Comment 1 Piotr Banski 2009-11-13 15:00:30 UTC
The bug persists with the proper XInclude namespace and with 

$ xmllint --version
xmllint: using libxml version 20703
   compiled with: Threads Tree Output Push Reader Patterns Writer SAXv1 FTP HTTP
 DTDValid HTML Legacy C14N Catalog XPath XPointer XInclude Iconv ISO8859X Unicod
e Regexps Automata Expr Schemas Schematron Modules Debug Zlib

under Cygwin (libxml 2.7.3-1).
Comment 2 Piotr Banski 2010-05-31 14:53:10 UTC
Created attachment 162386 [details]
test case
Comment 3 Piotr Banski 2010-05-31 14:55:07 UTC
This time, I attach a test suite, so that whitespace is controlled for and things are easy to reproduce.

Again, it is p[2] and p[3] that cause the error message, so the way to get rid of the error message is to either comment them out, or to use a designated character as an anchor, which is demonstrated in files with the suffix "-2".

(Note below that the addition of the anchoring character makes the string to be included lengthen by one, from 47 to 48 characters -- which seems somewhat strange.)


$ xmllint --version
xmllint: using libxml version 20706
   compiled with: Threads Tree Output Push Reader Patterns Writer SAXv1 FTP HTTP DTDValid HTML Legacy C14N Catalog XPath XPointer XInclude Iconv ISO8859X Unicode Regexps Automata Expr Schemas Schematron Modules Debug Zlib


$ xmllint --xinclude include-error-msg.xml > output.xml                         Internal error at /usr/src/ports/libs/libxml2/libxml2-2.7.6-1/src/libxml2-2.7.6/xpointer.c:2418
Internal error at /usr/src/ports/libs/libxml2/libxml2-2.7.6-1/src/libxml2-2.7.6/xpointer.c:2418

$ cat output.xml
<?xml version="1.0" encoding="UTF8"?>
<body xmlns="http://example.org/">
  <p>To make a prairie it takes a clover and one bee,</p>
  <p>One clover, and a bee,</p>
  <p>And revery.</p>
</body>

$ cat include-error-msg.xml
<?xml version="1.0" encoding="UTF8"?>
<body xmlns="http://example.org/">
  <p><xi:include  xmlns:xi="http://www.w3.org/2001/XInclude" href="source.xml" xpointer="xmlns(ex=http://example.org/) xpointer(string-range(/ex:div/ex:p,'',1,47)[1])"/></p>
  <p><xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="source.xml" xpointer="xmlns(ex=http://example.org/) xpointer(string-range(/ex:div/ex:p,'',51,22)[1])"/></p>
  <p><xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="source.xml" xpointer="xmlns(ex=http://example.org/) xpointer(string-range(/ex:div/ex:p,'',75,11)[1])"/></p>
</body>

$ cat source.xml
<?xml version="1.0" encoding="UTF-8"?>
<div xmlns="http://example.org/">
<p>To make a prairie it takes a clover and one bee,
One clover, and a bee,
And revery.
The revery alone will do,
If bees are few.</p>
</div>

--------------- (the anchored version now)

$ xmllint --xinclude include-error-msg-2.xml > output-2.xml

$ cat output-2.xml
<?xml version="1.0" encoding="UTF8"?>
<body xmlns="http://example.org/">
  <p>To make a prairie it takes a clover and one bee</p>
  <p>One clover, and a bee,</p>
  <p>And revery.</p>
</body>

INCIDENTALLY, note that here, the 1st line lacks the comma, although, as you can see below, the number of characters scanned from position 3 is the same: 47 -- increasing this to 48 helps; weird?

$ cat include-error-msg-2.xml
<?xml version="1.0" encoding="UTF8"?>
<body xmlns="http://example.org/">
  <p><xi:include  xmlns:xi="http://www.w3.org/2001/XInclude" href="source-2.xml" xpointer="xmlns(ex=http://example.org/) xpointer(string-range(/ex:div/ex:p,'&#160;',3,47)[1])"/></p>
  <p><xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="source-2.xml" xpointer="xmlns(ex=http://example.org/) xpointer(string-range(/ex:div/ex:p,'&#160;',53,22)[1])"/></p>
  <p><xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="source-2.xml" xpointer="xmlns(ex=http://example.org/) xpointer(string-range(/ex:div/ex:p,'&#160;',77,11)[1])"/></p>
</body>

$ cat source-2.xml
<?xml version="1.0" encoding="UTF-8"?>
<div xmlns="http://example.org/">
<p>&#160;To make a prairie it takes a clover and one bee,
One clover, and a bee,
And revery.
The revery alone will do,
If bees are few.</p>
</div>
Comment 4 Piotr Banski 2010-05-31 21:58:33 UTC
The issue of changing the length of the first string from 47 to 48 (the latter being the proper value) may be orthogonal to this case and is the topic of bug #620190.
Comment 5 GNOME Infrastructure Team 2021-07-05 13:20:58 UTC
GNOME is going to shut down bugzilla.gnome.org in favor of gitlab.gnome.org.
As part of that, we are mass-closing older open tickets in bugzilla.gnome.org
which have not seen updates for a longer time (resources are unfortunately
quite limited so not every ticket can get handled).

If you can still reproduce the situation described in this ticket in a recent
and supported software version, then please follow
  https://wiki.gnome.org/GettingInTouch/BugReportingGuidelines
and create a new ticket at
  https://gitlab.gnome.org/GNOME/libxml2/-/issues/

Thank you for your understanding and your help.