Project

Profile

Help

Bug #2360

closed

java.lang.RuntimeException was unhandled by user code

Added by O'Neil Delpratt over 9 years ago. Updated almost 9 years ago.

Status:
Closed
Priority:
Normal
Category:
.NET API
Sprint/Milestone:
Start date:
2015-04-21
Due date:
% Done:

100%

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

Description

Reported by Daniel Lemke. See forum post: https://saxonica.plan.io/boards/2/topics/6101?r=6105

The following exception was thrown:

java.lang.RuntimeException was unhandled by user code
  HResult=-2146233088
  Message=Internal error evaluating template  at line 1 in module 
  Source=saxon9he
  StackTrace:
       at net.sf.saxon.expr.instruct.Template.applyLeavingTail(XPathContextMajor context)
       at net.sf.saxon.trans.Mode.applyTemplates(ParameterSet parameters, ParameterSet tunnelParameters, XPathContextMajor context, Int32 locationId)
       at net.sf.saxon.Controller.transformDocument(NodeInfo startNode, Receiver outputDestination)
       at net.sf.saxon.Controller.transform(Source source, Receiver receiver)
       at Saxon.Api.XsltTransformer.Run(XmlDestination destination)
       at Kneip.XslTransformation.Saxon.SaxonXslTransformer.Transform(XsltTransformer xsltTransformer) in c:\projects\svn-be\Kneip.TransformationService - Copy\trunk\Kneip.XslTransformation.Saxon\SaxonXslTransformer.cs:line 154
       at Kneip.XslTransformation.Saxon.SaxonXslTransformer.Transform(XmlDocument xmlDocument, XmlDocument xsltDocument) in c:\projects\svn-be\Kneip.TransformationService - Copy\trunk\Kneip.XslTransformation.Saxon\SaxonXslTransformer.cs:line 131
       at Kneip.XslTransformation.Tests.SaxonXslTransformerTests.SaxonIssue() in c:\projects\svn-be\Kneip.TransformationService - Copy\trunk\Tests\KNEIP.XslTransformation.Tests\SaxonXslTransformerTests.cs:line 35
  InnerException: java.lang.ArrayIndexOutOfBoundsException
       HResult=-2146233088
       Message="" 
       InnerException: 

The bug happens in the next method of the ChildEnumeration sub-class of DotNetNodeWrapper. The problem is in the evaluateItem method of the CardinalityChecker. Here we try to call next on the iterator even though we know that there are no more items.

A fix has been committed has been committed to subversion.

Actions #1

Updated by Michael Kay over 9 years ago

Just to elaborate on this:

The SequenceIterator.next() method is defined to return null when there are no more items. It's bad practice to call next() again on the same iterator after this happens, but if you do, then iterator implementations are supposed to return null again.

The CardinalityCheckingIterator in the case where the sequence being checked is empty, and where the cardinality allows empty, is calling next() twice. Although this is poor practice, it works OK if iterators follow the rules. But the NodeWrapper.ChildEnumeration iterator which supports navigation using the child axis over the Microsoft .NET DOM tree is not following the rules: if next() is called after the end of sequence has already been signalled, it throws an ArrayIndexOutOfBounds exception.

So the fix for this bug is in two parts. (A) it changes the CardinalityChecker to avoid calling next() again when a null has already been returned, and (B) it changes the NodeWrapper.ChildEnumeration iterator so it no longer crashes if next() is called after end-of-sequence has already been notified.

Actions #2

Updated by O'Neil Delpratt over 9 years ago

  • % Done changed from 0 to 100

Fix has been committed to the 9.6 and 9.7 branch.

An nunit test case has been added to test for regression of this fix in future releases.

Actions #3

Updated by O'Neil Delpratt over 9 years ago

  • Status changed from Resolved to Closed
  • Fixed in version set to 9.6.0.6

Bug fix applied in the Saxon 9.6.0.6 maintenance release.

Actions #4

Updated by O'Neil Delpratt almost 9 years ago

  • Sprint/Milestone set to 9.6.0.6
  • Applies to branch 9.6 added
  • Fix Committed on Branch 9.6 added
  • Fixed in Maintenance Release 9.6.0.6 added

Please register to edit this issue

Also available in: Atom PDF