Opened 9 years ago

Last modified 7 years ago

#3495 accepted defect

Issue with array indices in generated code

Reported by: timo.lask@… Owned by: Mahder Alemseged Gebremedhin
Priority: high Milestone: Future
Component: Code Generation Version:
Keywords: Cc: Mahder Alemseged Gebremedhin

Description

I get the following output by the simulation of a Petri net model:

C:/Users/TKLEIN~1/AppData/Local/Temp/OpenModelica/OMEdit/PNlib2.Examples.TestWkeit.exe -port=51187 -logFormat=xml -override=startTime=0,stopTime=5,stepSize=0.01,tolerance=1e-6,solver=dassl,outputFormat=mat,variableFilter=.* -r=PNlib2.Examples.TestWkeit_res.mat -dasslJacobian=coloredNumerical -w -lv=LOG_STATS

scalar s->index[0][0] == 2456744 incorrect, a->dim_size[0] == 2

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

Simulation process failed. Exited with code 255.

Attachments (1)

TestWkeitTotal.mo (37.0 KB ) - added by Lennart Ochel 9 years ago.

Download all attachments as: .zip

Change History (14)

by Lennart Ochel, 9 years ago

Attachment: TestWkeitTotal.mo added

comment:1 by Lennart Ochel, 9 years ago

Component: UnknownCode Generation

This is the error message that I get:

Test.PNlib2_Examples_TestWkeit.o: In function `Test_PNlib2_Examples_TestWkeit_eqFunction_271':
Test.PNlib2_Examples_TestWkeit.c:(.text+0x40ee): undefined reference to `$PT2$Pactivation$PtIn_index'
Test.PNlib2_Examples_TestWkeit_functions.o: In function `omc_Test_PNlib2_Functions_Random_random':
Test.PNlib2_Examples_TestWkeit_functions.c:(.text+0xcf): undefined reference to `_random'
Test.PNlib2_Examples_TestWkeit_06inz.o: In function `Test_PNlib2_Examples_TestWkeit_eqFunction_74':
Test.PNlib2_Examples_TestWkeit_06inz.c:(.text+0x293e): undefined reference to `$PT2$Pactivation$PtIn_index'
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [omc_main_target] Error 1

comment:2 by Lennart Ochel, 9 years ago

The following model can be used as minimalistic test case to reproduce the issue:

model test
  function deleteElementInt "deletes an element of an integer vector"
    input Integer vecin[:];
    input Integer idx;
    output Integer vecout[size(vecin,1)];
  protected
    parameter Integer nVec= size(vecin,1);
  algorithm
    vecout[1:idx-1]:=vecin[1:idx-1];
    vecout[idx:nVec-1]:=vecin[idx+1:nVec];
    vecout[nVec]:=0;
  end deleteElementInt;

  Integer i[2];
algorithm
  i[1] := 3;
  i[2] := 4;
  i := deleteElementInt(i, 2);
end test;

The error message is as follows:

Simulation execution failed for model: test
scalar s->index[0][0] == 11636624 incorrect, a->dim_size[0] == 2
Aborted (core dumped)

comment:3 by Lennart Ochel, 9 years ago

Cc: Mahder Alemseged Gebremedhin added
Milestone: Future1.9.4
Priority: highcritical
Summary: Doesn‘t simulateIssue with array indices in generated code

comment:4 by Lennart Ochel, 9 years ago

This line causes the error if (idx == nVec) or (idx == 1):

vecout[idx:nVec-1]:=vecin[idx+1:nVec];
Last edited 9 years ago by Lennart Ochel (previous) (diff)

comment:5 by Lennart Ochel, 9 years ago

Priority: criticalhigh

I added a workaround to the PNlib (f6d864) which makes all atomic test cases working. However, it would be good to fix this anyway.

comment:6 by Mahder Alemseged Gebremedhin, 9 years ago

Owner: changed from Lennart Ochel to Mahder Alemseged Gebremedhin
Status: newaccepted

comment:7 by Lennart Ochel, 9 years ago

Mahder, can you please explain the issue? Do you think this could be fixed for milestone 1.9.4?

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

Milestone: 1.9.41.9.5

Milestone pushed to 1.9.5

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

Milestone: 1.9.51.10.0

Milestone renamed

comment:10 by Lennart Ochel, 9 years ago

This is still an issue (OpenModelica v1.10.0-dev-437-g5e9854e).

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

Milestone: 1.10.01.11.0

Ticket retargeted after milestone closed

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

Milestone: 1.11.01.12.0

Milestone moved to 1.12.0 due to 1.11.0 already being released.

comment:13 by Francesco Casella, 7 years ago

Milestone: 1.12.0Future

The milestone of this ticket has been reassigned to "Future".

If you think the issue is still valid and relevant for you, please select milestone 1.13.0 for back-end, code generation and run-time issues, or 2.0.0 for front-end issues.

If you are aware that the problem is no longer present, please select the milestone corresponding to the version of OMC you used to check that, and set the status to "worksforme".

In both cases, a short informative comment would be welcome.

Note: See TracTickets for help on using tickets.