#908 Optimization causing CCE

v9.1
closed
Michael Kay
5
2012-10-08
2008-12-20
Michael Kay
No

Saxon decides statically how to evaluate a variable based on the nature of the select expression (or initializing expression). If the select expression is subsequently rewritten by the optimizer, it should reevaluate this decision, but it is not doing so. If the evaluation strategy chosen is not suitable for the rewritten expression, this may cause a failure at runtime. In particular, one rarely-used evaluation strategy is "shared append expression", and is used when the select expression appends an item to a sequence. This strategy is designed to reduce the need for copying of a sequence in the case of a recursive function or template that appends one item to a sequence on each recursive call; however, it may also be used where this is not the case. In such cases, if the select expression is changed by the optimizer from its original form, a ClassCastException occurs at runtime.

A patch to module GeneralVariable is being placed in Subversion on the 9.1 branch. Test case bug84 added.

Discussion

  • Michael Kay
    Michael Kay
    2009-03-17

    Fixed in 9.1.0.6

     
  • Michael Kay
    Michael Kay
    2009-05-12

    A further occurrence of this problem has been found in 9.1.0.6. It occurs when the append expression (an expression using the comma operator) appears as an argument to a function call, and is subsequently rewritten as a reference to a global variable because the value of the argument has no dependencies on local data. Rather than patch this case to recompute the evaluation strategy, a patch is being applied to module ExpressionTool whose effect is to detect when "shared append" evaluation is being used inappropriately, and substitute a different evaluation strategy at run-time.