gz-transport icon indicating copy to clipboard operation
gz-transport copied to clipboard

Remove NodeShared singleton

Open osrf-migration opened this issue 5 years ago • 1 comments

Original report (archived issue) by Nate Koenig (Bitbucket: Nathan Koenig).


Summary

NodeShared is a singleton, which can lead to runtime problems particularly during shutdown. One problem occurs when two nodes are in the same process, with one node publishing messages that the other node consumes and then publishes new messages. I see a segfault when running this code (https://osrf-migration.github.io/ignition-gh-pages/#!/ignitionrobotics/ign-launch/commits/11b5830128da4561711a043c6450545a7b90c0a4 (ignitionrobotics/ign-launch@eea15cea322bc946f6f2a627e5ad8a54882bebff)) with this configuration file( https://osrf-migration.github.io/ignition-gh-pages/#!/ignitionrobotics/ign-launch/commits/11b5830128da4561711a043c6450545a7b90c0a4 (ignitionrobotics/ign-launch@eea15cea322bc946f6f2a627e5ad8a54882bebff)#chg-config/gazebo.ign). When this version of ign-launch is installed, you can test using ign launch -f config/gazebo.ign.

Motivation

In addition to the above error, we are trying to remove singletons from our code base. For reasons see https://stackoverflow.com/questions/137975/what-is-so-bad-about-singletons/138012#138012 and https://cocoacasts.com/are-singletons-bad.

Describe alternatives you've considered

I think @caguero mentioned that we could potentially use features built into ZeroMq to avoid the NodeShared singleton.

osrf-migration avatar Feb 04 '19 20:02 osrf-migration