magazino / move_base_flex

Move Base Flex: a backwards-compatible replacement for move_base
https://uos.github.io/mbf_docs/
BSD 3-Clause "New" or "Revised" License
434 stars 154 forks source link

Race condition when updating goal for ExePath #295

Closed RainerKuemmerle closed 2 years ago

RainerKuemmerle commented 2 years ago

The following is run in a thread

//AbstractActionBase
  virtual void run(ConcurrencySlot &slot)
  {
    slot.execution->preRun();
    runImpl(slot.goal_handle, *slot.execution);
    ROS_DEBUG_STREAM_NAMED(name_, "Finished action \"" << name_ << "\" run method, waiting for execution thread to finish.");
    slot.execution->join();
    ROS_DEBUG_STREAM_NAMED(name_, "Execution completed with goal status "
                           << (int)slot.goal_handle.getGoalStatus().status << ": "<< slot.goal_handle.getGoalStatus().text);
    slot.execution->postRun();
    slot.in_use = false;
  }

ControllerAction::start uses the boolean slot.in_use to see that the thread is still running. see https://github.com/magazino/move_base_flex/blob/master/mbf_abstract_nav/src/controller_action.cpp#L69 But it is used to infer whether we are still in runImpl, i.e., the goal is active and the exe_path controller is processing it.

The race condition is the following sequence:

Unfortunately, the node was not running with a log-level of debug when we hit the race condition. So I do not have the log about "Finished action ...".