using assume can cause crash during eval

Bugs

Modérateur : xcasadmin

lukamar
Messages : 331
Inscription : ven. juin 30, 2017 9:55 am
Localisation : Zagreb, Croatia

using assume can cause crash during eval

Message par lukamar » sam. nov. 12, 2022 11:38 am

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?).

parisse
Messages : 5742
Inscription : mar. déc. 20, 2005 4:02 pm
Contact :

Re: using assume can cause crash during eval

Message par parisse » mar. nov. 15, 2022 8:41 am

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.

parisse
Messages : 5742
Inscription : mar. déc. 20, 2005 4:02 pm
Contact :

Re: using assume can cause crash during eval

Message par parisse » mar. nov. 15, 2022 9:37 am

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.

lukamar
Messages : 331
Inscription : ven. juin 30, 2017 9:55 am
Localisation : Zagreb, Croatia

Re: using assume can cause crash during eval

Message par lukamar » mar. nov. 15, 2022 3:08 pm

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.

parisse
Messages : 5742
Inscription : mar. déc. 20, 2005 4:02 pm
Contact :

Re: using assume can cause crash during eval

Message par parisse » mer. nov. 16, 2022 6:11 am

Indeed, I plan to add a check for "recursive" assumptions, like for :=

Répondre