Opened 5 years ago

Closed 4 years ago

#5979 closed defect (fixed)

OMEdit dies when checking model with mutually recursive constants

Reported by: John Tinnerholm Owned by: Per Östlund
Priority: critical Milestone: 1.16.0
Component: OMEdit Version: v1.16.0-dev
Keywords: Cc: Martin Sjölund, Adrian Pop, Per Östlund, Adeel Asghar

Description

Consider the following model

package UT
  constant Real CONST1 = CONST2 * 3;
  constant Real CONST2 = CONST1 + 3;
  function f
    output Real ro;
  algorithm
    ro := CONST1 + CONST2;
  end f;
end UT;

I am on Windows using
OpenModelica v1.16.0-dev-170-g3af6123f8 (64-bit)

If I do check model using the new frontend from the GUI OMEdit dies without prompting the user. It seems to do this no matter if I use NF or OF.

If I run the regular

omc test.mo

I get the expected error message:

C:\Users\johti17\Documents>omc test.mo
Error processing file: test.mo
Error: Cyclically dependent constants or parameters found in scope UT: {CONST2,CONST1} (ignore with -d=ignoreCycles).
Error: Error occurred while flattening model UT

# Error encountered! Exiting...
# Please check the error message and the flags.

Execution failed!

Thanks to Martin who made me test it:)

Change History (8)

comment:1 by John Tinnerholm, 5 years ago

Cc: Adeel Asghar added

comment:2 by Francesco Casella, 5 years ago

Component: *unknown*OMEdit
Milestone: Future1.16.0
Owner: changed from somebody to Adeel Asghar
Priority: highcritical
Status: newassigned

I understand the check option doesn't really work well on packages, but in any case it seems the issue is with OMEdit, so I'd assign it to @adeas31

comment:3 by Martin Sjölund, 4 years ago

My OMEdit does not seem to crash at least

comment:4 by John Tinnerholm, 4 years ago

Hmm just tried again with my development version of 1.16: v1.16.0-dev-170-g3af6123f8
I will install the new version on Windows. Maybe it was fixed due to the other fixes relating to mutual recursion and or some other frontend fix.

@sjoelund.se does it work with both NF and OF?

in reply to:  4 comment:5 by Martin Sjölund, 4 years ago

Replying to johti17:

@sjoelund.se does it work with both NF and OF?

Yes

comment:6 by Per Östlund, 4 years ago

It shouldn't work with the NF since it doesn't yet check for mutually recursive constants/parameters, and as expected it crashes with a stack overflow for me.

I've fixed that issue in PR 6701 by checking that the NF doesn't try to evaluate a binding that it's already trying to evaluate. We still need to implement a check for mutually recursive parameters in the flat model, but this should fix any crashes at least.

comment:7 by Francesco Casella, 4 years ago

Owner: changed from Adeel Asghar to Per Östlund

I just checked the function with the latest nightly build of OMEdit, which uses the NF by default, and I get

[1] 20:15:21 Translation Error
[M: 2:3-2:36]: Variable 'CONST1' has a cyclic dependency and has variability constant.

I understand the issue has been fixed by PR 6071. @johti17, feel free to reopen if you see any remaining problem.

comment:8 by Francesco Casella, 4 years ago

Resolution: fixed
Status: assignedclosed
Note: See TracTickets for help on using tickets.