Project

Profile

Help

Bug #4987

closed

NPE when references to static XSLT parameters appear in non-static expressions

Added by Norm Tovey-Walsh over 3 years ago. Updated about 3 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
-
Sprint/Milestone:
-
Start date:
2021-05-11
Due date:
% Done:

100%

Estimated time:
Legacy ID:
Applies to branch:
10, trunk
Fix Committed on Branch:
10, trunk
Fixed in Maintenance Release:
Platforms:

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

app-functions.xsl (2.28 KB) app-functions.xsl Norm Tovey-Walsh, 2021-05-11 13:18
jstree.xsl (29.4 KB) jstree.xsl Norm Tovey-Walsh, 2021-05-11 13:18
body.xsl (4.13 KB) body.xsl Norm Tovey-Walsh, 2021-05-11 13:18
el-fnd-body.xsl (3.58 KB) el-fnd-body.xsl Norm Tovey-Walsh, 2021-05-11 13:18
elements-body.xsl (8.89 KB) elements-body.xsl Norm Tovey-Walsh, 2021-05-11 13:18
findtext.xsl (14.4 KB) findtext.xsl Norm Tovey-Walsh, 2021-05-11 13:18
functions-body.xsl (8.71 KB) functions-body.xsl Norm Tovey-Walsh, 2021-05-11 13:18
Actions #1

Updated by Michael Kay over 3 years ago

  • Status changed from New to In Progress
  • Assignee set to Michael Kay

Problem reproduced.

Actions #2

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.

Actions #3

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.

Actions #4

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
Actions #5

Updated by Michael Kay over 3 years ago

  • Status changed from In Progress to Resolved
Actions #6

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

Also available in: Atom PDF