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

occasional segfault in shutdown, perhaps in node.destroy_node() #178

Closed
wjwwood opened this issue Mar 3, 2018 · 2 comments
Closed

occasional segfault in shutdown, perhaps in node.destroy_node() #178

wjwwood opened this issue Mar 3, 2018 · 2 comments
Labels
bug Something isn't working good first issue Good for newcomers help wanted Extra attention is needed

Comments

@wjwwood
Copy link
Member

wjwwood commented Mar 3, 2018

While testing some things for a discourse question (https://discourse.ros.org/t/how-to-shutdown-and-reinitialize-a-publisher-node-in-ros-2/4090/3?u=wjwwood), I created this script:

import sys

import rclpy
from rclpy.node import Node

from std_msgs.msg import String


def main():
    msg = String()
    i = 0

    while True:
        rclpy.init()

        node = Node('talker')
        pub = node.create_publisher(String, 'chatter')
        msg.data = 'Hello World: {0}'.format(i)
        i += 1
        node.get_logger().info('Publishing: "{0}"'.format(msg.data))
        pub.publish(msg)

        node.destroy_node()
        rclpy.shutdown()


if __name__ == '__main__':
    main()

Which works fine, but one time when I did ctrl-c on it I got a segmentation fault:

...
[INFO] [talker]: Publishing: "Hello World: 336"
[INFO] [talker]: Publishing: "Hello World: 337"
^CTraceback (most recent call last):
  File "/tmp/testing/talker.py", line 31, in <module>
    main()
  File "/tmp/testing/talker.py", line 26, in main
    node.destroy_node()
  File "/Users/william/ros2_ws/install_release/lib/python3.6/site-packages/rclpy/node.py", line 286, in destroy_node
    _rclpy.rclpy_destroy_entity(self.handle)
KeyboardInterrupt
[1]    48020 segmentation fault  python3 /tmp/testing/talker.py

I've been trying to catch it in the debugger but I haven't been able to do so, and I don't really have time to track down the source right now, so I though I'd make an issue and see if anyone else had time or interest to track it down.

@sloretz
Copy link
Contributor

sloretz commented May 2, 2019

I'm unable to reproduce the segfault using the script in the issue body after multiple attempts. The original traceback goes to rclpy_destroy_entity, but that was removed in #319. OK to close this?

Occasionally I see the KeyboardInterrupt be ignored with a traceback

Exception ignored in: <function WeakSet.__init__.<locals>._remove at 0x7f1a78d9dbf8>
Traceback (most recent call last):
  File "/usr/lib/python3.6/_weakrefset.py", line 38, in _remove
    def _remove(item, selfref=ref(self)):
KeyboardInterrupt

But I haven't figured out why that happens. It seems like it might be a cpython 3.6 bug.

@wjwwood
Copy link
Member Author

wjwwood commented May 2, 2019

Let's close it and reopen if needed. Thanks!

@wjwwood wjwwood closed this as completed May 2, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants