lf-lang / lingua-franca

Intuitive concurrent programming in any language
https://www.lf-lang.org
Other
238 stars 63 forks source link

Mode transition fails to trigger in some cases #1433

Closed edwardalee closed 1 month ago

edwardalee commented 2 years ago

I found a simple modal model where a transition fails to trigger when it should. This is checked into the transition-trigger branch here:

https://github.com/lf-lang/lingua-franca/blob/transition-trigger/test/C/src/modal_models/TransitionTrigger.lf

Even stranger, if you uncomment the empty reaction on line 24, then the test passes. This reaction should really have no effect.

a-sr commented 2 years ago

I was able to further boil down the issue and it is not related to modes, see TransitionTrigger2.

It seems no reaction in the Destination reactor that only has y as a trigger, will be executed. Only if there is a reaction that has y and x suddenly the y trigger works again, despite the fact that x is never set.

I had a look at the generated code and it seems the triggering relation are correctly set up.

// Iterate over ranges TransitionTrigger2.ui.y(0,1)->[TransitionTrigger2.dlc.y(0,1)] and TransitionTrigger2.dlc.y(0,1).
...
// Point to destination port TransitionTrigger2.dlc.y's trigger struct.
transitiontrigger2_ui_self[src_runtime]->_lf__reaction_0.triggers[triggers_index[src_runtime] + src_channel][0] = &transitiontrigger2_dlc_self[dst_runtime]->_lf__y;

However, at runtime the log says that there are no reactions to trigger.

LOG: Worker 0: Invoking reaction TransitionTrigger2.ui reaction 0 at elapsed tag (0, 0).
S
DEBUG: There are 2 outputs from reaction TransitionTrigger2.ui reaction 0.
DEBUG: Output 1 has been produced.
DEBUG: There are 0 trigger arrays associated with output 1.

Maybe the output to trigger association is not correct because x is not connected to any downstream reaction? I am sorry but I don't know where to look next.

soerendomroes commented 4 months ago

@lhstrh This ticket and that one https://github.com/lf-lang/lingua-franca/issues/1489 should be tackled in the next release.

edwardalee commented 1 month ago

This is fixed with #2416.