Re: [Scilab-users] How to list the content of the recursion stack?

2021-05-06 Thread Jean-Yves Baudais
Hi,

> from
> --> currentMaxDepth = recursionlimit()
> currentMaxDepth =
> 1000.

Thanks Samuel, I didn't know this function. So I face a problem (a bug?): 
Scilab cratches with segfault but without reaching the recursionlimit. Here the 
used three functions

function out=test_l(in)
  if in==0 then
out=in;
return
  end
  out=in+test_l(in-1);
endfunction

function out=test_ll(in,acc)
  if in<=1
out=acc;
return
  end
  out=test_ll(in-1,acc+in);
endfunction

function l_test(in)
  i=1;
  while 1
mprintf("\n%d: ",i)
sleep(.5,"s");
select in
 case 1
  out=test_l(i);
 case 2
  out=test_ll(i,1);
end
mprintf("%d\n",out)
i=i+1;
  end
endfunction

There is no problem with

> recursionlimit(20)
> l_test(1)

The program stops as expected with the message "Limite de récursion atteinte 
(20)" when i=19 and

> recursionlimit(20)
> l_test(2)

stops when i=20 (I was wrong when I talked about tail call in my previous 
email!). But, with

> recursionlimit(1000)
> l_test(1)

Scilab cratches at i=41 with segfault and with

> recursionlimit(1000)
> l_test(2)

Scilab cratches at i=140. Is this cratch a know bug? (It's quite far from the 
recursion limit!)

(Subsidiary question: while l_test(2) stop 1 iteration after l_test(1) with low 
recursion limit, l_test(2) allows around 100 iterations more than l_test(1) 
before cratch with recursionlimit(1000)! Where does it comes from?)

--Jean-Yves
___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users


Re: [Scilab-users] How to list the content of the recursion stack?

2021-05-06 Thread Samuel Gougeon

Hello Jean-Yves,

Le 06/05/2021 à 11:13, Jean-Yves Baudais a écrit :

.../...
test_ll improves a bit test_l because it uses tail call, but the max 
without seg.fault is far from 1000. Where does this limit of 1000 come 
from?


from
--> currentMaxDepth = recursionlimit()
 currentMaxDepth  =
   1000.

set by default in the user's preferences:
https://help.scilab.org/docs/6.1.0/en_US/recursionlimit.html

A recursion can be triggered in a involontary way according to a quite 
indirect and complex path. That was the case i have met. I have fixed it 
with a lot of spying pause() and disp().

But it's not really a way of working...

Samuel
___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users


Re: [Scilab-users] How to list the content of the recursion stack?

2021-05-06 Thread Jean-Yves Baudais
Hi,

> [...] When we get a Recursion limit reached (1000) message [...]


  I'm not a wizard on programming, not at all, and recursion call it's all the 
time complex for me to use. Anyway, I tested two different recursions and I'm 
really far from the "Recursion limit"! Here the examples:

function out=test_l(in)
  if in==0 then
out=in;
return
  end
  out=in+test_l(in-1);
endfunction
//calling sequence
// test_l(n); // max n=41

function out=test_ll(in,acc)
  if in<=1
out=acc;
return
  end
  out=test_ll(in-1,acc+in);
endfunction
//calling sequence
//test_ll(n,1); // max n=140


test_ll improves a bit test_l because it uses tail call, but the max without 
seg.fault is far from 1000. Where does this limit of 1000 come from?

-- Jean-Yves
___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users


Re: [Scilab-users] How to list the content of the recursion stack?

2021-05-06 Thread Clément David
Hello Samuel,

If I remember correctly, this message comes without any information as this is 
a regular Scilab error and should be trap through debug(). However on the 
latest Scilab dev build it seems to crash my Scilab. Could you post a bug on 
that please ?

Thanks,

Clément 

-Original Message-
From: users  On Behalf Of Samuel Gougeon
Sent: Tuesday, May 4, 2021 3:01 PM
To: International users mailing list for Scilab. 
Subject: [Scilab-users] How to list the content of the recursion stack?

Dear all,

When we get a Recursion limit reached (1000) message, does anyone know how to 
know more about which recursive calls are filling and overflowing the recursion 
stack?

Noticeably, the message does not tell anything about the last instruction that 
yielded the error.
This makes debugging quite hard.

Using debug() to follow 1000 nested calls is just not possible.
The debug page says "launch execution with stop on error". But then, in debug 
mode,  "e whereami" does not display anything, as in normal mode.

Thanks
Regards
Samuel

___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users
___
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users