Haskell-Things / ImplicitCAD

A math-inspired CAD program in haskell. CSG, bevels, and shells; 2D & 3D geometry; 2D gcode generation...
https://implicitcad.org/
GNU Affero General Public License v3.0
1.39k stars 142 forks source link

Translate with malformed vector leads to crash #106

Closed WJWH closed 5 years ago

WJWH commented 10 years ago

Trying to compile the following code will cause extopenscad to consume all available memory until it crashes with an "out of memory" error.

translate([-,0,0]) cube(1);

Note there being just a minus as the first element of the vector. I believe proper behavior would be to detect this and give a more informative error message.

julialongtin commented 7 years ago

Reproduced on the current version. investigating.

julialongtin commented 5 years ago

also reproduced by:

echo ((-)); echo ([-]);

julialongtin commented 5 years ago

and echo((+));

WJWH commented 5 years ago

Perhaps it believes there to be a number following it, causing some sort of infinite recursion? I had a quick look through code and the most likely thing I could find was https://github.com/colah/ImplicitCAD/blob/master/Graphics/Implicit/ExtOpenScad/Parser/Expr.hs#L177, but I must admit I don't know this code (or just Parsec in general) well enough to make a proper fix.

As an aside, this is one of the oldest GH issues I've filed and I think it's super cool that people are looking at it now. Much appreciation for that.

julialongtin commented 5 years ago

and echo([ for (a = [1 : 4]) [a, a * a] ]);

julialongtin commented 5 years ago

almost-complete rewrite of the expression parser. quite a bit faster (4-600 times, depending on the test!), and all of these generate syntax errors now.

Problem solved. :)