Project

Profile

Help

Bug #4614

closed

Crash in string-to-double conversion

Added by Michael Kay almost 4 years ago. Updated over 3 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Saxon extensions
Sprint/Milestone:
-
Start date:
2020-06-26
Due date:
% Done:

100%

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

Description

Encountered while converting some xslt3extra tests to qt3extra. Test case highest-003 does

saxon:highest(doc('highest/highest-003.xml')/*/*)

and selects an element whose string value is non-numeric ("cat"), this results in a stack trace

-s:saxon-highest -t:highest-004
java.lang.NumberFormatException: For input string: "cat"
	at sun.misc.FloatingDecimal.readJavaFormatString(FloatingDecimal.java:2043)
	at sun.misc.FloatingDecimal.parseDouble(FloatingDecimal.java:110)
	at java.lang.Double.parseDouble(Double.java:538)
	at net.sf.saxon.type.StringToDouble.stringToNumber(StringToDouble.java:168)
	at com.saxonica.functions.extfn.HighestOrLowest.call(HighestOrLowest.java:87)

The test is flawed, because the spec says that untypedAtomic values are compared after casting to xs:double (as with fn:min and fn:max); but it shouldn't crash.

Actions #1

Updated by Michael Kay almost 4 years ago

StringToDouble.stringToNumber is declared to throw NumberFormatException, but this is an unchecked exception and the extension function code is not catching it.

Actions #2

Updated by Michael Kay almost 4 years ago

  • Description updated (diff)
Actions #3

Updated by Michael Kay almost 4 years ago

  • Status changed from New to Resolved
  • Fix Committed on Branch 10 added

Patched extfn.HighestOrLowest to catch the exception and report accordingly.

Actions #4

Updated by O'Neil Delpratt over 3 years ago

  • % Done changed from 0 to 100
  • Fixed in Maintenance Release 10.2 added

Bug fix applied in the Saxon 10.2 maintenance release.

Actions #5

Updated by O'Neil Delpratt over 3 years ago

  • Status changed from Resolved to Closed

Please register to edit this issue

Also available in: Atom PDF