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

YarpRobotLoggerDevice sets global blf factories in the costructor #872

Open
traversaro opened this issue Aug 11, 2024 · 2 comments
Open

Comments

@traversaro
Copy link
Collaborator

See

YarpRobotLoggerDevice::YarpRobotLoggerDevice()
: yarp::os::PeriodicThread(0.01, yarp::os::ShouldUseSystemClock::No)
{
// Use the yarp clock in blf
BipedalLocomotion::System::ClockBuilder::setFactory(
std::make_shared<BipedalLocomotion::System::YarpClockFactory>());
// the logging message are streamed using yarp
BipedalLocomotion::TextLogging::LoggerBuilder::setFactory(
std::make_shared<BipedalLocomotion::TextLogging::YarpLoggerFactory>());
m_sendDataRT = false;
}
.

This works fine if the device is launched as part of a standalone yarprobotinterface process, but if this is done as part of a robotinterface instance created with the libYARP_robotinterface, what can happen is that the YARP libraries are unloaded, but the factories are never restored to the non-YARP ones, resulting in segmentation fault if the textlogging or clock functions are used.

@GiulioRomualdi
Copy link
Member

Thanks for spotting it, what do you think is the correct solution?

@traversaro
Copy link
Collaborator Author

That is kind of a tricky one, as any kind of global state is always tricky to handle. Perhaps we could have an option to enable/disable setting this global state? It may be even more clean to have a dedicated device that only set the logger and the clock, but that would be a bit cumbersome as you would need to remember to insert it in any yarprobotinterface, while the option may be more easy to handle?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants