Bug #5888
closed
NPE in LoopLifter: corruption in expression tree for sum() function call
Applies to branch:
12, trunk
Fix Committed on Branch:
12, trunk
Fixed in Maintenance Release:
Description
Reported by Mark Pierce.
An NPE occurs in LoopLifter when processing a template containing two rather complex calls on sum().
java.lang.NullPointerException: Cannot read field "dependees" because "parentInfo" is null
at net.sf.saxon.expr.parser.LoopLifter.markDependencies(LoopLifter.java:221)
at net.sf.saxon.expr.parser.LoopLifter.gatherInfo(LoopLifter.java:171)
at net.sf.saxon.expr.parser.LoopLifter.gatherInfo(LoopLifter.java:174)
at net.sf.saxon.expr.parser.LoopLifter.gatherInfo(LoopLifter.java:174)
Debugging reveals that both calls on sum() share the same operand object for the defaulted second argument (literal integer 0), so the parent pointer on one of these instances is necessarily wrong.
- Category set to Internals
- Status changed from New to Resolved
- Priority changed from Low to Normal
Fixed by changing the code that uses the default value expression and adds it as an operand to a function call, so that it now makes a copy of the expression.
- Status changed from Resolved to In Progress
- Status changed from In Progress to Resolved
- Status changed from Resolved to In Progress
The fix causes problems where the default value of a function parameter refers to global variables: test case function-decl-40-019 crashes
java.lang.UnsupportedOperationException: Cannot copy a variable reference whose binding is unknown
For the 12.1 release, I have restricted the default value expression for user-defined functions in both XSLT and XQuery so it must be either a literal or ".".
For system functions (like sum()), I have reverted to a design where the generic mechanism inserts a dummy DefaultValueExpression as the supplied argument for an omitted parameter, and the logic of the function itself then recognises this and knows what the default should be.
- Status changed from In Progress to Resolved
- Status changed from Resolved to Closed
- % Done changed from 0 to 100
- Fixed in Maintenance Release 12.1 added
Bug fix applied in the Saxon 12.1 maintenance release.
Please register to edit this issue
Also available in: Atom
PDF