rmw_fastrtps: Using different typesupports on same node and topic ends in segfault

Bug report

Required Info:

  • Operating System:
    • Ubuntu 18.04
  • Installation type:
    • Source
  • Version or commit hash:
    • Head
  • DDS implementation:
    • Fast RTPS
  • Client library (if applicable):
    • N/A

Steps to reproduce issue

Create a node that registers to an already registered topic but with a different typesupport. If we assume that the node is using rosout log, and that rosout regsiters a publisher in the /rosout topic with C typesupport. You can subscribe to the /rosout topic with a CPP typesupport.

#include <iostream>
#include "rclcpp/rclcpp.hpp"
#include <rcl_interfaces/msg/log.hpp>

class MinimalSubscriber : public rclcpp::Node
{
public:
  MinimalSubscriber()
  : Node("minimal_subscriber")
  {
    subscription_ = this->create_subscription<rcl_interfaces::msg::Log>(
      "rosout",
      [this](rcl_interfaces::msg::Log::UniquePtr msg) {
      RCLCPP_INFO(this->get_logger(), "I heard: '%s'", msg->msg.c_str());
    });
  }

private:
  rclcpp::Subscription<rcl_interfaces::msg::Log>::SharedPtr subscription_;
};

int main(int argc, char * argv[])
{
  rclcpp::init(argc, argv);
  rclcpp::spin(std::make_shared<MinimalSubscriber>());
  rclcpp::shutdown();
  return 0;
}

Expected behavior

Both registered publisher and subscribers should be able to publish and receive messages for the topic.

Actual behavior

The process exits with a segfault when receiving a message on the subscribed topic.

Additional information

Two different typesupports cannot be in the same topic at the same time. This is due to the fact that rmw_fastrtps uses the same name to register both typesupports in the FastRTPS Domain. See code

Disambiguate with a different name (appending or prepending a string) is not possible because the name of the typesupport is directly related to the name of the topic. See code and fastrtps TopicData

Probably happening in other implementations.

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 1
  • Comments: 29 (25 by maintainers)

Commits related to this issue

Most upvoted comments

@dirk-thomas I just created PR #342 which should solve this. Merry Xmas! 🎅

@dirk-thomas this issue was not prioritized sorry. I can assign resources to this as soon we finish the release of Fast RTPS for eloquent, scheduled for next week.

This seems like a conversation that needs to be turned into an issue on roslaunch to support passing these kinds of parameters properly.

Commenting that this appears to prevent a lifecycle node from subscribing to the .../transition_event topic of another lifecycle node. A C++ subscriber crashes when taking data because the C typesupport was established for type by rcl_lifecycle.

backtrace
#0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:51
#1  0x00007ffff6a7b801 in __GI_abort () at abort.c:79
#2  0x00007ffff6ac4897 in __libc_message (action=action@entry=do_abort, fmt=fmt@entry=0x7ffff6bf1b9a "%s\n") at ../sysdeps/posix/libc_fatal.c:181
#3  0x00007ffff6acb90a in malloc_printerr (str=str@entry=0x7ffff6befefd "realloc(): invalid pointer") at malloc.c:5350
#4  0x00007ffff6ad3eba in __GI___libc_realloc (oldmem=0x5555562c1980, bytes=1) at malloc.c:3174
#5  0x00007ffff4bfb432 in rosidl_generator_c__String__assignn () from /opt/ros/dashing/lib/librosidl_generator_c.so
#6  0x00007fffe9bf4e47 in ?? () from /opt/ros/dashing/lib/liblifecycle_msgs__rosidl_typesupport_fastrtps_c.so
#7  0x00007fffe9bf5329 in ?? () from /opt/ros/dashing/lib/liblifecycle_msgs__rosidl_typesupport_fastrtps_c.so
#8  0x00007ffff317370c in ?? () from /opt/ros/dashing/lib/librmw_fastrtps_cpp.so
#9  0x00007ffff2b37ce2 in rmw_fastrtps_shared_cpp::TypeSupport::deserialize(eprosima::fastrtps::rtps::SerializedPayload_t*, void*) () from /opt/ros/dashing/lib/librmw_fastrtps_shared_cpp.so
#10 0x00007ffff2583830 in eprosima::fastrtps::SubscriberHistory::takeNextData(void*, eprosima::fastrtps::SampleInfo_t*) () from /opt/ros/dashing/lib/libfastrtps.so.1
#11 0x00007ffff2b34fc3 in rmw_fastrtps_shared_cpp::_take(char const*, rmw_subscription_t const*, void*, bool*, rmw_message_info_t*, rmw_subscription_allocation_t*) ()
   from /opt/ros/dashing/lib/librmw_fastrtps_shared_cpp.so
#12 0x00007ffff6826d28 in rcl_take () from /opt/ros/dashing/lib/librcl.so
#13 0x00007ffff7667a2c in rclcpp::executor::Executor::execute_subscription(std::shared_ptr<rclcpp::SubscriptionBase>) () from /opt/ros/dashing/lib/librclcpp.so
#14 0x00007ffff7668b25 in rclcpp::executor::Executor::execute_any_executable(rclcpp::executor::AnyExecutable&) () from /opt/ros/dashing/lib/librclcpp.so
#15 0x00007ffff766ef2f in rclcpp::executors::SingleThreadedExecutor::spin() () from /opt/ros/dashing/lib/librclcpp.so
#16 0x00005555555586c8 in main (argc=2, argv=0x7fffffffe7e8) at /home/sloretz/workspaces/dashing/src/lifecycle_manager/src/lifecycle_manager_standalone.cpp:27