Project

Profile

Help

Bug #1745

closed

Variable stack frame allocation issue - PE 0.5.0.1

Added by John Lumley about 11 years ago. Updated almost 11 years ago.

Status:
Closed
Priority:
High
Assignee:
Category:
Internals
Sprint/Milestone:
-
Start date:
2013-04-25
Due date:
% Done:

100%

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

Description

In the attached code, the let assignment of $y in svg:join.orthogonal causes ArrayOutOfBounds: "local variable $y uses slot 2 but only 1 slots are allocated on the stack frame". (LocalVariableReference.java:105) at runtime. Changing to svg:join.line() is fine. Both forms run successfully under 9.4.0.7


Files

bug95.xsl (2.28 KB) bug95.xsl John Lumley, 2013-04-25 13:23
Actions #1

Updated by Michael Kay about 11 years ago

  • Category set to Internals
  • Status changed from New to In Progress
  • Assignee set to Michael Kay

Interesting - this fails under Saxon-PE 9.5.0.1 but not under Saxon-EE 9.5.0.1. So I tried it with ~~opt:0 under EE, and that fails too. This means the code is OK after applying Saxon-EE optimization, but not OK without it ~~ which is a little unusual!

Actions #2

Updated by Michael Kay about 11 years ago

Even more interesting...

The reason it works when Saxon-EE optimization is in place is that the call to svg:join gets inlined, so none of the following complications arise.

The call to svg:join is treated as a "tail call to a different function", which is implemented by using the same context object with the stack frame overwritten to contain the parameters to the called function (and enough space for its local variables). However, the parameter passed to the called function includes a "Lazy Sequence", that is a data structure that has not yet been fully evaluated, and as it happens the evaluation depends on variable $y, which is held in the stack frame that has just been overwritten. Nasty. In this situation 9.4 would have used a Closure, which maintains a local copy of all the context information on which it depends.

Actions #3

Updated by Michael Kay about 11 years ago

  • Priority changed from Normal to High
Actions #4

Updated by Michael Kay almost 11 years ago

  • Status changed from In Progress to Resolved

See bug 1752. I was concerned that this might be a rather deep design problem. But in fact there are a limited number of evaluation strategies for variables and the only one that allows lazy sequences is the "shared append" strategy, used when a variable or parameter is initialized with an expression using comma operators. This has been fixed by making Chain and its component sequences "grounded values" as described under bug 1752, and it is believed that this fixes this problem.

Actions #5

Updated by O'Neil Delpratt almost 11 years ago

  • Status changed from Resolved to Closed
  • % Done changed from 0 to 100
  • Found in version changed from 9.5.0.1 to 9.5
  • Fixed in version set to 9.5.0.2

Please register to edit this issue

Also available in: Atom PDF