Bug #4987
closedNPE when references to static XSLT parameters appear in non-static expressions
100%
Description
$ java ... com.saxonica.Transform -xsl:src/docs/xsl/jstree.xsl -export:/tmp/out.sef -target:JS -nogo -l:on --generateByteCode:off -relocate:on "-ns:##html5" saxon-js-version=2.2
throws an NPE:
java.lang.NullPointerException
at net.sf.saxon.expr.parser.LoopLifter.markDependencies(LoopLifter.java:168)
at net.sf.saxon.expr.parser.LoopLifter.gatherInfo(LoopLifter.java:119)
at net.sf.saxon.expr.parser.LoopLifter.gatherInfo(LoopLifter.java:122)
at net.sf.saxon.expr.parser.LoopLifter.gatherInfo(LoopLifter.java:122)
at net.sf.saxon.expr.parser.LoopLifter.gatherInfo(LoopLifter.java:122)
at net.sf.saxon.expr.parser.LoopLifter.gatherInfo(LoopLifter.java:122)
at net.sf.saxon.expr.parser.LoopLifter.gatherInfo(LoopLifter.java:122)
at net.sf.saxon.expr.parser.LoopLifter.gatherInfo(LoopLifter.java:122)
at net.sf.saxon.expr.parser.LoopLifter.gatherInfo(LoopLifter.java:101)
at net.sf.saxon.expr.parser.LoopLifter.process(LoopLifter.java:51)
at net.sf.saxon.expr.parser.ExpressionTool.optimizeComponentBody(ExpressionTool.java:1075)
at com.saxonica.ee.optim.OptimizerEE.tryInlineFunctionCall(OptimizerEE.java:1576)
at net.sf.saxon.expr.UserFunctionCall.optimize(UserFunctionCall.java:420)
at net.sf.saxon.expr.Operand.optimize(Operand.java:228)
at net.sf.saxon.expr.SlashExpression.optimize(SlashExpression.java:354)
at net.sf.saxon.expr.Operand.optimize(Operand.java:228)
at net.sf.saxon.expr.SlashExpression.optimize(SlashExpression.java:354)
at net.sf.saxon.expr.Operand.optimize(Operand.java:228)
at net.sf.saxon.expr.instruct.ApplyTemplates.optimize(ApplyTemplates.java:231)
at net.sf.saxon.expr.Operand.optimize(Operand.java:228)
at net.sf.saxon.expr.Expression.optimizeChildren(Expression.java:618)
at net.sf.saxon.expr.instruct.ResultDocument.optimize(ResultDocument.java:267)
at net.sf.saxon.expr.Operand.optimize(Operand.java:228)
at net.sf.saxon.expr.Expression.optimizeChildren(Expression.java:618)
at net.sf.saxon.expr.instruct.Block.optimize(Block.java:672)
at net.sf.saxon.expr.parser.ExpressionTool.optimizeComponentBody(ExpressionTool.java:1063)
at net.sf.saxon.style.XSLTemplate.optimize(XSLTemplate.java:1002)
at net.sf.saxon.style.PrincipalStylesheetModule.optimizeTopLevel(PrincipalStylesheetModule.java:1478)
at net.sf.saxon.style.PrincipalStylesheetModule.compile(PrincipalStylesheetModule.java:1274)
at net.sf.saxon.style.Compilation.compilePackage(Compilation.java:322)
at net.sf.saxon.s9api.XsltCompiler.compilePackage(XsltCompiler.java:580)
at net.sf.saxon.Transform.doTransform(Transform.java:738)
at net.sf.saxon.Transform.main(Transform.java:82)
java.lang.NullPointerException
at net.sf.saxon.expr.parser.LoopLifter.markDependencies(LoopLifter.java:168)
at net.sf.saxon.expr.parser.LoopLifter.gatherInfo(LoopLifter.java:119)
at net.sf.saxon.expr.parser.LoopLifter.gatherInfo(LoopLifter.java:122)
at net.sf.saxon.expr.parser.LoopLifter.gatherInfo(LoopLifter.java:122)
at net.sf.saxon.expr.parser.LoopLifter.gatherInfo(LoopLifter.java:122)
at net.sf.saxon.expr.parser.LoopLifter.gatherInfo(LoopLifter.java:122)
at net.sf.saxon.expr.parser.LoopLifter.gatherInfo(LoopLifter.java:122)
at net.sf.saxon.expr.parser.LoopLifter.gatherInfo(LoopLifter.java:122)
at net.sf.saxon.expr.parser.LoopLifter.gatherInfo(LoopLifter.java:101)
at net.sf.saxon.expr.parser.LoopLifter.process(LoopLifter.java:51)
at net.sf.saxon.expr.parser.ExpressionTool.optimizeComponentBody(ExpressionTool.java:1075)
at com.saxonica.ee.optim.OptimizerEE.tryInlineFunctionCall(OptimizerEE.java:1576)
at net.sf.saxon.expr.UserFunctionCall.optimize(UserFunctionCall.java:420)
at net.sf.saxon.expr.Operand.optimize(Operand.java:228)
at net.sf.saxon.expr.SlashExpression.optimize(SlashExpression.java:354)
at net.sf.saxon.expr.Operand.optimize(Operand.java:228)
at net.sf.saxon.expr.SlashExpression.optimize(SlashExpression.java:354)
at net.sf.saxon.expr.Operand.optimize(Operand.java:228)
at net.sf.saxon.expr.instruct.ApplyTemplates.optimize(ApplyTemplates.java:231)
at net.sf.saxon.expr.Operand.optimize(Operand.java:228)
at net.sf.saxon.expr.Expression.optimizeChildren(Expression.java:618)
at net.sf.saxon.expr.instruct.ResultDocument.optimize(ResultDocument.java:267)
at net.sf.saxon.expr.Operand.optimize(Operand.java:228)
at net.sf.saxon.expr.Expression.optimizeChildren(Expression.java:618)
at net.sf.saxon.expr.instruct.Block.optimize(Block.java:672)
at net.sf.saxon.expr.parser.ExpressionTool.optimizeComponentBody(ExpressionTool.java:1063)
at net.sf.saxon.style.XSLTemplate.optimize(XSLTemplate.java:1002)
at net.sf.saxon.style.PrincipalStylesheetModule.optimizeTopLevel(PrincipalStylesheetModule.java:1478)
at net.sf.saxon.style.PrincipalStylesheetModule.compile(PrincipalStylesheetModule.java:1274)
at net.sf.saxon.style.Compilation.compilePackage(Compilation.java:322)
at net.sf.saxon.s9api.XsltCompiler.compilePackage(XsltCompiler.java:580)
at net.sf.saxon.Transform.doTransform(Transform.java:738)
at net.sf.saxon.Transform.main(Transform.java:82)
Fatal error during transformation: java.lang.NullPointerException: (no message)
Files
Updated by Michael Kay over 3 years ago
- Status changed from New to In Progress
- Assignee set to Michael Kay
Problem reproduced.
Updated by Michael Kay over 3 years ago
In the xsl:choose at line 612 of jstree.xsl, there are two references to the static variable $saxon-js-version. Both of these have been (correctly) substituted by the string literal "2.2". But it appears that the same string literal has been used for both, which means that when one of them is found by navigating the expression tree downwards, its parent expression is not an expression that has already been analysed: the NPE at this point always indicates such an inconsistency in the tree (where a child C of a parent expression P has a parent pointer to an expression other than P).
The inconsistency is confirmed by uncommenting line 45 in LoopLifter.java (exp.verifyParentPointers()
) which triggers an integrity check of the expression tree.
Updated by Michael Kay over 3 years ago
In VariableReference.optimize()
line 273, return select
should be return select.copy(new RebindingMap())
. Without this copy, all references to the variable will share the same parent pointer.
Updated by Michael Kay over 3 years ago
- Subject changed from Attempting to compile the jstree application throws an NPE to NPE when references to static XSLT parameters appear in non-static expressions
- Applies to branch trunk added
- Fix Committed on Branch 10, trunk added
Updated by Michael Kay over 3 years ago
- Status changed from In Progress to Resolved
Updated by O'Neil Delpratt about 3 years ago
- Status changed from Resolved to Closed
- % Done changed from 0 to 100
- Fixed in Maintenance Release 10.6 added
Bug fix applied in the Saxon 10.6 maintenance release
Please register to edit this issue