Open doisyg opened 8 months ago
Same problem occurs. Did you solve it?
I'm also facing this issue now :eyes:
So I couldn't find the root cause, but it's unlikely a plotjuggler problem.
What I did to hack this in the meantime to use this functionality is to comment out this line in rclcpp
https://github.com/ros2/rclcpp/blob/8de4b90512469d74802871e6c88db2e3135720e7/rclcpp/src/rclcpp/publisher_base.cpp#L55
event_callbacks_(event_callbacks)
This line invokes a copy construction of each callback object defined within the PublisherEventCallbacks event_callbacks_;
member, this is defined as follow (in https://github.com/ros2/rclcpp/blob/8de4b90512469d74802871e6c88db2e3135720e7/rclcpp/include/rclcpp/event_handler.hpp#L15):
using QOSDeadlineOfferedInfo = rmw_offered_deadline_missed_status_t;
using QOSLivelinessLostInfo = rmw_liveliness_lost_status_t;
using QOSOfferedIncompatibleQoSInfo = rmw_offered_qos_incompatible_event_status_t;
using IncompatibleTypeInfo = rmw_incompatible_type_status_t;
using MatchedInfo = rmw_matched_status_t;
using QOSDeadlineOfferedCallbackType = std::function<void (QOSDeadlineOfferedInfo &)>;
using QOSLivelinessLostCallbackType = std::function<void (QOSLivelinessLostInfo &)>;
using QOSOfferedIncompatibleQoSCallbackType = std::function<void (QOSOfferedIncompatibleQoSInfo &)>;
using IncompatibleTypeCallbackType = std::function<void (IncompatibleTypeInfo &)>;
using PublisherMatchedCallbackType = std::function<void (MatchedInfo &)>;
/// Contains callbacks for various types of events a Publisher can receive from the middleware.
struct PublisherEventCallbacks
{
QOSDeadlineOfferedCallbackType deadline_callback;
QOSLivelinessLostCallbackType liveliness_callback;
QOSOfferedIncompatibleQoSCallbackType incompatible_qos_callback;
IncompatibleTypeCallbackType incompatible_type_callback;
PublisherMatchedCallbackType matched_callback;
};
When trying to copy the GenericPublisher::callbacks_
into the rclcpp base publisher, the segfault does happen in the copy constructor of the std::function
objects, so there is something fishy there
As reference, the implementation of the gcc11 copy constructor of std::function
:
/**
* @brief %Function copy constructor.
* @param __x A %function object with identical call signature.
* @post `bool(*this) == bool(__x)`
*
* The newly-created %function contains a copy of the target of
* `__x` (if it has one).
*/
function(const function& __x) : _Function_base()
{
if (static_cast<bool>(__x))
{
__x._M_manager(_M_functor, __x._M_functor, __clone_functor); // <---- crashes here!!!
_M_invoker = __x._M_invoker;
_M_manager = __x._M_manager;
}
}
Environment: OS: Ubuntu 22.04 ROS2 Iron lastest binaries as of 02/02/2024 PlotJuggler and ros msg and pluggin lastest source as of 02/02/2024 Cyclone DDS
https://github.com/PlotJuggler/plotjuggler-ros-plugins/assets/15727892/df5575a6-4e56-4c20-b94d-e5381c73139a