discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

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

MH
Martin Herdieckerhoff
Fri, May 1, 2020 2:55 PM

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?

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?
TP
Torsten Paul
Fri, May 1, 2020 3:01 PM

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.

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.
MH
Martin Herdieckerhoff
Fri, May 1, 2020 5:00 PM

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
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

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 > Discuss@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
M
MichaelAtOz
Fri, May 1, 2020 11:37 PM

& 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/

& 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/
MH
Martin Herdieckerhoff
Sun, May 3, 2020 2:48 PM

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
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

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 > Discuss@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
TP
Torsten Paul
Wed, May 6, 2020 10:59 PM

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.

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.
MH
Martin Herdieckerhoff
Sat, May 9, 2020 1:20 PM

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
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

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 > Discuss@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org