Skip to content

Extracted msg from LoanedMessage not destroy #1304

@iuhilnehc-ynos

Description

@iuhilnehc-ynos

Bug report

Required Info:

  • Operating System:
    • Ubuntu 20.04
  • Installation type:
    • source
  • Version or commit hash:
  • DDS implementation:
    • rmw_fastrtps_cpp
  • Client library (if applicable):
    • rclcpp

Steps to reproduce issue

$ colcon build --cmake-args -DCMAKE_BUILD_TYPE=Debug --packages-up-to rclcpp
$ . install/setup.bash
$ valgrind --leak-check=full ./build/rclcpp/test/test_loaned_message

Expected behavior

No memory leak

Actual behavior

memory leak log

==1676834== 
==1676834== HEAP SUMMARY:
==1676834==     in use at exit: 52,173 bytes in 106 blocks
==1676834==   total heap usage: 20,136 allocs, 20,030 frees, 9,441,487 bytes allocated
==1676834== 
==1676834== 48 bytes in 1 blocks are definitely lost in loss record 1 of 31
==1676834==    at 0x483DE63: operator new(unsigned long) (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_memcheck-amd64-linux.so)
==1676834==    by 0x14DD6A: __gnu_cxx::new_allocator<test_msgs::msg::BasicTypes_<std::allocator<void> > >::allocate(unsigned long, void const*) (new_allocator.h:114)
==1676834==    by 0x14CFD5: rclcpp::LoanedMessage<test_msgs::msg::BasicTypes_<std::allocator<void> >, std::allocator<void> >::LoanedMessage(rclcpp::PublisherBase const&, std::allocator<test_msgs::msg::BasicTypes_<std::allocator<void> > >) (loaned_message.hpp:80)
==1676834==    by 0x14B90C: rclcpp::LoanedMessage<test_msgs::msg::BasicTypes_<std::allocator<void> >, std::allocator<void> >::LoanedMessage(rclcpp::PublisherBase const*, std::shared_ptr<std::allocator<test_msgs::msg::BasicTypes_<std::allocator<void> > > >) (loaned_message.hpp:109)
==1676834==    by 0x14BE61: rclcpp::Publisher<test_msgs::msg::BasicTypes_<std::allocator<void> >, std::allocator<void> >::borrow_loaned_message() (publisher.hpp:176)
==1676834==    by 0x148F76: TestLoanedMessage_release_Test::TestBody() (test_loaned_message.cpp:70)
==1676834==    by 0x19785B: void testing::internal::HandleSehExceptionsInMethodIfSupported<testing::Test, void>(testing::Test*, void (testing::Test::*)(), char const*) (gtest.cc:2447)
==1676834==    by 0x1903BA: void testing::internal::HandleExceptionsInMethodIfSupported<testing::Test, void>(testing::Test*, void (testing::Test::*)(), char const*) (gtest.cc:2483)
==1676834==    by 0x16BECD: testing::Test::Run() (gtest.cc:2522)
==1676834==    by 0x16C8C6: testing::TestInfo::Run() (gtest.cc:2703)
==1676834==    by 0x16CFB7: testing::TestCase::Run() (gtest.cc:2825)
==1676834==    by 0x1786A0: testing::internal::UnitTestImpl::RunAllTests() (gtest.cc:5216)
==1676834== 
==1676834== LEAK SUMMARY:
==1676834==    definitely lost: 48 bytes in 1 blocks
==1676834==    indirectly lost: 0 bytes in 0 blocks
==1676834==      possibly lost: 0 bytes in 0 blocks
==1676834==    still reachable: 52,125 bytes in 105 blocks
==1676834==         suppressed: 0 bytes in 0 blocks
==1676834== Reachable blocks (those to which a pointer was found) are not shown.
==1676834== To see them, rerun with: --leak-check=full --show-leak-kinds=all

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions