Re: [xslt] Segmentation faults returning variable value from exslt functions II



Marc Adkins wrote:
> I have another example of segmentation faults when returning values from
> exslt functions.  Again, I can't give you a minimal test stylesheet
> (durn it), but this one has a slightly different configuration and the
> solution may be of interest.
>
> The function itself is a pretty straightforward substitute for the
> non-existent fn:lower-case() xpath function:
>
>     <func:function name="wpn:lowercase">
>         <xsl:param name="str" />
>         <func:result
> select="translate($str,$upper_alphabet,$lower_alphabet)" />
>     </func:function>
>
> In this case I was not able to modify the function itself so as to get
> rid of the segmentation fault.  Nothing worked.
>
> The original place where the segfault was happening was the line:
>
>     <xsl:variable name="lower" select="wpn:lowercase(string(.))" />
>
> The following modification removed the segfault:
>
>     <xsl:variable name="lower">
>         <xsl:value-of select="wpn:lowercase(string(.))" />
>     </xsl:variable>
>
> Interesting, neh?

Well, it's really not too interesting to try to make assumptions about
code taken out of context.  You are reporting that there is a failure
with the libxslt/libxml2 library, but the code that produces it is
something you can't tell us about.  That, of course, makes it rather
difficult to try to fix.

Taking what you have set down, I produced the following xslt file:

[bill bbsf work]$ cat bug1.xsl
<xsl:stylesheet version="1.0"
                xmlns:foo="http://foo.com/bar";
                xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
                xmlns:func="http://exslt.org/functions";
                extension-element-prefixes="func foo">

<xsl:variable name="upper" select="'ABCDE'"/>
<xsl:variable name="lower" select="'abcde'"/>
<func:function name="foo:myfunc">
        <xsl:param name="param"/>
        <func:result select="translate($param, $upper, $lower)"/>
</func:function>

<xsl:template match="/">
  <xsl:variable name="myvar" select="foo:myfunc('ABC')"/>
  <xsl:value-of select="$myvar"/>
</xsl:template>

</xsl:stylesheet>

Then, I ran that through the previously-released version of xsltproc (my
distro hasn't yet distributed the versions release a day or two ago):

[bill bbsf work]$ xsltproc --version
Using libxml 20628, libxslt 10120 and libexslt 813
xsltproc was compiled against libxml 20627, libxslt 10120 and libexslt 813
libxslt 10120 was compiled against libxml 20627
libexslt 813 was compiled against libxml 20627
[bill bbsf work]$ xsltproc bug1.xsl bug1.xsl
<?xml version="1.0"?>
abc
[bill bbsf work]$

No segfault.  And, just to make sure, I also ran that through Valgrind,
with similar result.  So, since you can't tell us anything more about
your code, can you at least give a hint as to how it differs from the
above?

>
> I have done some cursory code inspection.  All that bought me was the
> knowledge that cursory code inspection was insufficient.  Duh.
>
> I can duplicate this with xsltproc and our entire body of templates.  I
> would take a whack at debugging through at this point if I knew how to
> get started with the debugger with libxml/libxslt.  For example, are
> there debugging parameters to make?  Is there a web page giving hints on
> this?
>

Debugging is certainly not for the faint at heart, and for someone with
no previous experience at low-level tracing through both the libxslt and
libxml2 libraries would probably be a rather lengthy exercise.

> Thanks,
> Marc M. Adkins

Regards,
Bill



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