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

Valgrind shows leak in rcutils_load_shared_library #407

Open
mmattb opened this issue Jan 20, 2023 · 1 comment
Open

Valgrind shows leak in rcutils_load_shared_library #407

mmattb opened this issue Jan 20, 2023 · 1 comment

Comments

@mmattb
Copy link

mmattb commented Jan 20, 2023

Apologies if this is tracked somewhere already, or addressed in a previous version. I'm still getting oriented here...

This happens on a recent-ish (~2-3 weeks old) ros2_rolling clone. I hit it while debugging some odd library unload behavior in Nav2's planner_server. The command to start it was:

valgrind --leak-check=full --num-callers=60 /home/mbryan/Projects/ros/navigation2/install/nav2_planner/lib/nav2_planner/planner_server --ros-args --log-level info --ros-args -r __node:=planner_server -p use_sim_time:=True --params-file /tmp/tmpm5wzacln -r /tf:=tf -r /tf_static:=tf_static

NOTE: that path points to my navigation2 clone. My built ros2_rolling clone is in my path (see bottom stack frame below).

==49974== 
==49974== HEAP SUMMARY:
==49974==     in use at exit: 224,129 bytes in 761 blocks
==49974==   total heap usage: 92,290 allocs, 91,529 frees, 19,064,079 bytes allocated
==49974== 
==49974== 64 bytes in 1 blocks are definitely lost in loss record 50 of 172
==49974==    at 0x4852899: malloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==49974==    by 0x400F21D: malloc (rtld-malloc.h:56)
==49974==    by 0x400F21D: resize_scopes (dl-open.c:295)
==49974==    by 0x400F21D: dl_open_worker_begin (dl-open.c:707)
==49974==    by 0x5DDAC27: _dl_catch_exception (dl-error-skeleton.c:208)
==49974==    by 0x400DF99: dl_open_worker (dl-open.c:782)
==49974==    by 0x5DDAC27: _dl_catch_exception (dl-error-skeleton.c:208)
==49974==    by 0x400E34D: _dl_open (dl-open.c:883)
==49974==    by 0x5CF66BB: dlopen_doit (dlopen.c:56)
==49974==    by 0x5DDAC27: _dl_catch_exception (dl-error-skeleton.c:208)
==49974==    by 0x5DDACF2: _dl_catch_error (dl-error-skeleton.c:227)
==49974==    by 0x5CF61AD: _dlerror_run (dlerror.c:138)
==49974==    by 0x5CF6747: dlopen_implementation (dlopen.c:71)
==49974==    by 0x5CF6747: dlopen@@GLIBC_2.34 (dlopen.c:81)
==49974==    by 0x4C5CF02: rcutils_load_shared_library (in /home/mbryan/Projects/ros/ros2_rolling/install/rcutils/lib/librcutils.so)
==49974==    by 0x63EB667: rcpputils::SharedLibrary::SharedLibrary(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) (in /home/mbryan/Projects/ros/ros2_rolling/install/rcpputils/lib/librcpputils.so)
==49974==    by 0x6CCD633: rosidl_message_type_support_t const* rosidl_typesupport_c::get_typesupport_handle_function<rosidl_message_type_support_t>(rosidl_message_type_support_t const*, char const*) (in /home/mbryan/Projects/ros/ros2_rolling/install/rosidl_typesupport_c/lib/librosidl_typesupport_c.so)
==49974==    by 0x6CCD3FF: rosidl_typesupport_c__get_message_typesupport_handle_function (in /home/mbryan/Projects/ros/ros2_rolling/install/rosidl_typesupport_c/lib/librosidl_typesupport_c.so)
==49974==    by 0x6CAD6D0: get_message_typesupport_handle (in /home/mbryan/Projects/ros/ros2_rolling/install/rosidl_runtime_c/lib/librosidl_runtime_c.so)
==49974==    by 0x7566280: rmw_fastrtps_cpp::create_publisher(CustomParticipantInfo const*, rosidl_message_type_support_t const*, char const*, rmw_qos_profile_s const*, rmw_publisher_options_s const*, bool, bool) (in /home/mbryan/Projects/ros/ros2_rolling/install/rmw_fastrtps_cpp/lib/librmw_fastrtps_cpp.so)
==49974==    by 0x7585B31: rmw_create_publisher (in /home/mbryan/Projects/ros/ros2_rolling/install/rmw_fastrtps_cpp/lib/librmw_fastrtps_cpp.so)
==49974==    by 0x669E915: rmw_create_publisher (in /home/mbryan/Projects/ros/ros2_rolling/install/rmw_implementation/lib/librmw_implementation.so)
==49974==    by 0x642D575: rcl_publisher_init (in /home/mbryan/Projects/ros/ros2_rolling/install/rcl/lib/librcl.so)
==49974==    by 0x6428499: rcl_logging_rosout_init_publisher_for_node (in /home/mbryan/Projects/ros/ros2_rolling/install/rcl/lib/librcl.so)
==49974==    by 0x642B72A: rcl_node_init (in /home/mbryan/Projects/ros/ros2_rolling/install/rcl/lib/librcl.so)
==49974==    by 0x567587B: rclcpp::node_interfaces::NodeBase::NodeBase(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::shared_ptr<rclcpp::Context>, rcl_node_options_s const&, bool, bool, std::shared_ptr<rclcpp::CallbackGroup>) (in /home/mbryan/Projects/ros/ros2_rolling/install/rclcpp/lib/librclcpp.so)
==49974==    by 0x4B3283E: rclcpp_lifecycle::LifecycleNode::LifecycleNode(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, rclcpp::NodeOptions const&, bool) (in /home/mbryan/Projects/ros/ros2_rolling/install/rclcpp_lifecycle/lib/librclcpp_lifecycle.so)
==49974==    by 0x6268DCE: nav2_util::LifecycleNode::LifecycleNode(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, rclcpp::NodeOptions const&) (in /home/mbryan/Projects/ros/navigation2/build/nav2_util/src/libnav2_util_core.so)
==49974==    by 0x48E85D4: nav2_planner::PlannerServer::PlannerServer(rclcpp::NodeOptions const&) (in /home/mbryan/Projects/ros/navigation2/build/nav2_planner/libplanner_server_core.so)
==49974==    by 0x10E553: void __gnu_cxx::new_allocator<nav2_planner::PlannerServer>::construct<nav2_planner::PlannerServer>(nav2_planner::PlannerServer*) [clone .isra.0] (in /home/mbryan/Projects/ros/navigation2/build/nav2_planner/planner_server)
==49974==    by 0x10E702: std::__shared_ptr<nav2_planner::PlannerServer, (__gnu_cxx::_Lock_policy)2>::__shared_ptr<std::allocator<nav2_planner::PlannerServer>>(std::_Sp_alloc_shared_tag<std::allocator<nav2_planner::PlannerServer> >) (in /home/mbryan/Projects/ros/navigation2/build/nav2_planner/planner_server)
==49974==    by 0x10D80B: main (in /home/mbryan/Projects/ros/navigation2/build/nav2_planner/planner_server)

Minor leak; seems low priority. Please advise if this needs punting over to another repo.

Not sure if it's related, but I see this log line in the tests I'm running; putting it here for FYI:

[228.584185] (nav2_regulated_pure_pursuit_controller) StdoutLine: {'line': b'6: Warning: class_loader.ClassLoader: SEVERE WARNING!!! Attempting to unload library while objects created by this loader exist in the heap! You should delete your objects before attempting to unload the library or destroying the ClassLoader. The library will NOT be unloaded.\n'}

@mmattb
Copy link
Author

mmattb commented Jan 20, 2023

To help narrow things down, since it seems there is some mach dep code in here: my test rig is Ubuntu 22.04.

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

1 participant