Skip to content

memory leak in rclcpp::parameter_map_from_yaml_file #1993

@iuhilnehc-ynos

Description

@iuhilnehc-ynos

Bug report

Required Info:

  • Operating System:
    • Ubuntu20.04
  • Installation type:
    • source
  • Version or commit hash:
  • DDS implementation:
    • all
  • Client library (if applicable):
    • rclcpp

Steps to reproduce issue

$ valgrind --leak-check=full ./test_parameter_client --gtest_filter="*.sync_parameter_load_parameters"
==1075091== Memcheck, a memory error detector
==1075091== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==1075091== Using Valgrind-3.15.0 and LibVEX; rerun with -h for copyright info
==1075091== Command: ./test_parameter_client --gtest_filter=*.sync_parameter_load_parameters
==1075091== 
Running main() from /home/chenlh/Projects/ROS2/ros2-master/local_install_test/gtest_vendor/src/gtest_vendor/src/gtest_main.cc
Note: Google Test filter = *.sync_parameter_load_parameters
[==========] Running 1 test from 1 test suite.
[----------] Global test environment set-up.
[----------] 1 test from TestParameterClient
[ RUN      ] TestParameterClient.sync_parameter_load_parameters
[       OK ] TestParameterClient.sync_parameter_load_parameters (6336 ms)
[----------] 1 test from TestParameterClient (6343 ms total)

[----------] Global test environment tear-down
[==========] 1 test from 1 test suite ran. (8835 ms total)
[  PASSED  ] 1 test.
==1075091== 
==1075091== HEAP SUMMARY:
==1075091==     in use at exit: 93,286 bytes in 178 blocks
==1075091==   total heap usage: 46,099 allocs, 45,921 frees, 8,914,054 bytes allocated
==1075091== 
==1075091== 46,251 (72 direct, 46,179 indirect) bytes in 1 blocks are definitely lost in loss record 73 of 73
==1075091==    at 0x4841D99: calloc (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_memcheck-amd64-linux.so)
==1075091==    by 0x56E109F: __default_zero_allocate (allocator.c:62)
==1075091==    by 0x5B79678: rcl_yaml_node_struct_init_with_capacity (parser.c:58)
==1075091==    by 0x5B795EF: rcl_yaml_node_struct_init (parser.c:46)
==1075091==    by 0x5383876: rclcpp::parameter_map_from_yaml_file(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) (parameter_map.cpp:148)
==1075091==    by 0x53235D8: rclcpp::AsyncParametersClient::load_parameters(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) (parameter_client.cpp:293)
==1075091==    by 0x5324A97: rclcpp::SyncParametersClient::load_parameters(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::chrono::duration<long, std::ratio<1l, 1000000000l> >) (parameter_client.cpp:495)
==1075091==    by 0x36B74D: std::vector<rcl_interfaces::msg::SetParametersResult_<std::allocator<void> >, std::allocator<rcl_interfaces::msg::SetParametersResult_<std::allocator<void> > > > rclcpp::SyncParametersClient::load_parameters<long, std::ratio<1l, 1000l> >(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::chrono::duration<long, std::ratio<1l, 1000l> >) (parameter_client.hpp:523)
==1075091==    by 0x358178: TestParameterClient_sync_parameter_load_parameters_Test::TestBody() (test_parameter_client.cpp:945)
==1075091==    by 0x422BA7: void testing::internal::HandleSehExceptionsInMethodIfSupported<testing::Test, void>(testing::Test*, void (testing::Test::*)(), char const*) (gtest.cc:2433)
==1075091==    by 0x41BEA4: void testing::internal::HandleExceptionsInMethodIfSupported<testing::Test, void>(testing::Test*, void (testing::Test::*)(), char const*) (gtest.cc:2469)
==1075091==    by 0x3F730F: testing::Test::Run() (gtest.cc:2508)
==1075091== 
==1075091== LEAK SUMMARY:
==1075091==    definitely lost: 72 bytes in 1 blocks
==1075091==    indirectly lost: 46,179 bytes in 24 blocks
==1075091==      possibly lost: 0 bytes in 0 blocks
==1075091==    still reachable: 47,035 bytes in 153 blocks
==1075091==         suppressed: 0 bytes in 0 blocks
==1075091== Reachable blocks (those to which a pointer was found) are not shown.
==1075091== To see them, rerun with: --leak-check=full --show-leak-kinds=all
==1075091== 
==1075091== For lists of detected and suppressed errors, rerun with: -s
==1075091== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 0 from 0)

Expected behavior

No memory leak

Actual behavior

memory leak, please see the above log

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions