Skip to content

rcl_[publisher/subscription]_event_init not to deallocate event->impl if not return successfully #789

@iuhilnehc-ynos

Description

@iuhilnehc-ynos

Bug report

Required Info:

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

Steps to reproduce issue

$ colcon build --cmake-args -DCMAKE_BUILD_TYPE=Debug --packages-up-to rcl
$ . install/setup.bash
$ valgrind --leak-check=full ./build/rcl/test/test_events__rmw_cyclonedds_cpp  // or test_events__rmw_fastrtps_cpp

Expected behavior

No memory leak

Actual behavior

memory leak via valgrind

==255287== 64 bytes in 1 blocks are definitely lost in loss record 4 of 19
==255287==    at 0x483D7F3: malloc (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_memcheck-amd64-linux.so)
==255287==    by 0x50AFF06: __default_allocate (allocator.c:37)
==255287==    by 0x48626D4: rcl_publisher_event_init (event.c:59)
==255287==    by 0x19AAB1: TestEventFixture_test_bad_event_ini_Test::TestBody() (test_events.cpp:712)
==255287==    by 0x1E1B29: void testing::internal::HandleSehExceptionsInMethodIfSupported<testing::Test, void>(testing::Test*, void (testing::Test::*)(), char const*) (gtest.cc:2447)
==255287==    by 0x1DA768: void testing::internal::HandleExceptionsInMethodIfSupported<testing::Test, void>(testing::Test*, void (testing::Test::*)(), char const*) (gtest.cc:2483)
==255287==    by 0x1B638B: testing::Test::Run() (gtest.cc:2522)
==255287==    by 0x1B6D84: testing::TestInfo::Run() (gtest.cc:2703)
==255287==    by 0x1B7475: testing::TestCase::Run() (gtest.cc:2825)
==255287==    by 0x1C2B5E: testing::internal::UnitTestImpl::RunAllTests() (gtest.cc:5216)
==255287==    by 0x1E3023: bool testing::internal::HandleSehExceptionsInMethodIfSupported<testing::internal::UnitTestImpl, bool>(testing::internal::UnitTestImpl*, bool (testing::internal::UnitTestImpl::*)(), char const*) (gtest.cc:2447)
==255287==    by 0x1DB87C: bool testing::internal::HandleExceptionsInMethodIfSupported<testing::internal::UnitTestImpl, bool>(testing::internal::UnitTestImpl*, bool (testing::internal::UnitTestImpl::*)(), char const*) (gtest.cc:2483)
==255287== 
==255287== 64 bytes in 1 blocks are definitely lost in loss record 5 of 19
==255287==    at 0x483D7F3: malloc (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_memcheck-amd64-linux.so)
==255287==    by 0x50AFF06: __default_allocate (allocator.c:37)
==255287==    by 0x48628E3: rcl_subscription_event_init (event.c:102)
==255287==    by 0x19AB92: TestEventFixture_test_bad_event_ini_Test::TestBody() (test_events.cpp:719)
==255287==    by 0x1E1B29: void testing::internal::HandleSehExceptionsInMethodIfSupported<testing::Test, void>(testing::Test*, void (testing::Test::*)(), char const*) (gtest.cc:2447)
==255287==    by 0x1DA768: void testing::internal::HandleExceptionsInMethodIfSupported<testing::Test, void>(testing::Test*, void (testing::Test::*)(), char const*) (gtest.cc:2483)
==255287==    by 0x1B638B: testing::Test::Run() (gtest.cc:2522)
==255287==    by 0x1B6D84: testing::TestInfo::Run() (gtest.cc:2703)
==255287==    by 0x1B7475: testing::TestCase::Run() (gtest.cc:2825)
==255287==    by 0x1C2B5E: testing::internal::UnitTestImpl::RunAllTests() (gtest.cc:5216)
==255287==    by 0x1E3023: bool testing::internal::HandleSehExceptionsInMethodIfSupported<testing::internal::UnitTestImpl, bool>(testing::internal::UnitTestImpl*, bool (testing::internal::UnitTestImpl::*)(), char const*) (gtest.cc:2447)
==255287==    by 0x1DB87C: bool testing::internal::HandleExceptionsInMethodIfSupported<testing::internal::UnitTestImpl, bool>(testing::internal::UnitTestImpl*, bool (testing::internal::UnitTestImpl::*)(), char const*) (gtest.cc:2483)

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