Large XQuery range can crash eXist-db #1971
Comments
let's go with |
@duncdrum that would be the ideal solution, however that value has to be computed, and doing that efficiently (i.e. not running our of memory) would need quite some changes to eXist-db as far as I can see. |
@adamretter major work for a major release? I checked saxon and it produces and error, about the maximum sequence length no exceeding |
@duncdrum so the problem is as always, who will do the Major work? I don't think (I am CC'ing @wolfgangmm @dizzzz @joewiz @ljo as I think the explanation below will be of interest to them). From private static class RangeSequenceIterator implements SequenceIterator {
...
public Item nextItem() {
if (current <= end) {
return new IntegerValue(current++);
} else {
return null;
}
}
...
} Basically From public class FunSubSequence extends Function {
...
public Sequence eval(Sequence contextSequence, Item contextItem) throws XPathException {
...
Item item;
final SequenceIterator iterator = seq.iterate();
for(int i = 0; i < start; i++) {
item = iterator.nextItem();
}
int i=0;
while (iterator.hasNext() && i < length) {
item = iterator.nextItem();
tmp.add(item);
i++;
}
...
}
} Above, when the
So the query Unfortunately because of the design above, the similar query: An
So the size of an We have a few options for fixing this:
|
The following very simple query from the XQTS 3.1 will result in a
java.lang.OutOfMemoryError
.It should also be considered as a security issue. This simple query could be sent to the REST end-point of any eXist-db server (which exposes the service), and it will cause the JVM to shutdown.
The XQTS states that we can either return the value
3000000000
, or any error code. So we can decide what we want to do here.The text was updated successfully, but these errors were encountered: