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

Program abort under EmbeddedVector flattening #3541

Closed
rcolyer opened this issue Dec 16, 2020 · 0 comments · Fixed by #3542
Closed

Program abort under EmbeddedVector flattening #3541

rcolyer opened this issue Dec 16, 2020 · 0 comments · Fixed by #3542
Projects

Comments

@rcolyer
Copy link
Member

rcolyer commented Dec 16, 2020

This bug was initially raised on the OpenSCAD mailing list http://forum.openscad.org/RC-dumps-core-tc31122.html as a regression in the master branch of OpenSCAD for the BOSL2 library's testing suite test_hull.scad https://github.com/revarbat/BOSL2/blob/master/tests/test_hull.scad

Extensive reduction and transformation of the code in question reduced it to the following test case:

function nop(x) = 0;

function fails() =
  let (
    arr = [for (c = [0,0], i = [0,0]) 0],
    x = [for (e = arr) nop(arr[0])]
  ) 0;

function save_by_flattening() =
  let (
    arr = [for (c = [0,0], i = [0,0]) 0],
    tmp = arr[0],
    x = [for (e = arr) nop(arr[0])]
  ) 0;

function works() =
  let (
    arr = [for (c = [0,0,0,0])        0],
    x = [for (e = arr) nop(arr[0])]
  ) 0;

x = fails();
//x = save_by_flattening();
//x = works();

Running as:

openscad -o - --export-format echo modified_test.scad

produces an error output of:

openscad: src/value.cc:211: Value Value::clone() const: Assertion `false && "unknown Value variant type"' failed.
Aborted

After a detailed interpretation discussion on IRC with @thehans. This issue was diagnosed as most likely due to an invalidation of EmbeddedVector iterators during flattening, which causes undefined behavior leading to a faulty pointer to a Value with an unknown variant type.

@t-paul t-paul added this to To do (get into master) in 2021.01 via automation Dec 17, 2020
@t-paul t-paul moved this from To do (get into master) to Done in 2021.01 Dec 17, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
2021.01
  
Done-RC1-to-RC3
Development

Successfully merging a pull request may close this issue.

1 participant