fdo 37341 MAXRECURSION reached in ScFormulaCell::Interpret
Kohei Yoshida
kohei.yoshida at suse.de
Thu Jul 11 20:05:40 PDT 2013
On 07/11/2013 02:02 AM, Winfried Donkers wrote:
>
> Hi,
>
> Presently I'm looking at bug fdo 37341, which reports calc to hang
> when Goal Seek (sc/source/core/tool/interpr2.cxx,
> ScInterpreter::ScBackSolver()) is used.
>
> The cause of the problem is not that too many iterations are needed,
> but that MAXRECURSION in sc/source/core/data/formulacell.cxx,
> ScFormulaCell::Interpret() is reached.
>
> Increasing MAXRECURSION 'solves' the problem.
>
> I think increasing MAXRECURSION from its present value (400) to 800 is
> no problem. 10 years ago its value was 500 and in the past 1 years the
> available memory has been more than doubled.
>
The thing with recursion is that you need to be careful not to run out
of stack memory too, and the amount of stack memory has little to do
with the size of your physical memory, and it's very easy to run out of
stack memory.[1]
>
> Do you have any suggestions about how to properly solve this?
>
> To me just increasing MAXRECURSION to 800 is a dirty hack.
>
Yup. I wouldn't go there if I were you.
Actually, I'm just wondering why that code is even in ScInterpreter.
The goalseek functionality is not a cell function, and I would expect a
code like that to be outside of ScInterpreter. This is just my guess,
but because we are putting a code that does its own iterative
calculation on top of the recursive interpretation that ScInterpreter
already does, it is somehow not resetting the recursion counter in each
iteration. Maybe you can see if the recursion counter is really zero
when the formula calls Interpret() in each iteration... In theory the
recursion count should be zero when each iteration ends.
If you take a look at ScDocument::Solver, it actually creates a fake
formula cell instance and stuff it with fake formula expression to
perform this goal seek. Why not move this code from its current
location (ScInterpreter::ScBackSolver) into ScDocument::Solver and
eliminate this awkward indirection?
That's what I would try to do first.
Kohei
[1]
http://stackoverflow.com/questions/10482974/why-is-stack-memory-size-so-limited
--
Kohei Yoshida, LibreOffice Calc hacker, SUSE.
More information about the LibreOffice
mailing list