Release mode break the program



I’m working with Visual Studio 2010 and RhinoCommon with c#.

I’ve developed a process that works fine in debug mode, but in release mode Rhino is break.

I’ve detected that the process break in this point

Curve result = Curve.JoinCurves(new Curve[] { curva1, union, corner_, curva2 }, 0.000000001, true)[0];

I don’t use threads, and I don`t know how to solve this problem

(Menno Deij - van Rijswijk) #2

It is possible that Curve.JoinCurves returns null or an empty array. So, before you apply the [0] index operator, first check if the result is not null and has content:

Curve[] joined = Curve.JoinCurves(new Curve[] { curva1, union, corner_, curva2 }, 0.000000001, true);
Curve result = null;
if (null != joined && joined.Length > 0)
    result = joined[0];



It not works in release

if I put this code

Curve[] joined = Curve.JoinCurves(curvesUnion, 0.000000001, true);

The MessageBox.Show(“2”) is not executed in release mode, but in Debug mode it works fine

If I envolve this code in try…catch no exception is raised

(Dale Fugier) #4

Why such a tight tolerance (0.000000001)? Most joining operations use 2.1 * the document’s absolute tolerance…


I’ve changed the tolerance to 2, but I release em mode still does not work

I have disabled also the optimizer code for release and removed all warnings.

Do not know what else to do :S

(Menno Deij - van Rijswijk) #6

It starts to sound like a bug in Rhino or RhinoCommon to me. Does this happen with any curves in your code, or just a specific example?

One thing to check, if you haven’t done so already: are all the input curves 1) not null and 2) valid and 3) not short?

private bool CheckInput(IEnumerable<Curve> curvesUnion, double tolerance) {
foreach(Curve crv in curvesUnion)
    if (null == crv) 
        RhinoApp.WriteLine("one of the curves is NULL");
        return false;

    String err;
    if (!crv.IsValidWithLog(out err))
        RhinoApp.WriteLine("One of the curves is not valid: "+err);
        return false;
    if (crv.IsShort(tolerance))
        RhinoApp.WriteLine("one of the curves is too short");
        return false;




This error appears only in this process, in others parts of code works fine.

This process is for making a polish cycle over marble. The cycle consist in doing spirals over the surface to get the polish.

I attach a picture to represent what the process does. This picture is obtained executed the process in Debug mode with Visual Studio

The selected path is the representation of the polish cycle 3

Attaching your code, I’ve detect that if I put a toleance value greater that 0.1 I get the erro “one of the curves is too short”.

In release mode, the polish cycle is broken and the toolpath is not generated. No exception is throwed

(Steve Baer) #8

This doesn’t make a whole lot of sense since debug and release builds are running against the exact same Rhino executable. One thing I notice from your screenshots is that it looks like you have a skin running in your release build and not in your debug build. What happens if you run your plug-in without the skin?

(Steve Baer) #9

Also, does your document have the same tolerances in both debug and release?


Yes, tolerances are the same.

I’ve executed the code in release without the skin and works fine!!!

I never would have guessed that the skin failed and I was already going crazy

Thank you very much!