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

bond::Bond constructs TimerBase in its destructor, making it difficult to destruct after rclcpp::shutdown #92

Open
mmattb opened this issue Feb 1, 2023 · 2 comments

Comments

@mmattb
Copy link

mmattb commented Feb 1, 2023

The Bond destructor constructs a TimerBase:

 0# rclcpp::TimerBase::TimerBase(std::shared_ptr<rclcpp::Clock>, std::chrono::duration<long, std::ratio<1l, 1000000000l> >, std::shared_ptr<rclcpp::Context>) in /home/mbryan/Projects/ros/ros2_rolling/install/rclcpp/lib/librclcpp.so
 1# bond::Bond::deadpublishingTimerReset() in /opt/ros/rolling/lib/libbondcpp.so
 2# SM_Alive::Die(BondSMContext&) in /opt/ros/rolling/lib/libbondcpp.so
 3# bond::Bond::breakBond() in /opt/ros/rolling/lib/libbondcpp.so
 4# bond::Bond::~Bond() in /opt/ros/rolling/lib/libbondcpp.so
 5# nav2_util::LifecycleNode::~LifecycleNode() in /home/mbryan/Projects/ros/navigation2/install/nav2_util/lib/libnav2_util_core.so
 6# behavior_server::BehaviorServer::~BehaviorServer() in /home/mbryan/Projects/ros/navigation2/install/nav2_behaviors/lib/libbehavior_server_core.so
 7# std::_Sp_counted_ptr_inplace<behavior_server::BehaviorServer, std::allocator<behavior_server::BehaviorServer>, (__gnu_cxx::_Lock_policy)2>::_M_dispose() in /home/mbryan/Projects/ros/navigation2/install/nav2_behaviors/lib/nav2_behaviors/behavior_server
 8# std::_Sp_counted_base<(__gnu_cxx::_Lock_policy)2>::_M_release() in /home/mbryan/Projects/ros/navigation2/install/nav2_behaviors/lib/nav2_behaviors/behavior_server
 9# 0x000055F5FE8BB964 in /home/mbryan/Projects/ros/navigation2/install/nav2_behaviors/lib/nav2_behaviors/behavior_server
10# 0x00007FA05CCD9D90 in /lib/x86_64-linux-gnu/libc.so.6
11# __libc_start_main in /lib/x86_64-linux-gnu/libc.so.6
12# 0x000055F5FE8BBA35 in /home/mbryan/Projects/ros/navigation2/install/nav2_behaviors/lib/nav2_behaviors/behavior_server

Unfortunately this means that we hit exceptions if destruction happens after rclcpp::shutdown is called. Basically this exception translates to "why are you trying to make timer stuff after shutdown?"

[43.062857] (nav2_system_tests) StdoutLine: {'line': b'9: [behavior_server-10] [INFO] [1673598507.589703428] [behavior_server]: Destroying\n'}
[43.062996] (nav2_system_tests) StdoutLine: {'line': b"9: [behavior_server-10] terminate called after throwing an instance of 'rclcpp::exceptions::RCLError'\n"}
[43.063104] (nav2_system_tests) StdoutLine: {'line': b"9: [behavior_server-10]   what():  Couldn't initialize rcl timer handle: the given context is not valid, either rcl_init() was not called or rcl_shutdown() was called., at ./src/rcl/guard_condition.c:67\n"}

Construction for the purpose of doing some operation in a destruction path is not insane per se, but this particular one is requiring us to get careful with shutdown callbacks blah blah in the Nav2 code. It would be good to avoid it if possible.

I don't see deadpublishingTimerReset in today's code base, so I'm not sure what versions of libbond this may affect. Having said that: this is affecting today's Nav2 system tests. Not sure what version those CI rigs are running... The version in the stack above is from the Ubuntu 22.04 repository I believe.

Filed per request of Steve Macenski (who I can't tag for some reason).

@mjcarroll
Copy link
Member

Thanks for the report. If you could get the exact versions, that would help me figure out where the fix is most appropriate.

@SteveMacenski
Copy link
Member

Rolling - we're running into this in Nav2 (so Humble, Foxy, ... should probably also exhibit this behavior)

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

3 participants