Skip to content

Commit c15e7bd

Browse files
Willi BraunOpenModelica-Hudson
authored andcommitted
[Backend] prevent stackoverflow for recursive function differentiation
Belonging to [master]: - OpenModelica/OMCompiler#2196 - OpenModelica/OpenModelica-testsuite#854
1 parent 815ffe0 commit c15e7bd

File tree

3 files changed

+287
-268
lines changed

3 files changed

+287
-268
lines changed

Compiler/BackEnd/BackendDAE.mo

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ encapsulated package BackendDAE
3636
"
3737

3838
import Absyn;
39+
import AvlSetPath;
3940
import DAE;
4041
import DoubleEndedList;
4142
import ExpandableArray;
@@ -775,10 +776,11 @@ uniontype DifferentiateInputData
775776
list< Var> controlVars; // variables to save control vars of for algorithm
776777
list< .DAE.ComponentRef> diffCrefs; // all crefs to differentiate, needed for generic gradient
777778
Option<String> matrixName; // name to create temporary vars, needed for generic gradient
779+
AvlSetPath.Tree diffedFunctions; // current functions, to prevent recursive differentiation
778780
end DIFFINPUTDATA;
779781
end DifferentiateInputData;
780782

781-
public constant DifferentiateInputData emptyInputData = DIFFINPUTDATA(NONE(),NONE(),NONE(),NONE(),{},{},NONE());
783+
public constant DifferentiateInputData emptyInputData = DIFFINPUTDATA(NONE(),NONE(),NONE(),NONE(),{},{},NONE(),AvlSetPath.EMPTY());
782784

783785
public
784786
type DifferentiateInputArguments = tuple< .DAE.ComponentRef, DifferentiateInputData, DifferentiationType, .DAE.FunctionTree>;

0 commit comments

Comments
 (0)