In last release 2.3 many functions in fn namespace have been written in FnModule.hpp (FnModule.xq) by xquery. And many of them are recursive, for example the sum. During execution for each iteration of a call there is creation AtomizeResult, OccurrenceMatchesResult, in call stack like so
...
SequenceType::OccurrenceMatchesResult::next(DynamicContext * context=0x05e57a50)
ResultImpl::nextOrTail(Result & tail={...}, DynamicContext * context=0x05e57a50)
ResultImpl::next(DynamicContext * context=0x05e57a50)
AtomizeResult::next(DynamicContext * context=0x05e57a50)
SequenceType::OccurrenceMatchesResult::next(DynamicContext * context=0x05e57a50)
ResultImpl::nextOrTail(Result & tail={...}, DynamicContext * context=0x05e57a50)
ResultImpl::next(DynamicContext * context=0x05e57a50)
AtomizeResult::next(DynamicContext * context=0x05e57a50)
SequenceType::OccurrenceMatchesResult::next(DynamicContext * context=0x05e57a50)
ResultImpl::nextOrTail(Result & tail={...}, DynamicContext * context=0x05e57a50)
ResultImpl::next(DynamicContext * context=0x05e57a50)
AtomizeResult::next(DynamicContext * context=0x05e57a50)
SequenceType::OccurrenceMatchesResult::next(DynamicContext * context=0x05e57a50)
ResultImpl::nextOrTail(Result & tail={...}, DynamicContext * context=0x05e57a50)
ResultImpl::next(DynamicContext * context=0x05e57a50)
AtomizeResult::next(DynamicContext * context=0x05e57a50)
SequenceType::OccurrenceMatchesResult::next(DynamicContext * context=0x05e57a50)
ResultImpl::nextOrTail(Result & tail={...}, DynamicContext * context=0x05e57a50)
...
The quantity of repeated calls of functions depends on the size of argument. At achievement of some threshold occurs stack overflow.
Example:
sum(1 to 100000)