Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OpenSCAD fails to open inlined file that uses the BOSL2 library #51

Open
tbjers opened this issue Apr 6, 2023 · 4 comments · May be fixed by #52
Open

OpenSCAD fails to open inlined file that uses the BOSL2 library #51

tbjers opened this issue Apr 6, 2023 · 4 comments · May be fixed by #52
Assignees
Labels
bug Something isn't working

Comments

@tbjers
Copy link
Contributor

tbjers commented Apr 6, 2023

Describe the bug

When opening an inlined model that uses a larger library like BOSL2, OpenSCAD produces an error:

ERROR: Recursion detected calling function 'is_num' in file inline-hex-grid-test.scad, line 40782
TRACE: called by 'is_finite' in file inline-hex-grid-test.scad, line 23609
TRACE: called by 'is_vector' in file inline-hex-grid-test.scad, line 8223
TRACE: called by 'attachable' in file inline-hex-grid-test.scad, line 9789
TRACE: called by 'cube' in file inline-hex-grid-test.scad, line 6036
TRACE: called by '_cube' in file inline-hex-grid-test.scad, line 9790
TRACE: called by 'children' in file inline-hex-grid-test.scad, line 8250
TRACE: called by 'children' in file inline-hex-grid-test.scad, line 6034
TRACE: called by 'if' in file inline-hex-grid-test.scad, line 6034
TRACE: called by '_color' in file inline-hex-grid-test.scad, line 8250
TRACE: called by 'if' in file inline-hex-grid-test.scad, line 8249
TRACE: called by 'multmatrix' in file inline-hex-grid-test.scad, line 8242
TRACE: called by 'attachable' in file inline-hex-grid-test.scad, line 9789
Geometries in cache: 1
Geometry cache size in bytes: 0
CGAL Polyhedrons in cache: 0
CGAL cache size in bytes: 0
Total rendering time: 0:00:00.000

To Reproduce

Steps to reproduce the behavior:

  1. Enter command arguments scadi inline hex-grid-test.scad
  2. Run openscad -o inline-hex-grid-test.stl inline-hex-grid-test.scad
  3. See the error

Expected behavior

OpenSCAD should export an STL without errors.

Proposed solution

  • Add revarbat/BOSL2 as a submodule in tests/samples
  • Add hex-grid.scad to tests/samples
  • Create end-to-end tests using OpenSCAD
  • Add installation of OpenSCAD to CI/CD pipeline
@tbjers tbjers added the bug Something isn't working label Apr 6, 2023
@tbjers tbjers self-assigned this Apr 6, 2023
@tbjers
Copy link
Contributor Author

tbjers commented Apr 6, 2023

@Loki44 originally reported this bug as part of evaluating #42.

@Loki44
Copy link

Loki44 commented Apr 6, 2023

Thanks for looking into this.

To answer your question from the other issue, I'm on windows 10, and I had the same result with both 2021.01 and 2023.04.04.

@tbjers
Copy link
Contributor Author

tbjers commented Apr 7, 2023

I have managed to track down what causes the recursion error. By including a file inline that is loaded with use <builtins.scad> it brings those modules into the global scope, when they should be in their own context. I am currently working on solving this.

@tbjers
Copy link
Contributor Author

tbjers commented Apr 7, 2023

Looks like the BOSL2 library is taking advantage of the isolated context provided by use<> in order to work around the recursion problem. Even though there are no commands to execute inside builtins.scad, it still benefits from having a separate context in order for it to not count against the internal recursion counter in OpenSCAD. Sneaky.

How to reproduce:
Change use <builtins.scad> in the files color.scad, shapes2d.scad, and shapes3d.scad to include <builtins.scad> and the recursion error occurs as you open the original file.

@tbjers tbjers linked a pull request Apr 7, 2023 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants