Project

Profile

Help

Bug #5888

closed

NPE in LoopLifter: corruption in expression tree for sum() function call

Added by Michael Kay about 1 year ago. Updated about 1 year ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Internals
Sprint/Milestone:
-
Start date:
2023-02-22
Due date:
% Done:

100%

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

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.

Actions #1

Updated by Michael Kay about 1 year ago

  • 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.

Actions #2

Updated by Norm Tovey-Walsh about 1 year ago

  • Status changed from Resolved to In Progress
Actions #5

Updated by Michael Kay about 1 year ago

  • Status changed from In Progress to Resolved
Actions #6

Updated by Michael Kay about 1 year ago

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

Updated by Michael Kay about 1 year ago

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.

Actions #8

Updated by Michael Kay about 1 year ago

  • Status changed from In Progress to Resolved
Actions #9

Updated by O'Neil Delpratt about 1 year ago

  • 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