Skip to content

Commit 0e0fce2

Browse files
facontidavideclaude
andcommitted
fix segfault in GenericPublisher on Jazzy due to uninitialized callbacks_ member
The callbacks_ member was passed to the rclcpp::PublisherBase base class constructor before it was initialized (C++ UB), causing a segfault inside rclcpp::JumpHandler::JumpHandler on Jazzy. Replace with a default-constructed temporary rclcpp::PublisherEventCallbacks{} and remove the now-unused member. Fixes #112 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent c59c52d commit 0e0fce2

1 file changed

Lines changed: 2 additions & 5 deletions

File tree

src/TopicPublisherROS2/generic_publisher.h

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ class GenericPublisher : public rclcpp::PublisherBase
2828
#ifdef ROS_HUMBLE
2929
: rclcpp::PublisherBase(node_base, topic_name, type_support, rcl_publisher_get_default_options())
3030
#else
31-
: rclcpp::PublisherBase(node_base, topic_name, type_support, rcl_publisher_get_default_options(), callbacks_, true)
31+
: rclcpp::PublisherBase(node_base, topic_name, type_support, rcl_publisher_get_default_options(),
32+
rclcpp::PublisherEventCallbacks{}, true)
3233
#endif
3334
{
3435
}
@@ -53,10 +54,6 @@ class GenericPublisher : public rclcpp::PublisherBase
5354

5455
return std::make_shared<GenericPublisher>(node.get_node_base_interface().get(), topic_name, *type_support);
5556
}
56-
57-
#ifndef ROS_HUMBLE
58-
rclcpp::PublisherEventCallbacks callbacks_;
59-
#endif
6057
};
6158

6259
#endif // GENERIC_PUBLISHER_H

0 commit comments

Comments
 (0)