Project

Profile

Help

Bug #1792

closed

ArrayIndexOutOfBoundsException when converting xs:string variable with occurrence indicator

Added by O'Neil Delpratt almost 11 years ago. Updated almost 11 years ago.

Status:
Closed
Priority:
Normal
Category:
Byte code generation
Sprint/Milestone:
-
Start date:
2013-06-03
Due date:
% Done:

100%

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

Description

Given the following stylesheet code snippet:

<xsl:template name="t_element">
  <xsl:param name="ver" as="xs:string?" select="'1.0'"/>
  <xsl:element name="test"><xsl:value-of select="xs:double($ver) &gt;= xs:double('1.1')" /></xsl:element>
</xsl:template>

The following exception is thrown when bytecode generation option is 'on'. The problem here is that the '@as@' attribute is declared with type @xs:string?@. The occurrence indicator means zero or one occurrence, however we are given a default value which when used in the xs:double construct is not being correctly converted to xs:double in the byte code. I confirm that the correct type conversion happens in the interpreted code:

java.lang.ArrayIndexOutOfBoundsException: 1
	at org.objectweb.asm.Frame.a(Unknown Source)
	at org.objectweb.asm.Frame.a(Unknown Source)
	at org.objectweb.asm.MethodWriter.visitMaxs(Unknown Source)
	at org.objectweb.asm.commons.GeneratorAdapter.endMethod(Unknown Source)
	at com.saxonica.bytecode.util.CompilerService.compileToByteCode(CompilerService.java:636)
	at com.saxonica.expr.ee.OptimizerEE.compileToByteCode(OptimizerEE.java:1338)
	at net.sf.saxon.style.XSLTemplate.optimize(XSLTemplate.java:464)
	at net.sf.saxon.style.PrincipalStylesheetModule.compileStylesheet(PrincipalStylesheetModule.java:818)
	at net.sf.saxon.PreparedStylesheet.setStylesheetDocument(PreparedStylesheet.java:391)
	at net.sf.saxon.PreparedStylesheet.prepare(PreparedStylesheet.java:236)
	at net.sf.saxon.PreparedStylesheet.compile(PreparedStylesheet.java:114)
	at net.sf.saxon.Transform.doTransform(Transform.java:565)
	at net.sf.saxon.Transform.main(Transform.java:82)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:597)
	at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)
Error 
Actions #1

Updated by O'Neil Delpratt almost 11 years ago

  • Description updated (diff)
Actions #2

Updated by O'Neil Delpratt almost 11 years ago

  • Description updated (diff)
Actions #3

Updated by O'Neil Delpratt almost 11 years ago

  • Description updated (diff)
Actions #4

Updated by O'Neil Delpratt almost 11 years ago

  • Subject changed from ArrayIndexOutOfBoundsException when converting xs:string variable in a xs:double construct to ArrayIndexOutOfBoundsException when converting xs:string variable with occurrence indicator
Actions #5

Updated by O'Neil Delpratt almost 11 years ago

  • Status changed from In Progress to Resolved

Bug fixed and committed to subversion, which will be available in the next maintenance release of 9.5.

The Exception was caused by different stack heights in the various paths of the bytecode as a result of incorrect unwinding when the string param is empty.

Actions #6

Updated by O'Neil Delpratt almost 11 years ago

  • Status changed from Resolved to In Progress

Similar change is required for other types.

Actions #7

Updated by O'Neil Delpratt almost 11 years ago

  • Status changed from In Progress to Resolved

Bug now fixed. The classes affected are StringToFloatCompiler and StringToDoubleCompiler

Actions #8

Updated by O'Neil Delpratt almost 11 years ago

  • Status changed from Resolved to Closed
  • % Done changed from 0 to 100
  • Fixed in version set to 9.5.1.1

Bug now closed. Applied to the Saxon 9.5.1.1 maintenance release.

Please register to edit this issue

Also available in: Atom PDF