Skip to content

Commit d810987

Browse files
jmachowinskiHarunTeper
authored andcommitted
fix(Executor): Fix segfault if callback group is deleted during rmw_wait (ros2#2683)
Signed-off-by: Janosch Machowinski <[email protected]>
1 parent 293bbfd commit d810987

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

rclcpp/test/rclcpp/executors/test_executors.cpp

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -861,6 +861,7 @@ TYPED_TEST(TestExecutors, releaseOwnershipEntityAfterSpinningCancel)
861861
TYPED_TEST(TestExecutors, testRaceDropCallbackGroupFromSecondThread)
862862
{
863863
using ExecutorType = TypeParam;
864+
<<<<<<< HEAD
864865

865866
// Create an executor
866867
ExecutorType executor;
@@ -870,13 +871,36 @@ TYPED_TEST(TestExecutors, testRaceDropCallbackGroupFromSecondThread)
870871
auto executor_thread = std::thread(
871872
[&executor]() {
872873
executor.spin();
874+
=======
875+
// rmw_connextdds doesn't support events-executor
876+
if (
877+
std::is_same<ExecutorType, rclcpp::experimental::executors::EventsExecutor>() &&
878+
std::string(rmw_get_implementation_identifier()).find("rmw_connextdds") == 0)
879+
{
880+
GTEST_SKIP();
881+
}
882+
883+
// Create an executor
884+
auto executor = std::make_shared<ExecutorType>();
885+
executor->add_node(this->node);
886+
887+
// Start spinning
888+
auto executor_thread = std::thread(
889+
[executor]() {
890+
executor->spin();
891+
>>>>>>> e9b10042 (fix(Executor): Fix segfault if callback group is deleted during rmw_wait (#2683))
873892
});
874893

875894
// As the problem is a race, we do this multiple times,
876895
// to raise our chances of hitting the problem
896+
<<<<<<< HEAD
877897
for (size_t i = 0; i < 10; i++) {
878898
auto cg = this->node->create_callback_group(
879899
rclcpp::CallbackGroupType::MutuallyExclusive);
900+
=======
901+
for(size_t i = 0; i < 10; i++) {
902+
auto cg = this->node->create_callback_group(rclcpp::CallbackGroupType::MutuallyExclusive);
903+
>>>>>>> e9b10042 (fix(Executor): Fix segfault if callback group is deleted during rmw_wait (#2683))
880904
auto timer = this->node->create_timer(1s, [] {}, cg);
881905
// sleep a bit, so that the spin thread can pick up the callback group
882906
// and add it to the executor
@@ -887,6 +911,10 @@ TYPED_TEST(TestExecutors, testRaceDropCallbackGroupFromSecondThread)
887911
// If the executor has a race, we will experience a segfault at this point.
888912
}
889913

914+
<<<<<<< HEAD
890915
executor.cancel();
916+
=======
917+
executor->cancel();
918+
>>>>>>> e9b10042 (fix(Executor): Fix segfault if callback group is deleted during rmw_wait (#2683))
891919
executor_thread.join();
892920
}

0 commit comments

Comments
 (0)