Opened 10 years ago

Closed 10 years ago

Last modified 7 years ago

#3245 closed defect (fixed)

OMEdit crashes: When set record parameter in Function

Reported by: arnesinnema@… Owned by: Per Östlund
Priority: high Milestone: 1.9.4
Component: Run-time Version: trunk
Keywords: crash, record, function Cc:

Description (last modified by Per Östlund)

OMEdit crashes when a record parameter is set in a function (see code below), it looks very similar to bug #3082.

model TestRecord 
  function setRecordFunction 
    output Real[3] y; 
  protected 
    Rec[3] x; 
  algorithm 
    for i in 1:3 loop 
      x[i].r := i; 
      y[i] := x[i].r; 
    end for; 
  end setRecordFunction; 

  record Rec 
    Real r; 
  end Rec; 

  model CallRecordFunction 
    Real[3] y; 
    //Real[4] y2; 
  equation 
    y = setRecordFunction(); 
    //y2 = setRecordFunction2(4); 
  end CallRecordFunction; 

  function setRecordFunction2 
    input Integer N; 
    output Real[N] y; 
  protected 
    Rec[N] x; 
  algorithm 
    for i in 1:N loop 
      x[i].r := i; 
      y[i] := x[i].r; 
    end for; 
  end setRecordFunction2; 
end TestRecord;

Change History (5)

comment:1 by Jan Kokert, 10 years ago

Description: modified (diff)

comment:2 by Per Östlund, 10 years ago

Component: UnknownRun-time
Description: modified (diff)
Owner: changed from somebody to Per Östlund
Status: newaccepted

Seems like the run-time is having some issues with assigning record components like that. A workaround is to rewrite

for i in 1:3 loop
  x[i].r := i;
  y[i] := x[i].r;
end for;

as

x.r := 1:3;
y := x.r;

Of course, your example is simplified, so maybe it's not possible for you to get rid of the loop in your actual model.

comment:3 by Per Östlund, 10 years ago

Resolution: fixed
Status: acceptedclosed

Fixed in r25245.

comment:4 by Dietmar Winkler, 9 years ago

Milestone: Futurepre1.9.4

It doesn't make sense to keep closed ticket in the "Future" milestone that were simply forgotten to assign to the correct milestone in the past.

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

Milestone: pre1.9.41.9.4

Removing the pre1.9.4 milestone in favor of 1.9.4.

Note: See TracTickets for help on using tickets.