Bug #6145
closed![Author: Vladimir Nesterovsky](https://www.gravatar.com/avatar/20fb0ad082fd4afbf6cfcc2736a032c0?rating=PG&size=50&default=https%3A%2F%2Fassets.plan.io%2Fimages%2Fdefault_avatar.png)
![Assignee: Michael Kay](https://www.gravatar.com/avatar/db6526d63053f09b62e52c2da8b2230a?rating=PG&size=22&default=https%3A%2F%2Fassets.plan.io%2Fimages%2Fdefault_avatar.png)
Saxon 10.6 - NPE in pattern array(XX) when XSLT 4.0 extensions are not enabled
0%
Description
I have typed invalid xslt and got obscure NPE:
[java] [1]:java.lang.NullPointerException: Cannot invoke "net.sf.saxon.expr.parser.Tokenizer.recentText(int)" because "this.t" is null
[java] [1] at net.sf.saxon.expr.parser.XPathParser.grumble(XPathParser.java:299)
[java] [1] at net.sf.saxon.expr.parser.XPathParser.grumble(XPathParser.java:268)
[java] [1] at net.sf.saxon.expr.parser.XPathParser.grumble(XPathParser.java:255)
[java] [1] at net.sf.saxon.expr.parser.XPathParser.checkSyntaxExtensions(XPathParser.java:3067)
[java] [1] at net.sf.saxon.pattern.PatternParser30.isSelectionPattern(PatternParser30.java:165)
[java] [1] at net.sf.saxon.pattern.PatternParser30.parsePattern(PatternParser30.java:62)
[java] [1] at net.sf.saxon.pattern.Pattern.make(Pattern.java:59)
[java] [1] at net.sf.saxon.style.StyleElement.makePattern(StyleElement.java:723)
[java] [1] at net.sf.saxon.style.XSLTemplate.prepareAttributes(XSLTemplate.java:371)
[java] [1] at net.sf.saxon.style.StyleElement.processAttributes(StyleElement.java:594)
[java] [1] at net.sf.saxon.style.StyleElement.processAllAttributes(StyleElement.java:531)
[java] [1] at net.sf.saxon.style.XSLTemplate.processAllAttributes(XSLTemplate.java:428)
[java] [1] at net.sf.saxon.style.PrincipalStylesheetModule.processAllAttributes(PrincipalStylesheetModule.java:589)
[java] [1] at net.sf.saxon.style.PrincipalStylesheetModule.preprocess(PrincipalStylesheetModule.java:366)
[java] [1] at net.sf.saxon.style.Compilation.compilePackage(Compilation.java:288)
[java] [1] at net.sf.saxon.style.StylesheetModule.loadStylesheet(StylesheetModule.java:252)
[java] [1] at net.sf.saxon.style.Compilation.compileSingletonPackage(Compilation.java:113)
[java] [1] at net.sf.saxon.s9api.XsltCompiler.compile(XsltCompiler.java:838)
[java] [1] at net.sf.saxon.jaxp.SaxonTransformerFactory.newTemplates(SaxonTransformerFactory.java:184)
Almost nothing in error report helps to identify the problem. Error is in these lines:
<xsl:template mode="x" match="array(element())" as="map(*)">
...
</xsl:template>
Match should be: match=".[. instance of array(element())]"
.
Please note that I did not test it in newer versions.
Updated by Michael Kay about 1 year ago
It's trying to tell you that you haven't enabled Saxon syntax extensions, and it crashes because it's accessing unitialised data while constructing the error message.
Updated by Michael Kay about 1 year ago
The problem seems to be still present, in modified form, in later releases.
Recommended actions:
(a) make the error-reporting code more resilient (avoids the crash, leaves the message with no location information) (b) delay the checking until the parser is fully initialized (c) improved testing (too much of our testing is done with all optional features enabled)
Updated by Michael Kay about 1 year ago
- Subject changed from NPE in pattern during compilatio in Saxon 10.6 HE to NPE in pattern array(XX) when XSLT 4.0 extensions are not enabled
Updated by Michael Kay about 1 year ago
- Category set to Diagnostics
- Assignee set to Michael Kay
- Priority changed from Low to Normal
Updated by Michael Kay about 1 year ago
It seems that the XSLT test driver, unlike the XQuery/XPath test driver, doesn't allow multiple version strings in the spec version dependency, so a test specifying `<dependency type="spec" value="XSLT20 XSLT30" isn't being run. Many of the tests designed to ensure that 4.0 syntax is rejected when 4.0 isn't available use this formulation.
Updated by Michael Kay about 1 year ago
I've fixed the test driver, and the relevant tests in the arrays
test-set are now being run, which is revealing quite a few problems (mainly minor, like incorrect error codes). However, the test arrays-010b that was designed to reproduce this problem fails to do so on the 12.x branch.
Updated by Michael Kay about 1 year ago
In the 10.x branch, the new test arrays-010b reproduces the failure.
On the 11.x branch, many of the tests that should fail if 4.0 is not enabled actually succeed.
Updated by Michael Kay about 1 year ago
Given the variation between releases, for 10.x I've done a minimal ad-hoc patch on the error-handling path.
For 11.x, the problem is that the flag allowXPath40Syntax
is set to true. I think this is because the stylesheet says version="4.0". The documentation is clear that this should not be enough to enable 4.0 features. But ExpressionContext.getXPathVersion() has the logic
if (element.getEffectiveVersion() == 40
|| element.getCompilation().getCompilerInfo().getXsltVersion() == 40
|| (attributeName != null && attributeName.hasURI(NamespaceConstant.SAXON))) {
return 40;
Changing this could be a bit disruptive, but the documentation is clear enough.
When I fix this, tests array-006b and array-020b still fail to report an error. This is because Saxon 11 is allowing new 4.0 functions in the array namespace to be called regardless of version settings.
The tests are all passing on the 12.x branch, but in some cases the error codes differ from those expected.
Updated by Michael Kay about 1 year ago
Note that some of the array tests still fail on 10.x, notably arrays-306 fails with a stack overflow because we decided not to fix bug #5600 on the 10.x branch. Although I've pushed a patch for the NPE, it's quite possible that we will not produce any further maintenance releases on the 10.x branch.
Updated by Michael Kay about 1 year ago
- Status changed from New to Resolved
- Fix Committed on Branch 10 added
- Platforms .NET, Java added
I've transferred the 11.x problems to a separate issue #6156.
Updated by Michael Kay about 1 year ago
- Subject changed from NPE in pattern array(XX) when XSLT 4.0 extensions are not enabled to Saxon 10.6 - NPE in pattern array(XX) when XSLT 4.0 extensions are not enabled
Please register to edit this issue