Rosanswers logo

I believe I have found a threading issue with ros logging.

If a node subscribes to a topic in one thread and logs to rosout in another, a conflict can occur, since the nodes topic list may be altered while the rosout logging traverses it.

The following error is reported:

Unable to report rosout: Set changed size during iteration

And what is worse is that tcpros protocol synchronization is lost:

[ERROR] [1520594758.451498758] [/rosout]: a message of over a gigabyte was predicted in tcpros. that seems highly unlikely, so I'll assume protocol synchronization is lost.

[ERROR] [1520594758.451553409] [/rosout]: Exception thrown when deserializing message of length [0] from [/rosout_test]: Buffer Overrun

[ERROR] [1520594758.451622886] [/rosout]: Exception thrown when deserializing message of length [39] from [/rosout_test]: Buffer Overrun

Are there any locks or similar in place, so I can safely subscribe/unsubscribe to topics?

This python node reproduces the problem:

#!/usr/bin/env python

import rospy
from std_msgs.msg import Float64
from threading import Thread

def topic_callback(msg):

def my_topic_thread():
    """endless subscribing and unsubscribing to a list of topics"""

    topic_names = ["/some/topic{}".format(i) for i in range(0, 100)]

    while not rospy.is_shutdown():
        subs = []
        for topic in topic_names:
            subs.append(rospy.Subscriber(topic, Float64, topic_callback))

        for sub in subs:

if __name__ == '__main__':


    topic_thread = Thread(target=my_topic_thread)

    while not rospy.is_shutdown():
        # This logging fails intermittently, because the nodes
        # topic list is changed during logging
        # Error: protocol synchronization is lost
        rospy.loginfo("dummy message")


kinetic, ubuntu 16.04

Originally posted by knxa on ROS Answers with karma: 811 on 2018-03-09

Post score: 1

Original comments

Comment by gvdhoorn on 2018-03-09:
This is not an answer, but a recommendation: ROS Answers might not be the best place to report this sort of problem. If you have an MWE and believe it is a bug, it might be more efficient to post to ros/ros_comm/issues directly. If you do, please link back.

Comment by knxa on 2018-03-09:
Thanks for the input. Now reported here


1 Answer 1


Rosanswers logo

Closing this now the issue is reported.

In case you have ideas on how to work around this, I would still like to hear it!

Originally posted by knxa with karma: 811 on 2018-03-09

This answer was ACCEPTED on the original site

Post score: 0

Original comments

Comment by gvdhoorn on 2018-03-09:
I'm not sure this should be marked as answered: until the bug is fixed, or it's clarified that the usage seen in the MWE is incorrect, there seems to be no conclusion.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.