ami-iit / bipedal-locomotion-framework

Suite of libraries for achieving bipedal locomotion on humanoid robots
https://ami-iit.github.io/bipedal-locomotion-framework/
BSD 3-Clause "New" or "Revised" License
145 stars 37 forks source link

YarpRobotLoggerDevice sets global blf factories in the costructor #872

Open traversaro opened 1 month ago

traversaro commented 1 month ago

See https://github.com/ami-iit/bipedal-locomotion-framework/blob/4ea37800355531fe4c78f12a4ed0aa426a748ed3/devices/YarpRobotLoggerDevice/src/YarpRobotLoggerDevice.cpp#L111-L123 .

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 commented 3 weeks ago

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

traversaro commented 3 weeks ago

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?