Syntax error in used file causes a crash

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

Syntax error in used file causes a crash

nophead
If you load this file you get a syntax error because the function needs parentheses.

used.scad:
function s = 20;

module used(r) {
 sphere(r);
}

but if you load this one you get a crash

use.scad:
use <used.scad>

used(s());

I made these files to try to recreate the bug that causes my project to crash when I change some of the included files and reload. It can be as little as a white space change. I haven't been able to recreate it in a small example but it doesn't occur when I clear the cache before reloading. It might be something to do with my project filling the cache. Not every included file will cause the crash but an increasing number are doing so now more do than don't.








Reply | Threaded
Open this post in threaded view
|

Re: Syntax error in used file causes a crash

kintel
Administrator

On Jan 8, 2012, at 12:56 PM, nop head wrote:

> If you load this file you get a syntax error because the function needs parentheses.
>
AFACS, this is the same bug as you reported earlier: "used file not found" and "used file doesn't compile" both trigger the same bug.
The fix for this was merged into master Jan 4, in commit 9856607d278.

Brad: Would you have time to push updated Windows development binaries to let nop head test that the bug is gone?

 -Marius


Reply | Threaded
Open this post in threaded view
|

Re: Syntax error in used file causes a crash

Brad Pitcher

No problem, I'll do it later today.

On Jan 8, 2012 4:38 AM, "Marius Kintel" <[hidden email]> wrote:

On Jan 8, 2012, at 12:56 PM, nop head wrote:

> If you load this file you get a syntax error because the function needs parentheses.
>
AFACS, this is the same bug as you reported earlier: "used file not found" and "used file doesn't compile" both trigger the same bug.
The fix for this was merged into master Jan 4, in commit 9856607d278.

Brad: Would you have time to push updated Windows development binaries to let nop head test that the bug is gone?

 -Marius

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://rocklinux.net/mailman/listinfo/openscad
Reply | Threaded
Open this post in threaded view
|

Re: Syntax error in used file causes a crash

Brad Pitcher
I've updated the windows development snapshot. Please try to reproduce using it, nop head.

On Sun, Jan 8, 2012 at 7:21 AM, Brad Pitcher <[hidden email]> wrote:

No problem, I'll do it later today.

On Jan 8, 2012 4:38 AM, "Marius Kintel" <[hidden email]> wrote:

On Jan 8, 2012, at 12:56 PM, nop head wrote:

> If you load this file you get a syntax error because the function needs parentheses.
>
AFACS, this is the same bug as you reported earlier: "used file not found" and "used file doesn't compile" both trigger the same bug.
The fix for this was merged into master Jan 4, in commit 9856607d278.

Brad: Would you have time to push updated Windows development binaries to let nop head test that the bug is gone?

 -Marius

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://rocklinux.net/mailman/listinfo/openscad

Reply | Threaded
Open this post in threaded view
|

Re: Syntax error in used file causes a crash

nophead
Yes that comes up with "ignoring unknown function s" and "ignoring unknown module used" and does not crash.

Thanks.

On 8 January 2012 16:26, Brad Pitcher <[hidden email]> wrote:
I've updated the windows development snapshot. Please try to reproduce using it, nop head.


On Sun, Jan 8, 2012 at 7:21 AM, Brad Pitcher <[hidden email]> wrote:

No problem, I'll do it later today.

On Jan 8, 2012 4:38 AM, "Marius Kintel" <[hidden email]> wrote:

On Jan 8, 2012, at 12:56 PM, nop head wrote:

> If you load this file you get a syntax error because the function needs parentheses.
>
AFACS, this is the same bug as you reported earlier: "used file not found" and "used file doesn't compile" both trigger the same bug.
The fix for this was merged into master Jan 4, in commit 9856607d278.

Brad: Would you have time to push updated Windows development binaries to let nop head test that the bug is gone?

 -Marius

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://rocklinux.net/mailman/listinfo/openscad


_______________________________________________
OpenSCAD mailing list
[hidden email]
http://rocklinux.net/mailman/listinfo/openscad


Reply | Threaded
Open this post in threaded view
|

Re: Syntax error in used file causes a crash

kintel
Administrator
On Jan 8, 2012, at 17:45 PM, nop head wrote:

> Yes that comes up with "ignoring unknown function s" and "ignoring unknown module used" and does not crash.
>
Good :)

In related news - the reason large designs crash is definitely a cache-related issue and I've successfully reproduced this here.
I'm tinkering with ways to deal with this and hope to have something ready soon.

Basically, the problem is that if the top-level object itself is larger than the cache (100K vertices), it triggers an assertion failure.
However, that's not productive in terms of controlling memory usage since we've already allocated the memory for the top-level object by the time we're inserting it into the cache.

Another related issue is cache size management, which I'll also deal with at the same time (as a minimum making it configurable).

All this shows up now since the cache handling was rewritten since the previous release, and none of our tests exercise these limits.

 -Marius


Reply | Threaded
Open this post in threaded view
|

Re: Syntax error in used file causes a crash

nophead


On 8 January 2012 17:12, Marius Kintel <[hidden email]> wrote:
On Jan 8, 2012, at 17:45 PM, nop head wrote:

> Yes that comes up with "ignoring unknown function s" and "ignoring unknown module used" and does not crash.
>
Good :)

In related news - the reason large designs crash is definitely a cache-related issue and I've successfully reproduced this here.
I'm tinkering with ways to deal with this and hope to have something ready soon.

Basically, the problem is that if the top-level object itself is larger than the cache (100K vertices), it triggers an assertion failure.
However, that's not productive in terms of controlling memory usage since we've already allocated the memory for the top-level object by the time we're inserting it into the cache.
 
Wouldn't I get that if I changed anything affecting the top level? 

I get it when I change certain files that the top level uses, but not others. More complex files seem to cause it but I don't know what specifically. As I hack on the design and it gets more detailed more of the used files will cause the crash. Anything I change in the top level file seems to be OK though, and it is quite big itself with a lot of modules that are sub assembles of parts coming from the other files.


Another related issue is cache size management, which I'll also deal with at the same time (as a minimum making it configurable).

This what I am using at the moment: 

PolySets in cache: 628

Polygons in cache: 99291

CGAL Polyhedrons in cache: 1140

Vertices in cache: 99932

Compiling design (CSG Products normalization)...

Compiling background (1 CSG Trees)...

Normalized CSG tree has 943 elements

Will I hit any other limits soon?

 

All this shows up now since the cache handling was rewritten since the previous release, and none of our tests exercise these limits.

 -Marius

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://rocklinux.net/mailman/listinfo/openscad

Reply | Threaded
Open this post in threaded view
|

Re: Syntax error in used file causes a crash

kintel
Administrator
On Jan 8, 2012, at 19:55 PM, nop head wrote:

> Wouldn't I get that if I changed anything affecting the top level?
>
AFAIK, a crash (assert) will only happen if any one single object exceeds the entire max cache size.

If the sum of all objects in your design exceed the cache size, they will be thrown out based on a least-recently-used scheme, and will have to be regenerated in the future. However, since objects generated by multiple child objects are inherently used _after_ the child objects themselves, the cache will still be somewhat functional, until you change something low-level enough that you get cascading cache overruns all the way to the top. This is of course totally dependent on exactly what you change.

Ideally, the cache should be bigger than the sum of all individual objects used in your design. This should be easy to measure - one idea is to issue a warning if we detect that you might have a too small cache to get optimal caching behavior.

> This what I am using at the moment:
> PolySets in cache: 628
> Polygons in cache: 99291
> CGAL Polyhedrons in cache: 1140
> Vertices in cache: 99932
> Compiling design (CSG Products normalization)...
> Compiling background (1 CSG Trees)...
> Normalized CSG tree has 943 elements
> Will I hit any other limits soon?
>  
I'm pretty sure you've already hit the 100K polygon in PolySetCache and 100K vertices in CGALCache limits.
You'll soon hit the 1000 element CSG rendering limit.

 -Marius


Reply | Threaded
Open this post in threaded view
|

Re: Syntax error in used file causes a crash

nophead
Looks like all the limits should be twice as big ;-)

On 8 January 2012 19:11, Marius Kintel <[hidden email]> wrote:
On Jan 8, 2012, at 19:55 PM, nop head wrote:

> Wouldn't I get that if I changed anything affecting the top level?
>
AFAIK, a crash (assert) will only happen if any one single object exceeds the entire max cache size.

If the sum of all objects in your design exceed the cache size, they will be thrown out based on a least-recently-used scheme, and will have to be regenerated in the future. However, since objects generated by multiple child objects are inherently used _after_ the child objects themselves, the cache will still be somewhat functional, until you change something low-level enough that you get cascading cache overruns all the way to the top. This is of course totally dependent on exactly what you change.

Ideally, the cache should be bigger than the sum of all individual objects used in your design. This should be easy to measure - one idea is to issue a warning if we detect that you might have a too small cache to get optimal caching behavior.

> This what I am using at the moment:
> PolySets in cache: 628
> Polygons in cache: 99291
> CGAL Polyhedrons in cache: 1140
> Vertices in cache: 99932
> Compiling design (CSG Products normalization)...
> Compiling background (1 CSG Trees)...
> Normalized CSG tree has 943 elements
> Will I hit any other limits soon?
>
I'm pretty sure you've already hit the 100K polygon in PolySetCache and 100K vertices in CGALCache limits.
You'll soon hit the 1000 element CSG rendering limit.

 -Marius

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://rocklinux.net/mailman/listinfo/openscad

Reply | Threaded
Open this post in threaded view
|

Re: Syntax error in used file causes a crash

kintel
Administrator
On Jan 8, 2012, at 20:20 PM, nop head wrote:

> Looks like all the limits should be twice as big ;-)
>
I'm thinking more 10 x as big ;)

 -Marius