GNOME Bugzilla – Bug 602531
apparent corruption of global variable value in a specific case
Last modified: 2016-07-07 16:04:07 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.
I'm pretty sure I'm having the same trouble... a global variable has mysteriously become empty. :-(
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
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.
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.
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.
Fixed with the following commit: https://git.gnome.org/browse/libxslt/commit/?id=470b17346163ba3deceb29eb4149ae140b595cdd
*** Bug 768511 has been marked as a duplicate of this bug. ***