Skip to content

Commit

Permalink
Fix a concurrency problem in the multithreaded executor
Browse files Browse the repository at this point in the history
Both, the `Executor::execute_any_executable` and the destructor for the `AnyExecutable` object used by the multithreaded executor, reset the `can_be_taken_from_` flag on a MutuallyExclusive group. This cause the variable to get out of sync and threads to process executables out of sequence.

This fix clears the callback group variable of the `AnyExecutable` instance effectively preventing its destructor from modifying the variable at the wrong time.

Issue: #702
Signed-off-by: Guillaume Autran <gautran@clearpath.ai>
  • Loading branch information
guillaumeautran committed Apr 18, 2019
1 parent 60996d1 commit 5a5a76a
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions rclcpp/src/rclcpp/executors/multi_threaded_executor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,5 +101,8 @@ MultiThreadedExecutor::run(size_t)
scheduled_timers_.erase(it);
}
}
// Clear the callback_group to prevent the AnyExecutable destructor from
// resetting the callback group `can_be_taken_from`
any_exec.callback_group.reset();
}
}

0 comments on commit 5a5a76a

Please sign in to comment.