-
Notifications
You must be signed in to change notification settings - Fork 522
Context destructor not being called #893
Description
Bug report
Required Info:
- Operating System:
- Ubuntu 18.04
- Installation type:
- from source
- Version or commit hash:
- current master
- DDS implementation:
- Fast-RTPS (should be DDS implementation agnostic)
- Client library (if applicable):
- rclcpp
Steps to reproduce issue
- Add a log here
rclcpp/rclcpp/src/rclcpp/context.cpp
Line 41 in 8e69b7d
std::lock_guard<std::recursive_mutex> lock(init_mutex_); - Execute any demo, e.g.
ros2 run demo_nodes_cpp talker ctrl-cit
Expected behavior
The log should be printed after ctrl-c.
Actual behavior
It's never printed.
rclcpp/rclcpp/src/rclcpp/contexts/default_context.cpp
Lines 25 to 26 in 8e69b7d
| static DefaultContext::SharedPtr default_context = DefaultContext::make_shared(); | |
| return default_context; |
For some reason, the destructor of the static variable is not being call.
Additional information
I realized of this while working in ros2/rmw_fastrtps#312.
I'm removing the participant from the domain when the context is destructed.
If that doesn't happen, other Participants will not immediately detect that it's not more available (Participant disposal is much slower than removal).
May be related with https://stackoverflow.com/questions/38510621/destructor-of-a-global-static-variable-in-a-shared-library-is-not-called-on-dlcl, as the example is written as a component https://github.com/ros2/demos/blob/master/demo_nodes_cpp/src/topics/talker.cpp.