Summary
Cyclic references between nested end-to-end flows are treated as successfully instantiated and can create cyclic instance graphs or unbounded recursion.
instantiateEndToEndFlow inserts the declarative flow into ete2info before processing its segments. processEndToEndFlow uses only containsKey to decide that a referenced flow is already instantiated. A reference back to a flow currently being processed therefore reuses its incomplete instance as if it were complete.
There is already a TODO in this path to detect cyclic dependencies between end-to-end flows.
Reproduction
Declare two end-to-end flows where a contains b and b contains a, and reference one of them from another flow or instantiate the containing implementation.
The instantiated model can contain EndToEndFlowInstance objects that recursively contain each other. Code that follows the first or last nested flow element can then recurse indefinitely or fail with a stack overflow.
Expected behavior
Instantiation should distinguish in-progress flows from completed cached flows, detect the cycle, report an instantiation diagnostic, and avoid retaining a cyclic or incomplete end-to-end flow instance graph.
Relevant code
core/org.osate.aadl2.instantiation/src/org/osate/aadl2/instantiation/CreateEndToEndFlowsSwitch.java, methods instantiateEndToEndFlow and processEndToEndFlow.
Summary
Cyclic references between nested end-to-end flows are treated as successfully instantiated and can create cyclic instance graphs or unbounded recursion.
instantiateEndToEndFlowinserts the declarative flow intoete2infobefore processing its segments.processEndToEndFlowuses onlycontainsKeyto decide that a referenced flow is already instantiated. A reference back to a flow currently being processed therefore reuses its incomplete instance as if it were complete.There is already a
TODOin this path to detect cyclic dependencies between end-to-end flows.Reproduction
Declare two end-to-end flows where
acontainsbandbcontainsa, and reference one of them from another flow or instantiate the containing implementation.The instantiated model can contain
EndToEndFlowInstanceobjects that recursively contain each other. Code that follows the first or last nested flow element can then recurse indefinitely or fail with a stack overflow.Expected behavior
Instantiation should distinguish in-progress flows from completed cached flows, detect the cycle, report an instantiation diagnostic, and avoid retaining a cyclic or incomplete end-to-end flow instance graph.
Relevant code
core/org.osate.aadl2.instantiation/src/org/osate/aadl2/instantiation/CreateEndToEndFlowsSwitch.java, methodsinstantiateEndToEndFlowandprocessEndToEndFlow.