Project

Profile

Help

Bug #6067

closed

NullPointerException with upper-case function

Added by Shuxin Li over 1 year ago. Updated over 1 year ago.

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

100%

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

Description

On Saxon-HE 12.2 from Java,

XML document:

<L2 id="1"/>

XPath:

//*[contains(upper-case(@f1), "a")]

Saxon gave unexpected exception:

java.lang.NullPointerException: Cannot invoke "Object.toString()" because the return value of "net.sf.saxon.expr.elab.UnicodeStringEvaluator.eval(net.sf.saxon.expr.XPathContext)" is null
Actions #1

Updated by Martin Honnen over 1 year ago

I get the following stack trace:

java -cp 'C:\Program Files\Saxonica\SaxonHE12-2J\saxon-he-12.2.jar' net.sf.saxon.Query -s:.\sample1.xml -q:.\test1.xq
<?xml version="1.0" encoding="UTF-8"?>java.lang.NullPointerException
        at net.sf.saxon.expr.elab.Elaborator.lambda$elaborateForString$0(Elaborator.java:184)
        at net.sf.saxon.functions.UpperCase$UpperCaseFnElaborator.lambda$elaborateForString$1(UpperCase.java:75)
        at net.sf.saxon.functions.Contains$ContainsFnElaborator.lambda$elaborateForBoolean$0(Contains.java:76)
        at net.sf.saxon.expr.FilterExpression$FilterExprElaborator$SimpleFilteredIterator.next(FilterExpression.java:1389)
        at net.sf.saxon.expr.elab.PullElaborator.lambda$elaborateForPush$0(PullElaborator.java:39)
        at net.sf.saxon.query.XQueryExpression.processQuery(XQueryExpression.java:499)
        at net.sf.saxon.query.XQueryExpression.run(XQueryExpression.java:473)
        at net.sf.saxon.s9api.XQueryEvaluator.run(XQueryEvaluator.java:464)
        at net.sf.saxon.Query.runQuery(Query.java:985)
        at net.sf.saxon.Query.doQuery(Query.java:443)
        at net.sf.saxon.Query.doQuery(Query.java:502)
        at net.sf.saxon.Query.main(Query.java:106)
Fatal error during query: java.lang.NullPointerException:  (no message)
Actions #2

Updated by Michael Kay over 1 year ago

Thanks for reporting it. It's failing in Saxon-HE but not in -EE.

In fact it doesn't crash in -EE even with -opt:0, or when run without a license file.

Actions #3

Updated by Michael Kay over 1 year ago

Although I can reproduce the problem running Saxon-HE 12.2 from the command line, I have built an IntelliJ project over the Saxon-HE source code and the problem does not occur.

Actually, I built this over the current source code which contains bug fixes. And I notice the line numbers in Elaborator.java are slightly different. Looking at the git history, some of the changes are simply to Javadoc. However, one substantive change that affected this module is bug #6022; and this, interestingly, has similar characteristics of failing in HE but not in EE. So I'm suspecting that this might be another manifestation (with very different symptoms) of bug #6022.

Unfortunately, though, if I revert the code change made by that bug, the problem still does not occur.

Actions #4

Updated by Michael Kay over 1 year ago

I checked out the 12_2 tag from the repo, which should be exactly the code we used to build 12.2, and ran this again in IntelliJ: again, no failure.

But then I rebuilt the HE jar files from this source, and ran from the command line, and I get the failure.

So I went back to the current branch, built the HE 12.2 Jar file again, and again I get the failure.

Went back to my IntelliJ HE project. Still no failure. A genuine Heisenbug.

Actions #5

Updated by Michael Kay over 1 year ago

I noticed that from the command line I was running Java 11.0.6, from IntelliJ I was running Java 17. Reconfigured IntelliJ to use 11.0.6. No difference, still no failure.

Actions #6

Updated by Michael Kay over 1 year ago

Now reproduced in the debugger. There was a trivial difference in the way the source document was referenced, which may have resulted in the query running in push mode rather than pull mode.

Actions #7

Updated by Michael Kay over 1 year ago

  • Category set to Internals
  • Status changed from New to Resolved
  • Assignee set to Michael Kay
  • Applies to branch 12, trunk added
  • Fix Committed on Branch 12, trunk added
  • Platforms .NET, Java added

Once reproduced, it was easily solved: simply checking for a null return from evaluator.eval() in Elaborator.elaborateForString().

Actions #9

Updated by O'Neil Delpratt over 1 year ago

  • Status changed from Resolved to Closed
  • % Done changed from 0 to 100
  • Fixed in Maintenance Release 12.3 added

Bug fix applied in the Saxon 12.3 maintenance release.

Please register to edit this issue

Also available in: Atom PDF