https://saxonica.plan.io/https://saxonica.plan.io/favicon.ico2020-05-16T18:52:55ZSaxonica Developer CommunitySaxon - Bug #4555: NullPointerException on Saxon 10.1https://saxonica.plan.io/issues/4555?journal_id=154282020-05-16T18:52:55ZGunther Rademachergrd@gmx.de
<ul></ul><p>Some further analysis showed that this might occur while compiling the code in <code>Q{de/bottlecaps/railroad/xq/ast-to-svg.xq}render-vertical-pass2</code>.</p>
<p>I was able to build a minimal repro based on that. It does not make any sense, but it preserves the NPE. It can be run from command line.</p>
<pre><code class="text syntaxhl" data-language="text">declare variable $center-choice := false();
declare function local:render-vertical-pass2($max-width, $todo)
{
if ($todo) then
let $extension-length := $max-width
let $ext1 := if ($center-choice) then $extension-length else 42
let $ext2 := $extension-length - $ext1
return <line x2="{$ext1}"/>[$ext2 != 0]
else
()
};
()
</code></pre>
<p>I guess that the problem is related to the condition on <code>$center-choice</code>, which is declared as <code>false()</code> statically.</p> Saxon - Bug #4555: NullPointerException on Saxon 10.1https://saxonica.plan.io/issues/4555?journal_id=154322020-05-16T23:41:26ZMichael Kaymike@saxonica.com
<ul></ul><p>Thanks. I've reproduced this - it fails in HE only (or in EE with no license file).</p> Saxon - Bug #4555: NullPointerException on Saxon 10.1https://saxonica.plan.io/issues/4555?journal_id=154382020-05-18T15:14:47ZMichael Kaymike@saxonica.com
<ul></ul><p>The NPE arises when the downwards (depth-first) search of the expression tree looking for candidates for loop-lifting finds an expression whose parent pointer in the tree is wrong - specifically, is an expression that hasn't been encountered during the depth-first search. The expression in question is a variable reference to $max-width, and this appears to arise because the redundant variable $extension-length has been eliminated.</p>
<p>The compiled expression is</p>
<pre><code>if ($todo) then
(let $ext1 := if (false())
then ($max-width)
else if (true()) then (42)
return (let $ext2 := (convertUntyped(atomizeSingleton($max-width))) - (convertUntyped(atomizeSingleton($ext1)))
return ((<line {FixedAttribute(string-join(convert(data($ext1)), " "))}/>)[$ext2 != 0])))
</code></pre>
<p>and the "bad" variable reference is the second one, inside the <code>atomizeSingleton()</code> call, which started life as a reference to <code>$extension-length</code>.</p> Saxon - Bug #4555: NullPointerException on Saxon 10.1https://saxonica.plan.io/issues/4555?journal_id=154392020-05-18T15:46:05ZMichael Kaymike@saxonica.com
<ul></ul><p>Both the variable references for <code>$max-width</code> are represented by the same <code>LocalVariableReference</code> object, which means that one of them has the wrong parent expression. This arises from a failure to copy the <code>LocalVariableReference</code>.</p>
<p>The offending code seems to be in <code>FLWORExpression.optimize()</code> line 520, where <code>ExpressionTool.replaceVariableReferences()</code> is called with <code>mustCopy=false</code> in the case where <code>oneRef=true</code>.</p>
<p>I'm now getting a failure "A license is needed to use custom serialization {<a href="http://saxon.sf.net/%7Dindent-spaces" class="external">http://saxon.sf.net/}indent-spaces</a>". This is because I'm running Saxon-EE without a license, rather than running HE. <code>EnterpriseConfiguration.makeXQueryExpression()</code> should create an instance of <code>XQueryExpression</code> rather than <code>XQueryExpressionEE</code> under these circumstances. But the actual failure is that the Query command line, when preparing the "explain" output destination (at line 365) is testing whether edition="HE" rather than testing whether it is licensed.</p> Saxon - Bug #4555: NullPointerException on Saxon 10.1https://saxonica.plan.io/issues/4555?journal_id=154402020-05-18T15:55:49ZMichael Kaymike@saxonica.com
<ul><li><strong>Category</strong> set to <i>Internals</i></li><li><strong>Status</strong> changed from <i>New</i> to <i>Resolved</i></li><li><strong>Assignee</strong> set to <i>Michael Kay</i></li><li><strong>Priority</strong> changed from <i>Low</i> to <i>Normal</i></li><li><strong>Applies to branch</strong> <i>9.9</i> added</li><li><strong>Fix Committed on Branch</strong> <i>10, 9.9</i> added</li></ul><p>In summary, the basic failure is a corruption of the expression tree when optimising FLWOR expressions, specifically those with a redundant variable declared in a let clause.</p>
<p>It's not failing in 9.9 because the variable oneRef is set to false; in effect 10.x has become smarter in analysing the variable references and this has triggered an optimisation that was not attempted in 9.9, but the optimisation turns out to be wrong. I will fix 9.9 so the failure to copy the variable reference is corrected, in cases there are other test cases that trigger this path.</p>
<p>Also, on the 10.x branch only, I am fixing a couple of places where Saxon-EE with no license file is failing when it should fall back to HE behaviour.</p> Saxon - Bug #4555: NullPointerException on Saxon 10.1https://saxonica.plan.io/issues/4555?journal_id=160572020-08-26T08:23:11ZO'Neil Delprattoneil@saxonica.com
<ul><li><strong>% Done</strong> changed from <i>0</i> to <i>100</i></li><li><strong>Fixed in Maintenance Release</strong> <i>10.2</i> added</li></ul><p>Bug fix applied in the Saxon 10.2 maintenance release.</p> Saxon - Bug #4555: NullPointerException on Saxon 10.1https://saxonica.plan.io/issues/4555?journal_id=161132020-08-26T16:08:20ZGunther Rademachergrd@gmx.de
<ul></ul><p>Thanks for the fix - this works fine on Saxon-HE 10.2.</p> Saxon - Bug #4555: NullPointerException on Saxon 10.1https://saxonica.plan.io/issues/4555?journal_id=165942020-10-22T16:17:36ZO'Neil Delprattoneil@saxonica.com
<ul><li><strong>Status</strong> changed from <i>Resolved</i> to <i>Closed</i></li><li><strong>Fixed in Maintenance Release</strong> <i>9.9.1.8</i> added</li></ul><p>Bug fix applied on the Saxon 9.9.1.8 maintenance release.</p>