Opened 4 years ago

Closed 4 years ago

#5979 closed defect (fixed)

OMEdit dies when checking model with mutually recursive constants

Reported by: johti17 Owned by: perost
Priority: critical Milestone: 1.16.0
Component: OMEdit Version: v1.16.0-dev
Keywords: Cc: sjoelund.se, adrpo, perost, adeas31

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 Changed 4 years ago by johti17

  • Cc adeas31 added

comment:2 Changed 4 years ago by casella

  • Component changed from *unknown* to OMEdit
  • Milestone changed from Future to 1.16.0
  • Owner changed from somebody to adeas31
  • Priority changed from high to critical
  • Status changed from new to assigned

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 Changed 4 years ago by sjoelund.se

My OMEdit does not seem to crash at least

comment:4 follow-up: Changed 4 years ago by johti17

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?

comment:5 in reply to: ↑ 4 Changed 4 years ago by sjoelund.se

Replying to johti17:

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

Yes

comment:6 Changed 4 years ago by perost

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 Changed 4 years ago by casella

  • Owner changed from adeas31 to perost

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 Changed 4 years ago by casella

  • Resolution set to fixed
  • Status changed from assigned to closed
Note: See TracTickets for help on using tickets.