Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

abort when running with SHM(TRUE) and MultiThreadedExecutor(CallbackGroupType::Reentrant) #495

Open
binbowang1987 opened this issue May 23, 2024 · 2 comments
Labels
help wanted Extra attention is needed

Comments

@binbowang1987
Copy link

Bug report

Required Info:

  • Operating System:
    • Ubuntu 20.04
  • Installation type:
    • from source
  • Version or commit hash:
    • humble
  • DDS implementation:
    • cyclonedds
  • Client library (if applicable):

Steps to reproduce issue

Test.msg

uint8[133] data
// publisher
class MinimalPublisher : public rclcpp::Node
{
public:
  MinimalPublisher()
  : Node("minimal_publisher"), count_(0)
  {
    publisher_ = this->create_publisher<examples_rclcpp_minimal_publisher::msg::Test>("topic", 100);
    timer_ = this->create_wall_timer(
      10ms, std::bind(&MinimalPublisher::timer_callback, this));
  }

private:
  void timer_callback()
  {
    for(int i = 0;i<10;i++) {
      auto message = examples_rclcpp_minimal_publisher::msg::Test();
      publisher_->publish(message);
    }
  }
  rclcpp::TimerBase::SharedPtr timer_;
  rclcpp::Publisher<examples_rclcpp_minimal_publisher::msg::Test>::SharedPtr publisher_;
  size_t count_;
};

int main(int argc, char * argv[])
{
  rclcpp::init(argc, argv);
  rclcpp::spin(std::make_shared<MinimalPublisher>());
  rclcpp::shutdown();
  return 0;
}
// subscriber
class MinimalSubscriber : public rclcpp::Node
{
public:
  MinimalSubscriber()
  : Node("minimal_subscriber", rclcpp::NodeOptions())
  {
    rclcpp::CallbackGroup::SharedPtr callbackGroup = 
      this->create_callback_group(rclcpp::CallbackGroupType::Reentrant);

    auto sub_opt = rclcpp::SubscriptionOptions();
    sub_opt.callback_group = callbackGroup;

    subscription_ = this->create_subscription<examples_rclcpp_minimal_publisher::msg::Test>(
      "topic", rclcpp::QoS(10), std::bind(&MinimalSubscriber::topic_callback, this, _1), 
      sub_opt);
  }

private:
  void topic_callback(const examples_rclcpp_minimal_publisher::msg::Test & msg) const
  {
    RCLCPP_INFO(this->get_logger(), "xxxxxx, %ld", msg.data.size());
    usleep(1000*1000);
  }
  rclcpp::Subscription<examples_rclcpp_minimal_publisher::msg::Test>::SharedPtr subscription_;
};

int main(int argc, char * argv[])
{
  rclcpp::init(argc, argv);

  auto node1 = std::make_shared<MinimalSubscriber>();
  rclcpp::executors::MultiThreadedExecutor executor;
  executor.add_node(node1);
  executor.spin();
  rclcpp::shutdown();
  return 0;
}

Expected behavior

Normally Run

Actual behavior

Aborted

Additional information

image

Feature request

Feature description

Implementation considerations

@audrow audrow added the help wanted Extra attention is needed label Jun 6, 2024
@audrow
Copy link
Member

audrow commented Jun 6, 2024

FYI @eboasson.

@eboasson
Copy link
Collaborator

I have a good idea what's going on here (Iceoryx API's aren't multi-thread safe, while I assumed they were. The hacks in Cyclone that were put in later are not the greatest. I think Cyclone master will do better, but then you need a patched RMW layer.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants