CGAL 3.6.1 causing errors, but CGAL 3.6.0 OK?

classic Classic list List threaded Threaded
16 messages Options
Reply | Threaded
Open this post in threaded view
|

CGAL 3.6.1 causing errors, but CGAL 3.6.0 OK?

donbright
I was wondering if anyone feels like download CGAL 3.6.1, wiping their
version of CGAL, cleaning openscad, and recompiling to see if example
15 and example 17 break or if they work properly?

The latest version of PCBSD (using FreeBSD8) has CGAL 3.6.1. When
compiling the current master of openscad and running it, example 15
and 17 do not render properly. 17 even generates a CGAL assertion in
f6 mode.

Here are images

http://cakebaby.wikia.com/wiki/Openscadbugs

However, if i pkg_delete cgal-3.6.1, and install CGAL 3.6 (not 3.6.1)
from the cgal.org site, and compile and install from source,
everything seems OK.

The strange thing is that running against CGAL-3.5 in Ubuntu 10.04
produces exactly the same rendering error on those two examples.

And no other examples seem to display this bug.

-DB

Reply | Threaded
Open this post in threaded view
|

Re: CGAL 3.6.1 causing errors, but CGAL 3.6.0 OK?

kintel
Administrator
On Dec 15, 2011, at 00:52 AM, Don Bright wrote:

> I was wondering if anyone feels like download CGAL 3.6.1, wiping their
> version of CGAL, cleaning openscad, and recompiling to see if example
> 15 and example 17 break or if they work properly?
>
Just did that here under Mac OS X and it works fine. Even CGAL 3.5 works for me (which is weird, but I've double-checked and the test output confirms that).

Btw., just in case you're not aware: You can test the examples by running ctest -C Examples

Perhaps it's worth to try reproducing that error with a minimal test case, to make it easier to discover similar issues.

 -Marius


Reply | Threaded
Open this post in threaded view
|

Re: CGAL 3.6.1 causing errors, but CGAL 3.6.0 OK?

donbright
Thanks for trying this. I think it may be an optimization thing.

When OpenSCAD is compiled with -O2 gcc optimization using older CGAL
(3.5.1), there is a bug that is readily visible in example15 and
example17, during f6 compile. Example17 even throws an assertion:

CGAL Cache insert: linear_extrude(height=6,center=false,con (60 verts)
CGAL error in CGAL_Build_PolySet: CGAL ERROR: assertion violation!
Expr: check_protocoll == 0
File: ../../src/CGAL-3.5.1-ubuntu/include/CGAL/Polyhedron_incremental_builder_3.h
Line: 198

When OpenSCAD is compiled with No Optimization (no -O flag at all),
the bug is gone.

The regression tests compile with no optimization (no -O flag at all)
by default (at least with my version of cmake?). So this bug doesn't
show up in the tests, even though it shows up in the QT GUI.

This was tested with gcc 4.4.3 on Ubuntu 10.04 with CGAL 3.5.1, both
the CGAL-3.5.1 from cgal.org, and the ubuntu-patched version of
CGAL-3.5.1.

I don't know exactly which versions/combinations of CGAL + GCC will
have the bug, but it appears to go away with newer versions of CGAL. I
will experiment more with CGAL 3.6 and 3.6.1 tonight.

-DB

On Wed, Dec 14, 2011 at 8:48 PM, Marius Kintel <[hidden email]> wrote:

> On Dec 15, 2011, at 00:52 AM, Don Bright wrote:
>
>> I was wondering if anyone feels like download CGAL 3.6.1, wiping their
>> version of CGAL, cleaning openscad, and recompiling to see if example
>> 15 and example 17 break or if they work properly?
>>
> Just did that here under Mac OS X and it works fine. Even CGAL 3.5 works for me (which is weird, but I've double-checked and the test output confirms that).
>
> Btw., just in case you're not aware: You can test the examples by running ctest -C Examples
>
> Perhaps it's worth to try reproducing that error with a minimal test case, to make it easier to discover similar issues.
>
>  -Marius
>
> _______________________________________________
> OpenSCAD mailing list
> [hidden email]
> http://rocklinux.net/mailman/listinfo/openscad

Reply | Threaded
Open this post in threaded view
|

Re: CGAL 3.6.1 causing errors, but CGAL 3.6.0 OK?

kintel
Administrator
On Dec 15, 2011, at 13:38 PM, Don Bright wrote:

> Thanks for trying this. I think it may be an optimization thing.
>
Ah, good point - we should remember run the tests with optimization on from time to time.
Perhaps even make it part of the release script.

 -Marius


Reply | Threaded
Open this post in threaded view
|

Re: CGAL 3.6.1 causing errors, but CGAL 3.6.0 OK?

donbright
Would it be good to always compile the tests with optimization turned on?

Reply | Threaded
Open this post in threaded view
|

Re: CGAL 3.6.1 causing errors, but CGAL 3.6.0 OK?

kintel
Administrator
On Dec 16, 2011, at 00:04 AM, Don Bright wrote:

> Would it be good to always compile the tests with optimization turned on?

At least building it in release mode (using the normal cmake option) as default would make sense.

 -Marius


Reply | Threaded
Open this post in threaded view
|

Re: CGAL 3.6.1 causing errors, but CGAL 3.6.0 OK?

donbright
----------------

Here is my latest set of tests, using 'ctest -R example017 -C Examples'

ubuntu 10.04 - GCC 4.4.3 - openscad regression tests compiled with no
optimization
CGAL 3.7 - pass
CGAL 3.6 - pass

ubuntu 10.04 - GCC 4.4.3 - openscad regression tests compiled with -O2
CGAL 3.9 - pass
CGAL-3.8 - pass
CGAL 3.7 - fail
CGAL 3.6 - fail

fedora ppc64 - GCC 4.6.2 - openscad regression tests compiled with no
optimization
CGAL-3.5.1 - pass
CGAL-3.6 - pass
CGAL-3.6.1 - pass
CGAL-3.7 - pass
CGAL-3.8 - pass
CGAL-3.9 - pass

fedora ppc64 - GCC 4.6.2 - openscad regression tests compiled with -O2
CGAL-3.5.1 - pass
CGAL-3.6 - pass
CGAL-3.6.1 - pass
CGAL-3.7 - pass
CGAL-3.8 - pass
CGAL-3.9 - pass

It would appear that some combination of older CGAL + older GCC +
optimization settings leads to this bug. If you upgrade CGAL, you are
ok. if you upgrade GCC, you are ok. But if you are using a
pre-packaged system like PCBSD or ubuntu 10.04, with their old CGAL
and old GCC, the bug will occur.

-DB


On Thu, Dec 15, 2011 at 6:17 PM, Marius Kintel <[hidden email]> wrote:

> On Dec 16, 2011, at 00:04 AM, Don Bright wrote:
>
>> Would it be good to always compile the tests with optimization turned on?
>
> At least building it in release mode (using the normal cmake option) as default would make sense.
>
>  -Marius
>
> _______________________________________________
> OpenSCAD mailing list
> [hidden email]
> http://rocklinux.net/mailman/listinfo/openscad

Reply | Threaded
Open this post in threaded view
|

Re: CGAL 3.6.1 causing errors, but CGAL 3.6.0 OK?

donbright
In reply to this post by kintel
On Thu, Dec 15, 2011 at 6:17 PM, Marius Kintel <[hidden email]> wrote:
> On Dec 16, 2011, at 00:04 AM, Don Bright wrote:
>
>> Would it be good to always compile the tests with optimization turned on?
>
> At least building it in release mode (using the normal cmake option) as default would make sense.
>
>  -Marius
>

I tried putt set(CMAKE_RELEASE_TYPE Release) into the CmakeLists file
, replacing the DEBUG line. This sets -O3, and also -NDEBUG.

what if we put a line like this in?

set(CMAKE_CXX_FLAGS "-O2 -g")

-DB

Reply | Threaded
Open this post in threaded view
|

Re: CGAL 3.6.1 causing errors, but CGAL 3.6.0 OK?

kintel
Administrator
On Dec 16, 2011, at 09:04 AM, Don Bright wrote:
>
> set(CMAKE_CXX_FLAGS "-O2 -g")
>
That's equivalent to this:
  set(CMAKE_BUILD_TYPE RelWithDebInfo)

 -Marius


Reply | Threaded
Open this post in threaded view
|

Re: CGAL 3.6.1 causing errors, but CGAL 3.6.0 OK?

kintel
Administrator
In reply to this post by donbright
Hi Don,

Thanks for exhaustive testing!
A small addition to your list:

ubuntu 11.04 - gcc 4.5.2 - tests compiled with -O2 -g
CGAL 3.6.1 - pass

 -Marius


Reply | Threaded
Open this post in threaded view
|

Re: CGAL 3.6.1 causing errors, but CGAL 3.6.0 OK?

donbright
PCBSD(Freebsd8) - gcc 4.2.1 - openscad compiled with no optimization
CGAL 3.6 - pass

PCBSD(Freebsd8) - gcc 4.2.1 - openscad compiled with -O2 -g
CGAL 3.6.1 - fail
CGAL 3.7 - fail
CGAL 3.8 - pass

-DB


On Fri, Dec 16, 2011 at 11:08 AM, Marius Kintel <[hidden email]> wrote:

> Hi Don,
>
> Thanks for exhaustive testing!
> A small addition to your list:
>
> ubuntu 11.04 - gcc 4.5.2 - tests compiled with -O2 -g
> CGAL 3.6.1 - pass
>
>  -Marius
>
> _______________________________________________
> OpenSCAD mailing list
> [hidden email]
> http://rocklinux.net/mailman/listinfo/openscad

Reply | Threaded
Open this post in threaded view
|

Re: CGAL 3.6.1 causing errors, but CGAL 3.6.0 OK?

kintel
Administrator

On Dec 17, 2011, at 06:47 AM, Don Bright wrote:

> PCBSD(Freebsd8) - gcc 4.2.1 - openscad compiled with no optimization
> CGAL 3.6 - pass
>
> PCBSD(Freebsd8) - gcc 4.2.1 - openscad compiled with -O2 -g
> CGAL 3.6.1 - fail
> CGAL 3.7 - fail
> CGAL 3.8 - pass
>
OK, that is interesting:

Mac OS X - gcc 4.2.1 - test compiled with -O2 -g
CGAL 3.6.1 - pass

Note that CGAL itself was compiled with -O3 -NDEBUG (as is default):
c++  -frounding-math -fno-strict-aliasing -O3 -DNDEBUG -arch i386 -arch x86_64

Could you give me your CGAL compilation output? I feel these two platforms should have enough in common to be able to reproduce this failure on both.

 -Marius


Reply | Threaded
Open this post in threaded view
|

Re: CGAL 3.6.1 causing errors, but CGAL 3.6.0 OK?

donbright
On Sat, Dec 17, 2011 at 8:04 AM, Marius Kintel <[hidden email]> wrote:

>
> On Dec 17, 2011, at 06:47 AM, Don Bright wrote:
>
>> PCBSD(Freebsd8) - gcc 4.2.1 - openscad compiled with no optimization
>> CGAL 3.6 - pass
>>
>> PCBSD(Freebsd8) - gcc 4.2.1 - openscad compiled with -O2 -g
>> CGAL 3.6.1 - fail
>> CGAL 3.7 - fail
>> CGAL 3.8 - pass
>>
> OK, that is interesting:
>
> Mac OS X - gcc 4.2.1 - test compiled with -O2 -g
> CGAL 3.6.1 - pass
>
> Note that CGAL itself was compiled with -O3 -NDEBUG (as is default):
> c++  -frounding-math -fno-strict-aliasing -O3 -DNDEBUG -arch i386 -arch x86_64
>
> Could you give me your CGAL compilation output? I feel these two platforms should have enough in common to be able to reproduce this failure on both.
>
>  -Marius
>
> _______________________________________________
> OpenSCAD mailing list
> [hidden email]
> http://rocklinux.net/mailman/listinfo/openscad


It would appear that my theories are wrong.

Those last few BSD tests were done with the QT GUI not the regression
tests. So I redid it with the regression test. They pass under the
regression test, but still fail when running in the GUI.

CGAL compilation: http://pastebin.com/GpYUMgxs

OpenSCAD regression tests build: http://pastebin.com/eH1gwztd

OpenSCAD QT GUI build: http://pastebin.com/gNP9hiFB
(i know the link has /usr/local/lib first, but i have also re-linked
using CGAL/lib first, and the result is the same)

I think that eventually it would be simpler if OpenSCAD had one build
system. Essentially, with two build systems, the regression tests are
testing something that is not the same thing the user is going to see
when they run the GUI.

-DB

Reply | Threaded
Open this post in threaded view
|

Re: CGAL 3.6.1 causing errors, but CGAL 3.6.0 OK?

kintel
Administrator
On Dec 17, 2011, at 16:36 PM, Don Bright wrote:

> Those last few BSD tests were done with the QT GUI not the regression
> tests. So I redid it with the regression test. They pass under the
> regression test, but still fail when running in the GUI.
>
These all pass on Mac with the same compiler.
One idea: Could this be related to things like memory alignment of eigen2 vectors?
There is an #ifdef __APPLE__  in dxfdata.h. It might be that freebsd has something in common with Mac OS X in this respect.

> I think that eventually it would be simpler if OpenSCAD had one build
> system.

Yes, that would indeed simplify things.
I guess we'd have to do cmake, as we're starting to hit the limitations of what qmake can do.
cmake is a bit ugly to maintain though and the build system code is hard to read, so it requires good organization.
I'm mostly worried about failing to do reproducible builds as some of those Find macros are pretty convoluted and change with cmake versions.

 -Marius


Reply | Threaded
Open this post in threaded view
|

Re: CGAL 3.6.1 causing errors, but CGAL 3.6.0 OK?

donbright
i think this might finally nail it down. I noticed BSD regression test
for some reason had

-fno-strict-aliasing

but QT build did not. When I add that to the CXXFLAGs, everything
passes. the bug goes away. both on BSD on CGAL 3.6 with GCC 4.2, and
Linux on CGAL 3.5 with GCC 4.4, both regression tests and in the QT
GUI.

interesting link i found:

"Apple's GCC disables strict aliasing."

http://stackoverflow.com/questions/1225741/performance-impact-of-fno-strict-aliasing

-----


minimal example of bug, taken by whittling down example17.


difference() {
        polygon([ [ 1,1 ], [ 65,0 ], [ 10, 20 ] ]);
        circle(5);
}


F6 should show a triangle with a 'bite taken out of it'.

It actually shows a blank image.

---


Will try to submit a patch if you think this is the solution.


DB

Reply | Threaded
Open this post in threaded view
|

Re: CGAL 3.6.1 causing errors, but CGAL 3.6.0 OK?

Steven Dick


On Sat, Dec 17, 2011 at 1:38 PM, Don Bright <[hidden email]> wrote:
"Apple's GCC disables strict aliasing."

More interesting is this article:
 http://blog.worldofcoding.com/2010/02/solving-gcc-44-strict-aliasing-problems.html

which suggests using -Wstrict-aliasing=2  to find sloppy code likely to trigger problems.