Archived OpenModelica forums. Posting is disabled.

Alternative forums include GitHub discussions or StackOverflow (make sure to read the Stack Overflow rules; you need to have well-formed questions)


Forgot password? | Forgot username? | Register

Stack Overflow with replaceable packages

Stack Overflow with replaceable packages

Hello,

I'm getting a Stack Overflow error when using inheritance and replaceable packages in OM r10622 (latest). This error happens also at least in r10615. I think it worked in some older versions, but I cannot ensure that. Of course I think the code is legal in modelica.

The simple code leading to the error is the following (perhaps it can be further simplified):

partial package MyPartialPackage
  replaceable partial function myFunction
    input Real a;
    output Real b;
  end myFunction;
end MyPartialPackage;

package MyExtendingPackage
  extends MyPartialPackage;
  redeclare function extends myFunction
  algorithm
    b := a;
  end myFunction;
end MyExtendingPackage;

model MyModel
  replaceable package MyPackage = MyPartialPackage;
  Real x;
equation
    x = MyPackage.myFunction(1);
end MyModel;

partial model MyPartialModel
  replaceable package MyPackage = MyPartialPackage;
  MyModel myModel(redeclare package MyPackage = MyPackage);
end MyPartialModel;

model MyExtendingModel
  package MyPackage = MyExtendingPackage;
  extends MyPartialModel(redeclare package MyPackage = MyPackage);
end MyExtendingModel;


The results from checking with OMC (also simulating) are the following:

checkModel(MyModel);
"Check of MyModel completed successfully.
Class MyModel has 1 equation(s) and 1 variable(s).
1 of these are trivial equation(s).
"
checkModel(MyPartialModel);
"Check of MyPartialModel completed successfully.
[OMTestModel.mo:23:1-26:19:writable] Warning: Forcing full instantiation of partial class MyPartialModel during checkModel.
Class MyPartialModel has 1 equation(s) and 1 variable(s).
1 of these are trivial equation(s).
"
checkModel(MyExtendingModel);

Lookup.lookupClassInFrame_ExitCall_Env__avlTreeGet_SC208
Lookup.lookupClassInEnv_ExitCall_lookupClassInFrame_SC191
Util.setStatefulBoolean
.
.
. (hundreds of lines here)
.
.
Env.avlTreeGet_ExitCall_stringCompare_SC23
Stack overflow! Failing the current function stack chain until the stack overflow signal is caught!


I suppose this is a OM compiler bug, but perhaps it's something wrong in my code. Any comment/help on which can be the solution would be very appreciated.

Thank you very much in advance,

Javier.

Edited by: jgb - Dec-02-11 13:24:39

Re: Stack Overflow with replaceable packages

Hi,

Yes, this is a bug.
You can circumvent it by using this model:

Code:


model MyExtendingModel
  package MyPackage = MyExtendingPackage;
  extends MyPartialModel(redeclare package MyPackage = MyExtendingPackage/*MyPackage*/);
end MyExtendingModel;

I'll look more into why this happens.

Cheers,
Adrian Pop/

There are 0 guests and 0 other users also viewing this topic
You are here: