$parent_modules increases each time the recursion limit is broken in [2019, 5, 0]

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

$parent_modules increases each time the recursion limit is broken in [2019, 5, 0]

herdima

Trying to print the module stack I observed an error in version [2019, 5, 0]
regarding the number of parent modules.
In my case $parent_modules was 182 where it should have been 2.
I could track down the observed behaviour to repeated breaks of the recursion limit.
You should be able to observe the same by repeatedly running the following small example within a single session:


function recurse(n, i=0) =
  (i>=n)?
  echo("Return from ", i, " with ", pm=$parent_modules):
  let(j=i+1)    // Breaks tail recursion
  recurse(n, j);

module simple() {
  echo(version());          // [2019, 5, 0]
  echo($parent_modules);    // Rises as recursions errors are detected
  a=recurse(1000);    // Prints pm
  b=recurse(10000);    // Breaks recursion limit and increases pm by 1
}
simple();


After some runs with F5 I get e.g. =>
  ECHO: "Return from ", 1000, " with ", pm = 15
  ERROR: Recursion detected calling function 'recurse' in file parent_modules.scad, line 5
  TRACE: called by 'recurse', in file parent_modules.scad, line 5.

When I create an empty "new" file from there e.g. with Ctrl+N
then the erroneously increased value of $parent_modules travels into the new session.

Possibly your recursion limit is not between 1000 and 10000.
Then you would have to adapt those numbers.
The limit is not documented and it seems to depend at least
on the called function and possibly also on your machine or settings.

The observed increase of pm looks like a bug to me.
Who can confirm and/or fix this?



_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
tp3
Reply | Threaded
Open this post in threaded view
|

Re: $parent_modules increases each time the recursion limit is broken in [2019, 5, 0]

tp3
On 01.05.20 16:55, Martin Herdieckerhoff wrote:
> The observed increase of pm looks like a bug to me.
> Who can confirm and/or fix this?

Yes, it's a bug:
https://github.com/openscad/openscad/issues/3264

However I was not able yet to reproduce it (on my Debian system)
with the info given.
Maybe this example with a compilation error will finally help.

ciao,
  Torsten.

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
-- Torsten
Reply | Threaded
Open this post in threaded view
|

Re: $parent_modules increases each time the recursion limit is broken in [2019, 5, 0]

herdima
Ok Thorsten - thanks.
The problem was observed on a system with Windows 10.
It seemed 100% reproducible there.

Am 01.05.2020 um 17:01 schrieb Torsten Paul:

> On 01.05.20 16:55, Martin Herdieckerhoff wrote:
>> The observed increase of pm looks like a bug to me.
>> Who can confirm and/or fix this?
> Yes, it's a bug:
> https://github.com/openscad/openscad/issues/3264
>
> However I was not able yet to reproduce it (on my Debian system)
> with the info given.
> Maybe this example with a compilation error will finally help.
>
> ciao,
>    Torsten.
>
> _______________________________________________
> OpenSCAD mailing list
> [hidden email]
> http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org



_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: $parent_modules increases each time the recursion limit is broken in [2019, 5, 0]

MichaelAtOz
Administrator
& W7/64.



-----
Admin - email* me if you need anything,  or if I've done something stupid...

* click on my MichaelAtOz label, there is a link to email me.

Unless specifically shown otherwise above, my contribution is in the Public Domain; to the extent possible under law, I have waived all copyright and related or neighbouring rights to this work. Obviously inclusion of works of previous authors is not included in the above.

--
Sent from: http://forum.openscad.org/

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Admin - email* me if you need anything, or if I've done something stupid...
* click on my MichaelAtOz label, there is a link to email me.

Unless specifically shown otherwise above, my contribution is in the Public Domain; to the extent possible under law, I have waived all copyright and related or neighbouring rights to this work.
Obviously inclusion of works of previous authors is not included in the above.
Reply | Threaded
Open this post in threaded view
|

Re: $parent_modules increases each time the recursion limit is broken in [2019, 5, 0]

herdima
I just noticed that any reported error seems to cause the problem.
On my system with OpenSCAD version [2019, 5, 0] and Windos 10 / 64 bit
the value of $parent_modules increases by 1 with each run:

module simple() {
   echo($parent_modules);   // Rises as errors are reported
   assert(false);
}
simple();

Am 02.05.2020 um 01:37 schrieb MichaelAtOz:

> & W7/64.
>
>
>
> -----
> Admin - email* me if you need anything,  or if I've done something stupid...
>
> * click on my MichaelAtOz label, there is a link to email me.
>
> Unless specifically shown otherwise above, my contribution is in the Public Domain; to the extent possible under law, I have waived all copyright and related or neighbouring rights to this work. Obviously inclusion of works of previous authors is not included in the above.
>
> --
> Sent from: http://forum.openscad.org/
>
> _______________________________________________
> OpenSCAD mailing list
> [hidden email]
> http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org



_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
tp3
Reply | Threaded
Open this post in threaded view
|

Re: $parent_modules increases each time the recursion limit is broken in [2019, 5, 0]

tp3
See https://github.com/openscad/openscad/issues/3264#issuecomment-624933243
for builds that should have the issue caused by assert/stack overflow fixed.

ciao,
  Torsten.

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
-- Torsten
Reply | Threaded
Open this post in threaded view
|

Re: $parent_modules increases each time the recursion limit is broken in [2019, 5, 0]

herdima
Very well: This fixes the reported problems on my system with Windows 64bit.

Am 07.05.2020 um 00:59 schrieb Torsten Paul:

> See https://github.com/openscad/openscad/issues/3264#issuecomment-624933243
> for builds that should have the issue caused by assert/stack overflow fixed.
>
> ciao,
>    Torsten.
>
> _______________________________________________
> OpenSCAD mailing list
> [hidden email]
> http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org



_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org