Page 1 sur 1

using assume can cause crash during eval

Publié : sam. nov. 12, 2022 11:38 am
par lukamar
If you enter

Code : Tout sélectionner

assume(a<b)
and then

Code : Tout sélectionner

assume(b<a)
then trying to compute with a and b, e.g.causes an infinite loop, crashing after a while (stack overflow?).

Re: using assume can cause crash during eval

Publié : mar. nov. 15, 2022 8:41 am
par parisse
I don't get a crash here (linux 64 bits), after 35 seconds I get a+b. Probably a stack overflow indeed, I should probably add a stack protection like MicroPython does, with a max stack size that is initialized at the begin of main() and a stack check at every evaluation.

Re: using assume can cause crash during eval

Publié : mar. nov. 15, 2022 9:37 am
par parisse
I tried to add a stack check, with a limit less than 100K of stack one gets a stack overflow on your example. But then some regression tests fail (chk_limit). Therefore I will not enable this, at least not for Linux.

Re: using assume can cause crash during eval

Publié : mar. nov. 15, 2022 3:08 pm
par lukamar
Thanks for clearing this up. My example is quite pathological, but maybe assume should report a warning when conflicting assumptions from the user are detected.

Re: using assume can cause crash during eval

Publié : mer. nov. 16, 2022 6:11 am
par parisse
Indeed, I plan to add a check for "recursive" assumptions, like for :=