Skip to content

Created rmw subscription/publisher handle isn't freed while failing to get qos from rmw in rcl_subscription/publisher_init() #793

@Barry-Xu-2018

Description

@Barry-Xu-2018

Bug report

  • Operating System:
    • Ubuntu 20.04
  • Installation type:
    • source
  • Version or commit hash:
  • DDS implementation:
    • fastrtps and cyclonedds
  • Client library (if applicable):
    • rcl

Steps to reproduce issue

$ colcon build - --packages-up-to rcl --symlink-install -cmake-args -DCMAKE_BUILD_TYPE=Debug
$ source install/setup.bash
$ valgrind --leak-check=full ./build/rcl/test/test_subscription__rmw_fastrtps_cpp
$ valgrind --leak-check=full ./build/rcl/test/test_publisher__rmw_fastrtps_cpp

Expected behavior

No memory leak

Actual behavior

$ valgrind --leak-check=full ./build/rcl/test/test_subscription__rmw_fastrtps_cpp
...
==247122== 483 (48 direct, 435 indirect) bytes in 1 blocks are definitely lost in loss record 44 of 47
==247122==    at 0x483F7F3: malloc (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_memcheck-amd64-linux.so)
==247122==    by 0x5130F06: __default_allocate (allocator.c:37)
==247122==    by 0x5147597: rmw_allocate (allocators.c:29)
==247122==    by 0x514769F: rmw_subscription_allocate (allocators.c:76)
==247122==    by 0x50FC6B5: rmw_fastrtps_cpp::create_subscription(CustomParticipantInfo const*, rosidl_message_type_support_t const*, char const*, rmw_qos_profile_t const*, rmw_subscription_options_t const*, bool, bool) (subscription.cpp:170)
==247122==    by 0x50F9130: rmw_create_subscription (rmw_subscription.cpp:73)
==247122==    by 0x4875437: rcl_subscription_init (subscription.c:161)
==247122==    by 0x1258DC: TestSubscriptionFixture__rmw_fastrtps_cpp_test_subscription_bad_init_Test::TestBody() (test_subscription.cpp:238)
==247122==    by 0x18E689: void testing::internal::HandleSehExceptionsInMethodIfSupported<testing::Test, void>(testing::Test*, void (testing::Test::*)(), char const*) (gtest.cc:2447)
==247122==    by 0x18703C: void testing::internal::HandleExceptionsInMethodIfSupported<testing::Test, void>(testing::Test*, void (testing::Test::*)(), char const*) (gtest.cc:2483)
==247122==    by 0x162D0F: testing::Test::Run() (gtest.cc:2522)
==247122==    by 0x163708: testing::TestInfo::Run() (gtest.cc:2703)
...

$ valgrind --leak-check=full ./build/rcl/test/test_publisher__rmw_fastrtps_cpp
... 
==248295== 440 (40 direct, 400 indirect) bytes in 1 blocks are definitely lost in loss record 24 of 28
==248295==    at 0x483F7F3: malloc (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_memcheck-amd64-linux.so)
==248295==    by 0x5130F06: __default_allocate (allocator.c:37)
==248295==    by 0x5147597: rmw_allocate (allocators.c:29)
==248295==    by 0x514766C: rmw_publisher_allocate (allocators.c:62)
==248295==    by 0x50DA4D7: rmw_fastrtps_cpp::create_publisher(CustomParticipantInfo const*, rosidl_message_type_support_t const*, char const*, rmw_qos_profile_t const*, rmw_publisher_options_t const*, bool, bool) (publisher.cpp:169)
==248295==    by 0x50EE67E: rmw_create_publisher (rmw_publisher.cpp:75)
==248295==    by 0x486F6D0: rcl_publisher_init (publisher.c:174)
==248295==    by 0x12DAF0: TestPublisherFixture__rmw_fastrtps_cpp_test_mock_publisher_init_fail_qos_Test::TestBody() (test_publisher.cpp:668)
==248295==    by 0x188767: void testing::internal::HandleSehExceptionsInMethodIfSupported<testing::Test, void>(testing::Test*, void (testing::Test::*)(), char const*) (gtest.cc:2447)
==248295==    by 0x181058: void testing::internal::HandleExceptionsInMethodIfSupported<testing::Test, void>(testing::Test*, void (testing::Test::*)(), char const*) (gtest.cc:2483)
==248295==    by 0x15CC33: testing::Test::Run() (gtest.cc:2522)
==248295==    by 0x15D62C: testing::TestInfo::Run() (gtest.cc:2703)
...

Metadata

Metadata

Assignees

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