Bug 527165 - code generator generates duplicate code for internal self transitions
Summary: code generator generates duplicate code for internal self transitions
Status: NEW
Alias: None
Product: Papyrus-rt
Classification: Modeling
Component: codegen (show other bugs)
Version: 1.0.0   Edit
Hardware: PC Windows 7
: P3 normal
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 528164 (view as bug list)
Depends on:
Blocks:
 
Reported: 2017-11-12 12:28 EST by Juergen Dingel CLA
Modified: 2017-12-13 13:32 EST (History)
2 users (show)

See Also:


Attachments
smallest model triggering the bug (5.86 KB, application/x-zip-compressed)
2017-11-12 12:28 EST, Juergen Dingel CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Juergen Dingel CLA 2017-11-12 12:28:06 EST
Created attachment 271425 [details]
smallest model triggering the bug

When, 
- using an internal self transition with a non-empty effect, 
- inside a composite state that has at least two states, 
then, 
the code generator generates duplicate code, i.e., the 
generated code contains the definition of the associated
actionchain twice: 

from Top.hh:
>    void actionchain_____State1__timeout1( const UMLRTMessage * msg );
>    void actionchain_____State1__timeout1( const UMLRTMessage * msg );

When, either
- the number of substates in the composite state is reduced to one, or
- the effect is removed from the internal self transition, 
the bug does not occur. 

The model in the attachment is pretty much as small as I could make it.
Comment 1 Ernesto Posse CLA 2017-12-05 10:46:04 EST
*** Bug 528164 has been marked as a duplicate of this bug. ***
Comment 2 Ernesto Posse CLA 2017-12-13 13:32:22 EST
Confirmed.

The duplicated functions are the *actionchain* functions, not the *transitionaction* functions.

The problem is in the way we handle internal transitions in the state machine flattener. Specifically, we "push-down" all internal transitions to the simple states, which produces a state machine with the same behaviour. However, when we do that, for every internal transition, we create a new self transition in each simple state with a copy of its ActionChain, specifically at

org.eclipse.papyrusrt.codegen.statemachines.transformations.StateNestingFlattener.copyInternalTransitions(SimpleState, Iterable<Transition>)

This action chain is created with a reference to the TransitionAction, which means that only one transition action is generated, but multiple copies of the action chain functions are generated.