Bug in Optimizer
Added by Anonymous about 15 years ago
Legacy ID: #7845037 Legacy Poster: pohl-michael (pohl-michael)
We suspect to have found a bug in the optimizer. A rather complicated computed variable value causes an exception with the default optimization, if optimization is disabled it runs fine. You can find a test case and complete bug description [here][1]. [1]: http://pohl-michael.gmx.home.de/saxon-optimizer-bug/saxon-optimizer-bug.zip
Replies (4)
Please register to reply
RE: Bug in Optimizer - Added by Anonymous about 15 years ago
Legacy ID: #7845077 Legacy Poster: pohl-michael (pohl-michael)
I fear the download does not work at the moment, so here are the XSLT code and the error message (use any XML file as input). XSLT <xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xsl:output method="text" encoding="ASCII"/> <xsl:variable name="input" select="/"/> <xsl:variable name="title" select="//@title"/> <xsl:variable name="all-fields" select="for $f in //pord[1]/* return if (not(name($f) = ('struktur', 'zuord'))) then name($f) else ()"/> <xsl:variable name="relevant-fields" select="for $f in $all-fields return if (count(distinct-values(//pord/[name() eq $f]/text())) + (if (//pord/[name() eq $f][not(text())]) then 1 else 0) gt 1) then $f else ()"/> <xsl:template match="/"> <xsl:value-of select="if (current() = $relevant-fields) then 'Y' else 'N'"/> </xsl:template> </xsl:stylesheet> Error Output *** Internal Saxon error: local variable encountered whose binding has been deleted Variable name: saxon:dot1111763 Line number of reference: 16 in file:/C:/Users/Michael/Subversion/wob2/saxon-optimizer-bug/test.xsl Line number of declaration: 16 in file:/C:/Users/Michael/Subversion/wob2/saxon-optimizer-bug/test.xsl DECLARATION: java.lang.IllegalStateException: *** Internal Saxon error: local variable encountered whose binding has been deleted at net.sf.saxon.expr.ExpressionTool.allocateSlots(ExpressionTool.java:535) at net.sf.saxon.expr.ExpressionTool.allocateSlots(ExpressionTool.java:541) at net.sf.saxon.expr.ExpressionTool.allocateSlots(ExpressionTool.java:541) at net.sf.saxon.expr.ExpressionTool.allocateSlots(ExpressionTool.java:541) at net.sf.saxon.expr.ExpressionTool.allocateSlots(ExpressionTool.java:541) at net.sf.saxon.expr.ExpressionTool.allocateSlots(ExpressionTool.java:541) at net.sf.saxon.expr.ExpressionTool.allocateSlots(ExpressionTool.java:541) at net.sf.saxon.expr.ExpressionTool.allocateSlots(ExpressionTool.java:541) at net.sf.saxon.style.StyleElement.allocateSlots(StyleElement.java:1096) at net.sf.saxon.style.XSLVariableDeclaration.optimize(XSLVariableDeclaration.java:184) at net.sf.saxon.style.XSLStylesheet.compileStylesheet(XSLStylesheet.java:1033) at net.sf.saxon.PreparedStylesheet.setStylesheetDocument(PreparedStylesheet.java:342) at net.sf.saxon.PreparedStylesheet.prepare(PreparedStylesheet.java:196) at net.sf.saxon.PreparedStylesheet.compile(PreparedStylesheet.java:88) at net.sf.saxon.Transform.doTransform(Transform.java:714) at net.sf.saxon.Transform.main(Transform.java:70) Fatal error during transformation: java.lang.IllegalStateException: *** Internal Saxon error: local variable encountered whose binding has been deleted
RE: Bug in Optimizer - Added by Anonymous about 15 years ago
Legacy ID: #7845120 Legacy Poster: pohl-michael (pohl-michael)
Sorry I missed this in the last post, but we used Saxon HE 9.2.0.3.
RE: Bug in Optimizer - Added by Anonymous about 15 years ago
Legacy ID: #7848067 Legacy Poster: Michael Kay (mhkay)
Thanks for getting it down to such a simple test case - this helps a lot with this kind of bug. It's still a bit of a nightmare tracing all the decisions the optimizer is making, but I got it in the end. It's hard to describe precisely the conditions that trigger the bug, but it's another instance of a class of problems in which the expression tree is changed by the optimizer without changing all the cached derived information held on the tree that can be invalidated by the change. A patch will be raised. Meanwhile you can work around the problem by pulling out the parts of the expression that depend on the context item (things like //pord/) into a separate variable (which is what the optimizer is trying to do unsuccessfully).
RE: Bug in Optimizer - Added by Anonymous about 15 years ago
Legacy ID: #7870747 Legacy Poster: pohl-michael (pohl-michael)
We are happy to have helped and are looking forward to the next Patch :-)
Please register to reply