Menu

#448 Infinite recursion at compile time

v8.6.1
closed
5
2012-10-08
2005-12-22
Michael Kay
No

When the optimizer rewrites an expression, it then
calls itself recursively to apply further optimization
to the rewritten expression. This creates the risk of
an infinite regression if the various rewrites are not
convergent.

An example of this occurs in Saxon 8.6.1 with the query

for $v in 'abc'
return <e/>/text {$v}

One optimization step is unnecessarily adding an
atomization of the operand $v; the next step is
removing it, and this continues ad infinitum.

Source fix: in
net.sf.saxon.instruct.SimpleNodeConstructor, method
typeCheck(), at line 83, change this code:

        if (select.getItemType(th).isAtomicType()) {
            select = new Atomizer(select,

env.getConfiguration());
}

to read:

        if (!select.getItemType(th).isAtomicType()) {
            select = new Atomizer(select,

env.getConfiguration());
}

Michael Kay

Discussion