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

Fix leak in test_subscription_content_filter_options.cpp #978

Merged

Conversation

sloretz
Copy link
Contributor

@sloretz sloretz commented Apr 15, 2022

I was checking rcl under the Address Sanitizer and noticed a leak in this test. It's missing a delete on the subscription pointer. I used std::unique_ptr to fix it since the tests are C++.

103: ==25716==ERROR: LeakSanitizer: detected memory leaks
103: 
103: Direct leak of 16 byte(s) in 2 object(s) allocated from:
103:     #0 0x7f6a74ffd1c7 in operator new(unsigned long) ../../../../src/libsanitizer/asan/asan_new_delete.cpp:99
103:     #1 0x557a65297980 in TestSubscriptionContentFilterOptions::SetUp() (/home/sloretz/ws/ros2/build/rcl/test/test_subscription_content_filter_options+0x30980)
103:     #2 0x557a6531c97f in void testing::internal::HandleSehExceptionsInMethodIfSupported<testing::Test, void>(testing::Test*, void (testing::Test::*)(), char const*) /home/sloretz/ws/ros2/install/gtest_vendor/src/gtest_vendor/./src/gtest.cc:2433
103:     #3 0x557a6530c30d in void testing::internal::HandleExceptionsInMethodIfSupported<testing::Test, void>(testing::Test*, void (testing::Test::*)(), char const*) /home/sloretz/ws/ros2/install/gtest_vendor/src/gtest_vendor/./src/gtest.cc:2469
103:     #4 0x557a652b33e6 in testing::Test::Run() /home/sloretz/ws/ros2/install/gtest_vendor/src/gtest_vendor/./src/gtest.cc:2503
103:     #5 0x557a652b497a in testing::TestInfo::Run() /home/sloretz/ws/ros2/install/gtest_vendor/src/gtest_vendor/./src/gtest.cc:2684
103:     #6 0x557a652b56b2 in testing::TestSuite::Run() /home/sloretz/ws/ros2/install/gtest_vendor/src/gtest_vendor/./src/gtest.cc:2816
103:     #7 0x557a652d2619 in testing::internal::UnitTestImpl::RunAllTests() /home/sloretz/ws/ros2/install/gtest_vendor/src/gtest_vendor/./src/gtest.cc:5338
103:     #8 0x557a6531fda5 in bool testing::internal::HandleSehExceptionsInMethodIfSupported<testing::internal::UnitTestImpl, bool>(testing::internal::UnitTestImpl*, bool (testing::internal::UnitTestImpl::*)(), char const*) /home/sloretz/ws/ros2/install/gtest_vendor/src/gtest_vendor/./src/gtest.cc:2433
103:     #9 0x557a6530ee4e in bool testing::internal::HandleExceptionsInMethodIfSupported<testing::internal::UnitTestImpl, bool>(testing::internal::UnitTestImpl*, bool (testing::internal::UnitTestImpl::*)(), char const*) /home/sloretz/ws/ros2/install/gtest_vendor/src/gtest_vendor/./src/gtest.cc:2469
103:     #10 0x557a652cf0ad in testing::UnitTest::Run() /home/sloretz/ws/ros2/install/gtest_vendor/src/gtest_vendor/./src/gtest.cc:4925
103:     #11 0x557a6529f239 in RUN_ALL_TESTS() /home/sloretz/ws/ros2/install/gtest_vendor/src/gtest_vendor/include/gtest/gtest.h:2473
103:     #12 0x557a6529f102 in main /home/sloretz/ws/ros2/install/gtest_vendor/src/gtest_vendor/src/gtest_main.cc:45
103:     #13 0x7f6a72fced8f  (/lib/x86_64-linux-gnu/libc.so.6+0x29d8f)
103: 
103: SUMMARY: AddressSanitizer: 16 byte(s) leaked in 2 allocation(s).
103: -- run_test.py: return code 1
103: -- run_test.py: inject classname prefix into gtest result file '/home/sloretz/ws/ros2/build/rcl/test_results/rcl/test_subscription_content_filter_options.gtest.xml'
103: -- run_test.py: verify result file '/home/sloretz/ws/ros2/build/rcl/test_results/rcl/test_subscription_content_filter_options.gtest.xml'
1/1 Test #103: test_subscription_content_filter_options ...***Failed    0.68 sec

I also updated the names of the class member variables to match the ROS 2 style guide.

Signed-off-by: Shane Loretz <sloretz@openrobotics.org>
@sloretz sloretz added the bug Something isn't working label Apr 15, 2022
@sloretz sloretz self-assigned this Apr 15, 2022
@sloretz
Copy link
Contributor Author

sloretz commented Apr 15, 2022

CI (build: --packages-up-to rcl test: --packages-select rcl)

  • Linux Build Status
  • Linux-aarch64 Build Status
  • Windows Build Status

Copy link
Collaborator

@fujitatomoya fujitatomoya left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm, thanks!

@sloretz sloretz merged commit 71baed4 into master Apr 15, 2022
@delete-merged-branch delete-merged-branch bot deleted the sloretz__asan_test_subscription_content_filter_options branch April 15, 2022 18:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants