Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Action goal state machine tests #311

Merged
merged 9 commits into from
Oct 30, 2018
Merged

Conversation

jacobperron
Copy link
Member

Connects to #306.

As a follow up, we might consider replacing the hard-coded transition map with the more general one in rcl_lifecycle. This would involve moving the general transition map to a common package like rcutils.

@jacobperron jacobperron added the in progress Actively being worked on (Kanban column) label Oct 29, 2018
@jacobperron
Copy link
Member Author

  • Linux Build Status
  • Linux-aarch64 Build Status
  • macOS Build Status
  • Windows Build Status

@jacobperron jacobperron mentioned this pull request Oct 29, 2018
10 tasks
@jacobperron
Copy link
Member Author

Attempt to fix MSVC compiler warnings:

  • Linux Build Status
  • Linux-aarch64 Build Status
  • macOS Build Status
  • Windows Build Status

@jacobperron jacobperron added in review Waiting for review (Kanban column) and removed in progress Actively being worked on (Kanban column) labels Oct 30, 2018
},
};
static rcl_action_goal_event_handler
_goal_state_transition_map[GOAL_STATE_NUM_STATES][GOAL_EVENT_NUM_EVENTS];
Copy link
Contributor

@hidmic hidmic Oct 30, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jacobperron just out of curiosity, what was wrong about the previous direct initialization?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When the direct initialization gets included in C++ (e.g. gtest), then gcc complains about a sparsely populated 2d array. But we might be able to use null pointers in the direct initialization instead of this init function.

Copy link
Member Author

@jacobperron jacobperron Oct 30, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moving the direct initialization to the C file got rid of the compiler warnings :)

_goal_state_transition_map[GOAL_STATE_NUM_STATES][GOAL_EVENT_NUM_EVENTS];

static inline void
rcl_action_goal_transition_map_init()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jacobperron Why are we using static linkage for these? Why not defining them on goal_state_machine.c ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, agreed; for a large function like this, making it static inline is bloating the downstream users for not a lot of reason. This is probably better as a function inside a C file.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In retrospect, I think all of these static functions and the transition map can be moved to a C file.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1, you should move as much out of the public interface as is possible/reasonable.

{
// Only run this function once
static bool _is_goal_state_transition_map_init = false;
if (_is_goal_state_transition_map_init) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this could be called from multiple threads, there is a TOCTTOU bug here; thread 1 could have read the state of _is_goal_state_transition_map_init as false then been swapped out, then thread 2 could read the state of _is_goal_state_transition_map as false, and do the initialization. Then when thread 1 wakes back up, it still thinks that it needs to do the initialization, and does it again.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moving the initialization to the C file let me do a direct initialization, so I believe this issue goes away.

@jacobperron
Copy link
Member Author

#315 should fix the unstable windows build. I'll rebase once it's merged.

Copy link
Contributor

@hidmic hidmic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

}

// Transition map
rcl_action_goal_event_handler
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jacobperron nit: this one could be static.

@jacobperron jacobperron force-pushed the action_goal_state_machine_tests branch from b63275b to 6a8750e Compare October 30, 2018 17:43
@jacobperron
Copy link
Member Author

Reviews addressed and rebased on master:

  • Linux Build Status
  • Linux-aarch64 Build Status
  • macOS Build Status
  • Windows Build Status

@jacobperron jacobperron self-assigned this Oct 30, 2018
Copy link
Contributor

@hidmic hidmic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@jacobperron jacobperron merged commit 29e7dbe into master Oct 30, 2018
@jacobperron jacobperron deleted the action_goal_state_machine_tests branch October 30, 2018 23:15
@jacobperron jacobperron removed the in review Waiting for review (Kanban column) label Oct 30, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants