Project

Profile

Help

Saxon-HE 9.8.0-3 Tail Calls

Added by Vladimir Nesterovsky 3 months ago

We're getting an error like this with Saxon-HE 9.8.0-3:

err:SXLM0001: Too many nested function calls. May be due to infinite recursion.

With version 9.7 it was working perfectly.
My guess that it's somehow related to tail call optimization.
Is anything changed in this regard in new version?

We still are to build a simple test case...


Replies (6)

Please register to reply

RE: Saxon-HE 9.8.0-3 Tail Calls - Added by Michael Kay 3 months ago

There are no conscious changes in the code for tail-call recursion but it's sensitive to other optimizations that may have changed, and may change the expression tree in a way that means we no longer recognize the tail call. We'll need to see a specific test case. (If you can't build a simple test case, a complex one will do, so long as we can run it...)

RE: Saxon-HE 9.8.0-3 Tail Calls - Added by Vladimir Nesterovsky 3 months ago

As simple as this tail call template with any input:

<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
  xmlns:xs="http://www.w3.org/2001/XMLSchema">

  <xsl:template match="/">
    <out>
      <xsl:call-template name="call">
        <xsl:with-param name="index" select="0"/>
        <xsl:with-param name="max" select="10000"/>
      </xsl:call-template>
    </out>
  </xsl:template>

  <xsl:template name="call">
    <xsl:param name="index" as="xs:integer"/>
    <xsl:param name="max" as="xs:integer"/>

    <value>
      <xsl:value-of select="$index"/>
    </value>

    <xsl:if test="$index lt $max">
      <xsl:call-template name="call">
        <xsl:with-param name="index" select="$index + 1"/>
        <xsl:with-param name="max" select="$max"/>
      </xsl:call-template>
    </xsl:if>
  </xsl:template>

</xsl:stylesheet>

Works perfectly with Saxon-HE-9.7.0-18, and
craches with "Too many nested template or function calls. The stylesheet may be looping." in Saxon-HE-9.8.0-3.

RE: Saxon-HE 9.8.0-3 Tail Calls - Added by Vladimir Nesterovsky 3 months ago

Is it possible in your development cycle to implement maven snapshot version?
This way you would get more prompt feed back.
As present we run our code base on each new version, and then rollback to the old one with long wait for a version tick for.

RE: Saxon-HE 9.8.0-3 Tail Calls - Added by Michael Kay 3 months ago

I understand the benefits of this, but

(a) if we ran our full set of tests on each such snapshot, it could add a significant amount of testing effort

(b) if we didn't run our full set of tests on each such snapshot, it could add a significant number of bugs and therefore support effort.

RE: Saxon-HE 9.8.0-3 Tail Calls - Added by Michael Kay 3 months ago

(Subsequent events illustrated this point rather well: after committing another patch for an unrelated bug I ran the XSLT 3.0 test suite in export/import mode where each compiled stylesheet is written to an SEF file and then imported before being executed; and this test showed that the patch for this problem was incomplete. Running the full test suite in this way is something we do before a maintenance release, but it is not something we do on every commit.)

    (1-6/6)

    Please register to reply