#343 AssertionError: unknown value representation

v8.4
closed
5
2014-04-26
2005-04-11
Michael Kay
No

The following exception can occur:

Exception in thread "main" java.lang.AssertionError:
Unknown value representation
| at
net.sf.saxon.value.Value.getIterator(Value.java:206)

This exception actually indicates that the system has
tried to read a variable and found that no value has
been written to the relevant slot. In this particular
case this has occurred because of a corruption caused
by reusing the stackframe. The problem occurs because
of the interaction of two optimizations: when
apply-templates calls a template that has no local
variables or parameters, then no new stackframe is
allocated; but if the called template contains a tail
call (which might be call-template or apply-templates)
then its stack frame is overwritten by that of the
tail-called template.

The source fix removes the first optimization, which is
no longer needed because allocating a new empty
stackframe is now very efficient.

In net.sf.saxon.instruct.ApplyTemplates, delete the
following lines:

251:
if (tunnelParameters != null ||
eh.needsStackFrame()) {

259-264:
} else {
TraceListener traceListener =
controller.getTraceListener();

traceListener.startCurrentItem(node);
tc = eh.processLeavingTail(c2);
traceListener.endCurrentItem(node);
}

292:
if (tunnelParameters != null ||
eh.needsStackFrame()) {

297-299:
} else {
tc = eh.processLeavingTail(c2);
}

In net.sf.saxon.expr.XPathContextMajor, change the
method openStackFrame(SlotManager map) at line 183 to read:

public void openStackFrame(SlotManager map) {
    int slots = map.getNumberOfVariables();
    if (slots == 0) {
        stackFrame = StackFrame.EMPTY;
    } else {
        stackFrame = new StackFrame(map, new

ValueRepresentation[slots]);
}
}

Michael Kay

Discussion