Skip to content
This repository was archived by the owner on May 31, 2025. It is now read-only.

Fix Issue 1346 - Make a copy of the topic list#1416

Merged
dirk-thomas merged 2 commits intoros:melodic-develfrom
pbaughman:issue_1346_rosout_race
Jun 1, 2018
Merged

Fix Issue 1346 - Make a copy of the topic list#1416
dirk-thomas merged 2 commits intoros:melodic-develfrom
pbaughman:issue_1346_rosout_race

Conversation

@pbaughman
Copy link
Copy Markdown

@pbaughman pbaughman commented May 31, 2018

Proposed fix from #1346

Description

get_topics() returns a set, which is iterated by the Log constructor. Make a copy of the set (atomic in cpython!) so nobody adds or removes something while the Log constructor iterates over it

A more optimized fix might be to use an immutable data structure inside the topic manager. I imagine that in the general case the topic list changes a lot less often than than calls are made to _rosout. It might be better to eat the overhead on topic add/remove instead of adding a copy operation to every _rosout call.

get_topics() returns a set, which is iterated by the Log constructor.
Make a copy of the set (atomic in cpython!) so nobody adds or removes
something while the Log constructor iterates over it
@dirk-thomas
Copy link
Copy Markdown
Member

Moving the copy call into the get_topics() function seems to be a "better" option (applies to all callers, doesn't need to change any other code). Can you update the patch accordingly.

@pbaughman
Copy link
Copy Markdown
Author

Aye - if you're comfortable with a slightly bigger footprint, that's probably a more robust fix

This reverts commit 0e019e0.
Move the fix to the _TopicManager so anybody else calling get_topics doesn't get burned by the same issue as _rosout
@@ -1348,7 +1348,7 @@ def get_topics(self):
@return: list of topic names this node subscribes to/publishes
@rtype: [str]
Copy link
Copy Markdown
Author

@pbaughman pbaughman Jun 1, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This return type is a bit of a fib, I think, unless I don't understand the documentation syntax. Problem?

@tfoote
Copy link
Copy Markdown
Member

tfoote commented Jun 1, 2018

This would be a good candidate for backporting. It's known to cause issues all the way back to indigo and is a pure bug fix.

@dirk-thomas dirk-thomas added the bug label Jun 1, 2018
@dirk-thomas
Copy link
Copy Markdown
Member

Thank you for the updated patch.

@dirk-thomas dirk-thomas merged commit 1523b1e into ros:melodic-devel Jun 1, 2018
dirk-thomas pushed a commit that referenced this pull request Aug 9, 2018
* Make a copy of the topic list

get_topics() returns a set, which is iterated by the Log constructor.
Make a copy of the set (atomic in cpython!) so nobody adds or removes
something while the Log constructor iterates over it

* Revert "Make a copy of the topic list", Fix

This reverts commit 0e019e0.
Move the fix to the _TopicManager so anybody else calling get_topics doesn't get burned by the same issue as _rosout
dirk-thomas pushed a commit that referenced this pull request Aug 20, 2018
* Make a copy of the topic list

get_topics() returns a set, which is iterated by the Log constructor.
Make a copy of the set (atomic in cpython!) so nobody adds or removes
something while the Log constructor iterates over it

* Revert "Make a copy of the topic list", Fix

This reverts commit 0e019e0.
Move the fix to the _TopicManager so anybody else calling get_topics doesn't get burned by the same issue as _rosout
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants