Opened 12 years ago

Closed 12 years ago

#1957 closed defect (fixed)

Modelica.Mechanics.MultiBody.Examples.Elementary.Surfaces

Reported by: Christian Schubert Owned by: Martin Sjölund
Priority: high Milestone: 1.9.0
Component: Backend Version: trunk
Keywords: omc crash MultiBody Cc: Martin Sjölund

Description

When running the MSL 3.2.1 testsuite the omc crashes at Modelica.Mechanics.MultiBody.Examples.Elementary.Surfaces with both the new and the old instantiation. Nevertheless it outputs (run with +d=execstat)

*** Enter Main -> time: 0.0000024360162920769613, memory: 0.001953125/20.0 MB (0.009765625%)
true
true
true
a->dim_size[0] != b->dim_size[0], 57 != 64
Assertion failed: base_array_shape_eq(source, dest), file util/real_array.c, line 129

This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.

Change History (9)

comment:1 by Martin Sjölund, 12 years ago

This is expected. The code is legal but written in such a way that a Modelica tool should crash during simulation time. Go figure.

comment:2 by Jens Frenkel, 12 years ago

If you call with +d=execstat you can see that it does not crash during simulation. It crashes in the FrontEnd. This couldn't be wanted?

*** Enter Main -> time: 0.000006926949845237357, memory: 0.003070831298828125/20
.0 MB (0.015354156494140625%)
true
true
true
a->dim_size[0] != b->dim_size[0], 57 != 64
Assertion failed: base_array_shape_eq(source, dest), file util/real_array.c, lin
e 129

This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.

comment:3 by Adrian Pop, 12 years ago

I'll look into this as it need more investigation.
Looks like maybe some redeclares or modifiers are not passed correctly.

Cheers,
Adrian Pop/

comment:4 by Adrian Pop, 12 years ago

As far as I can see until now this is a bug on our part as we call function:
Modelica.Mechanics.MultiBody.Visualizers.Advanced.PipeWithScalarField.colorMap
with n_colors = 64 instead of the n_colors = 32 given by modifier.
I'll dig up more.

comment:5 by Martin Sjölund, 12 years ago

The following is a patch for the problem with the array-dimensions in the jet function, but it cannot be used without breaking the frontend for MSL 3.1. From what little time I spent locating that bug, it seems to be due to having something like:

paramater Real x[:] = {15};
paramater Real y[1] = if cond then {1} else x;

So we do not yet know the dimension of x and thus crap out later in type-checking. Maybe I should just force it to evaluate parameter expressions with unknown dimensions...

  • Compiler/FrontEnd/Static.mo

     
    1179611796    case (cache,env,e1,DAE.PROP(type_ = t1,constFlag = c1),e2,DAE.PROP(type_ = t2,constFlag = c2),e3,DAE.PROP(type_ = t3,constFlag = c3),impl,st,_, _)
    1179711797      equation
    1179811798        (e1,_) = Types.matchType(e1, t1, DAE.T_BOOL_DEFAULT, true);
     11799        (t2,t3) = Types.ifExpMakeDimsUnknown(t2,t3);
    1179911800        (e2_1,t2_1) = Types.matchType(e2, t2, t3, true);
    1180011801        c = constIfexp(e1, c1, c2, c3) "then-part type converted to match else-part" ;
    1180111802        (cache,exp) = cevalIfexpIfConstant(cache,env, e1, e2_1, e3, c1, impl, st, inInfo);
     
    1180511806    case (cache,env,e1,DAE.PROP(type_ = t1,constFlag = c1),e2,DAE.PROP(type_ = t2,constFlag = c2),e3,DAE.PROP(type_ = t3,constFlag = c3),impl,st,_, _)
    1180611807      equation
    1180711808        (e1,_) = Types.matchType(e1, t1, DAE.T_BOOL_DEFAULT, true);
     11809        (t2,t3) = Types.ifExpMakeDimsUnknown(t2,t3);
    1180811810        (e3_1,t3_1) = Types.matchType(e3, t3, t2, true);
    1180911811        c = constIfexp(e1, c1, c2, c3) "else-part type converted to match then-part" ;
    1181011812        (cache,exp) = cevalIfexpIfConstant(cache,env, e1, e2, e3_1, c1, impl, st, inInfo);
  • Compiler/FrontEnd/Types.mo

     
    74637463  end match;
    74647464end classTypeEqualIfRecord;
    74657465
     7466public function ifExpMakeDimsUnknown "If one branch of an if-expression has truly unknown dimensions they both will need to return unknown dimensions for type-checking to work"
     7467  input DAE.Type ty1;
     7468  input DAE.Type ty2;
     7469  output DAE.Type oty1;
     7470  output DAE.Type oty2;
     7471algorithm
     7472  (oty1,oty2) := match (ty1,ty2)
     7473    local
     7474      DAE.Type inner1,inner2;
     7475      DAE.TypeSource ts1,ts2;
     7476      DAE.Dimensions dims2;
     7477      DAE.Dimension d;
     7478    case (DAE.T_ARRAY(ty=inner1,dims={DAE.DIM_UNKNOWN()},source=ts1),DAE.T_ARRAY(ty=inner2,dims={_},source=ts2))
     7479      equation
     7480        (oty1,oty2) = ifExpMakeDimsUnknown(inner1,inner2);
     7481      then (DAE.T_ARRAY(inner1,DAE.DIM_UNKNOWN()::{},ts1),DAE.T_ARRAY(inner2,DAE.DIM_UNKNOWN()::{},ts2));
     7482    case (DAE.T_ARRAY(ty=inner1,dims={_},source=ts1),DAE.T_ARRAY(ty=inner2,dims={DAE.DIM_UNKNOWN()},source=ts2))
     7483      equation
     7484        (oty1,oty2) = ifExpMakeDimsUnknown(inner1,inner2);
     7485      then (DAE.T_ARRAY(inner1,DAE.DIM_UNKNOWN()::{},ts1),DAE.T_ARRAY(inner2,DAE.DIM_UNKNOWN()::{},ts2));
     7486    case (DAE.T_ARRAY(ty=inner1,dims={_},source=ts1),DAE.T_ARRAY(ty=inner2,dims={_},source=ts2))
     7487      equation
     7488        (oty1,oty2) = ifExpMakeDimsUnknown(inner1,inner2);
     7489      then (DAE.T_ARRAY(inner1,DAE.DIM_UNKNOWN()::{},ts1),DAE.T_ARRAY(inner2,DAE.DIM_UNKNOWN()::{},ts2));
     7490    else (ty1,ty2);
     7491  end match;
     7492end ifExpMakeDimsUnknown;
     7493
    74667494public function fixUnknownDimensions "Fixes unknown dimensions by getting hints from the final expression"
    74677495  input DAE.Type ty1;
    74687496  input DAE.Type ty2 "Simplified type, but might have more dimensions known";

comment:6 by Martin Sjölund, 12 years ago

r14707 now manages Modelica.Mechanics.MultiBody.Visualizers.Colors.ColorMaps.jet fine. So one step down.

comment:7 by Martin Sjölund, 12 years ago

The following is the library diff that makes Surfaces simulate:

  • MultiBody/Visualizers.mo

     
    21772177        "Function defining the color map"
    21782178              annotation(choicesAllMatching=true, Dialog(group="Color coding"));
    21792179    protected
    2180       parameter Real colorMapData[n_colors,3] = colorMap(n_colors) annotation(HideResult=true);
     2180      parameter Real colorMapData[:,3] = colorMap(n_colors) annotation(HideResult=true);
    21812181      Surface surface(
    21822182        R=R,
    21832183        r_0=r_0,

It should be possible to instead fix the typing of the function to realize that the type Real[n_colors,3] that colorMap(n_colors) returns is a parameter expression that we can force evaluation on. Note: The error-message given by omc is nowhere close to the real problem, which only showed up when I ran instantiateModel directly on Advanced.PipeWithScalarField.

Last edited 12 years ago by Martin Sjölund (previous) (diff)

comment:8 by Martin Sjölund, 12 years ago

Owner: changed from Adrian Pop to Martin Sjölund
Status: newassigned

comment:9 by Martin Sjölund, 12 years ago

Resolution: fixed
Status: assignedclosed

Fixed in r14708. Someone should update the test to use the reference file.

Note: See TracTickets for help on using tickets.