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 602531 - apparent corruption of global variable value in a specific case
apparent corruption of global variable value in a specific case
Status: RESOLVED FIXED
Product: libxslt
Classification: Platform
Component: general
unspecified
Other Linux
: Normal normal
: ---
Assigned To: Daniel Veillard
libxml QA maintainers
: 768511 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2009-11-20 20:28 UTC by Peter Pawlowski
Modified: 2016-07-07 16:04 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Peter Pawlowski 2009-11-20 20:28:11 UTC
We seem to have discovered a strange bug in libxslt where the value of a 
global variable is being reported incorrectly as an empty string.

This occurs if you have a certain combination of global variables, 
template calls and functions returning result tree fragments.

Here is the output of the test case (just run it against itself), the 
libxslt version information, and the test case itself:

[dev3:pawlowski] ~/xsl/ext/bin [15:27 2009-11-20]
$ ./xsltproc test-case.xsl test-case.xsl 
assert 'success!' == ''

[dev3:pawlowski] ~/xsl/ext/bin [15:27 2009-11-20]
$ ./xsltproc --version
Using libxml 20706, libxslt 10126 and libexslt 815
xsltproc was compiled against libxml 20706, libxslt 10126 and libexslt 815
libxslt 10126 was compiled against libxml 20706
libexslt 815 was compiled against libxml 20706


=== our test case ===

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
  xmlns:xsl='http://www.w3.org/1999/XSL/Transform'
  xmlns:func='http://exslt.org/functions'
  xmlns:foo='http://foo.com/'
  extension-element-prefixes='func'
 >
<xsl:output method="text" />

<!-- $func-value should have the value 'success!' but instead reports an 
empty string -->
<xsl:variable name="func-value" select="foo:get-value()" />
<xsl:variable name="dummy-value" select="$func-value" />
<xsl:variable name="template-value">
   <xsl:call-template name="get-dummy" />
</xsl:variable>

<func:function name="foo:get-value">
   <func:result>success!</func:result>

   <!-- use this func:result instead and $func-value will report the 
expected value
   <func:result select="'success!'" />
   -->

</func:function>

<xsl:template name="get-dummy">
   <xsl:value-of select="$dummy-value" />
</xsl:template>

<xsl:template match="/">
   <xsl:text>assert 'success!' == '</xsl:text>
   <xsl:value-of select="$func-value" />
   <xsl:text>'
</xsl:text>
</xsl:template>

</xsl:stylesheet>

=== end test case ===


It seems obscure, but in our very complex, several thousand line XSL 
transformations, this actually comes up pretty frequently and is 
extremely frustrating to debug -- I hope you might be able to help us fix the problem.
Comment 1 docwhat 2009-11-24 16:35:26 UTC
I'm pretty sure I'm having the same trouble... a global variable has mysteriously become empty. :-(
Comment 2 Nick Wellnhofer 2009-12-29 18:26:19 UTC
I have a fix for this bug in my repository on github. See the following two commits:

http://github.com/nwellnhof/libxslt/commit/43f2cfbe1092ed69cb5bf97a23f0e6d824c9a615
http://github.com/nwellnhof/libxslt/commit/95a964e6981b60166870bf7ca152c2bfb547c60b
Comment 3 Peter Pawlowski 2010-01-20 15:44:20 UTC
Your patches appear to fix the problem, thanks so much!!! I patched libxslt-1.1.24 (that's the version we're currently using) and ran the test case and it succeeds.
Comment 4 Peter Pawlowski 2010-08-12 18:16:49 UTC
Nick: unfortunately the patches you provided seem to have caused a different bug to surface. I will attempt to isolate the bug so that I can describe it clearly.
Comment 5 Nick Wellnhofer 2016-04-20 10:38:24 UTC
I updated the branch, adding many improvements and reverting some changes that were too intrusive:

https://github.com/nwellnhof/libxslt/tree/rvt_memory_management

I tested it extensively and I'm pretty confident in the changes.
Comment 6 Nick Wellnhofer 2016-06-21 12:26:10 UTC
Fixed with the following commit:

https://git.gnome.org/browse/libxslt/commit/?id=470b17346163ba3deceb29eb4149ae140b595cdd
Comment 7 Nick Wellnhofer 2016-07-07 16:04:07 UTC
*** Bug 768511 has been marked as a duplicate of this bug. ***