question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Raw topic subscription crashes node under Cyclone when subscriber leaves

See original GitHub issue

Bug report

Required Info:

  • Operating System:
    • Ubuntu 18.04
  • Version or commit hash:
    • Foxy
  • DDS implementation:
    • Cyclone
  • Client library (if applicable):
    • rclpy

Steps to reproduce issue

Minimal subscriber example, slightly modified to use raw=True and output the raw msg instead of a string

import rclpy
from rclpy.node import Node

from std_msgs.msg import String


class MinimalSubscriber(Node):

    def __init__(self):
        super().__init__('minimal_subscriber')
        self.subscription = self.create_subscription(
            String,
            'topic',
            self.listener_callback,
            10,
            raw=True )
        self.subscription  # prevent unused variable warning

    def listener_callback(self, msg):
        self.get_logger().info(f'I got: {msg}')


def main(args=None):
    rclpy.init(args=args)

    minimal_subscriber = MinimalSubscriber()

    rclpy.spin(minimal_subscriber)

    # Destroy the node explicitly
    # (optional - otherwise it will be done automatically
    # when the garbage collector destroys the node object)
    minimal_subscriber.destroy_node()
    rclpy.shutdown()


if __name__ == '__main__':
    main()

Run this node under a Cyclone DDS setup. In a second terminal, publish to the topic, and then stop publishing

ros2 topic pub /topic std_msgs/msg/String
...
Ctrl+c

Expected behavior

The node stays up and happy

Actual behavior

Traceback (most recent call last):
  File "minimal_crash.py", line 38, in <module>
    main()
  File "minimal_crash.py", line 28, in main
    rclpy.spin(minimal_subscriber)
  File "/opt/ros/foxy/lib/python3.8/site-packages/rclpy/__init__.py", line 191, in spin
    executor.spin_once()
  File "/opt/ros/foxy/lib/python3.8/site-packages/rclpy/executors.py", line 711, in spin_once
    raise handler.exception()
  File "/opt/ros/foxy/lib/python3.8/site-packages/rclpy/task.py", line 239, in __call__
    self._handler.send(None)
  File "/opt/ros/foxy/lib/python3.8/site-packages/rclpy/executors.py", line 419, in handler
    arg = take_from_wait_list(entity)
  File "/opt/ros/foxy/lib/python3.8/site-packages/rclpy/executors.py", line 344, in _take_subscription
    msg_info = _rclpy.rclpy_take(capsule, sub.msg_type, sub.raw)
_rclpy.RCLError: Failed to take_serialized from a subscription: error not set

Additional information

Default dds, or removing raw=True fixes the crash

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:9 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
clalancettecommented, Feb 23, 2022

Are there instructions on how to setup the necessary build environment?

https://docs.ros.org/en/foxy/Installation/Ubuntu-Development-Setup.html has the instructions on building from source for Foxy.

0reactions
suurjaakcommented, Feb 23, 2022

@fujitatomoya I suppose I could try.

Do I understand correctly that this should suffice in handling rcl_take_serialized_message result?

  ret = rcl_take_serialized_message(subscription, &msg, message_info, NULL);
  if (ret != RCL_RET_OK) {
    if (ret != RCL_RET_SUBSCRIPTION_TAKE_FAILED) {
      PyErr_Format(
        RCLError,
        "Failed to take_serialized from a subscription: %s", rcl_get_error_string().str);
      rcl_reset_error();
    }
    rmw_ret_t r_fini = rmw_serialized_message_fini(&msg);
    if (r_fini != RMW_RET_OK) {
      PyErr_Format(RCLError, "Failed to deallocate message buffer: %d", r_fini);
    }
    return NULL;
  }

Are there instructions on how to setup the necessary build environment?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Subscription and publication to same topic from one node ...
I'm trying to both listen and publish to the same topic from one node. No matter in which order I try, I get...
Read more >
Documentation - Apache Kafka
We'll call processes that subscribe to topics and process the feed of published messages consumers.. Kafka is run as a cluster comprised of...
Read more >
Untitled
A place for CycloneReport.com subscribers to talk non-sports topics. 1 2 3 … ... The 1981-2010 average number of named storms in the...
Read more >
Bug listing with status RESOLVED with resolution OBSOLETE ...
issue with udev ("the udev init script is written for baselayout 2, please do not use this script with baselayout 1")" status:RESOLVED resolution:OBSOLETE ......
Read more >
RAW: MT: SNOWY WEATHER CAUSES MULTIPLE CRASHES
Montana Highway Patrol, report the initial accident came from one vehicle hitting a guard rail, causing multiple cars to rear-end and hit ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found