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

Polyhedron + minkowski -> SIGSEGV #2301

Closed
LubosD opened this issue Feb 13, 2018 · 6 comments · Fixed by #5229
Closed

Polyhedron + minkowski -> SIGSEGV #2301

LubosD opened this issue Feb 13, 2018 · 6 comments · Fixed by #5229

Comments

@LubosD
Copy link

LubosD commented Feb 13, 2018

This code makes OpenSCAD crash:

$fn=25;

module smoother() {
    polyhedron(points = [
        [100, 5, 0], [70, 7.5, 0], [0, 7.5, 0],
        [0, -7.5, 0], [70, -7.5, 0], [100, -5, 0],
        [100, 5, 1], [70, 7.5, 5], [0, 7.5, 5],
        [0, -7.5, 5], [70, -7.5, 5], [100, -5, 1],
    ],
    faces = [
        [0, 1, 7, 6], [1, 2, 8, 7],
        [2, 3, 9, 8],
        [5, 0, 6, 11],
        [0, 1, 2, 3, 4, 5],
        [6, 7, 10, 11], [7, 8, 9, 10],
        [5, 4, 10, 11], [4, 3, 9, 10],
    ]);
}

minkowski() {
    smoother();
    sphere(r=0.5);
}

Reproduced under Debian and Gentoo. Crash occurs in CGAL::polygon_mesh_to_nef_3.

UPDATE: I've figured out the source of trouble: I don't have all points ordered in the same direction. Still, I think it shouldn't crash.


Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

@kintel
Copy link
Member

kintel commented Feb 13, 2018

Confirmed on macOS using OpenSCAD-2017.12.23

@thehans
Copy link
Member

thehans commented Feb 13, 2018

Just quickly tested this on the nightly Linux build on Linux Mint 18.3.

I do see the following error when previewing, but it does not crash:

ERROR: CGAL error in CGAL_Nef_polyhedron3(): CGAL ERROR: assertion violation! Expr: pe != 0 File: /usr/include/CGAL/Nef_3/polyhedron_3_to_nef_3.h Line: 212 

The nightly build is built against CGAL 4.7.
I suspect @LubosD version is built against newer 4.9 or 4.10? Can you post your Help -> Library Info

@LubosD
Copy link
Author

LubosD commented Feb 13, 2018

@thehans CGAL 4.10.

@kintel
Copy link
Member

kintel commented Feb 13, 2018

It crashed for me using 4.11

@kintel
Copy link
Member

kintel commented Feb 16, 2018

It's definitely due to the polygons not being in order; when passing this to CGAL, we end up with two unclosed objects which causes the CGAL::Polyhedron_3() constructor to crash at https://github.com/openscad/openscad/blob/master/src/cgalutils.cc#L82

We have a check for closed & valid meshes in place just before that line, which we could easily enforce. Just not sure if that breaks other marginal use-cases. We'll have to add a testcase or two to test for this before enforcing that constraint.

@kintel
Copy link
Member

kintel commented Mar 29, 2024

Also crashes with Manifold. Not too unexpected as we use CGAL for most minkowski cases, but tagging it anyway.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Development

Successfully merging a pull request may close this issue.

3 participants