Skip to content

Fix leak in test_basic.cpp#9

Merged
thomas-moulard merged 1 commit intomasterfrom
thomas-moulard/fix-leak
Apr 8, 2019
Merged

Fix leak in test_basic.cpp#9
thomas-moulard merged 1 commit intomasterfrom
thomas-moulard/fix-leak

Conversation

@thomas-moulard
Copy link
Copy Markdown

Signed-off-by: Thomas Moulard tmoulard@amazon.com

@thomas-moulard
Copy link
Copy Markdown
Author

thomas-moulard commented Apr 6, 2019

ASAN output before:

./build-asan/rcpputils/test_basic                                                                                                                                                                                                                                                                                                                                              
Running main() from ../../../install-asan/gtest_vendor/src/gtest_vendor/src/gtest_main.cc                                                                                                                                                                                                                                                                                                    
[==========] Running 7 tests from 1 test case.                                                                                                                                                                                                                                                                                                                                               
[----------] Global test environment set-up.                                                                                                                                                                                                                                                                                                                                                 
[----------] 7 tests from test_tsa                                                                                                                                                                                                                                                                                                                                                           
[ RUN      ] test_tsa.libcxx_types                                                                                                                                                                                                                                                                                                                                                           
[       OK ] test_tsa.libcxx_types (0 ms)                                                                                                                                                                                                                                                                                                                                                    
[ RUN      ] test_tsa.capability                                                                                                                                                                                                                                                                                                                                                             
[       OK ] test_tsa.capability (0 ms)                                                                                                                                                                                                                                                                                                                                                      
[ RUN      ] test_tsa.ptr_guard                                                                                                                                                                                                                                                                                                                                                              
[       OK ] test_tsa.ptr_guard (0 ms)                                                                                                                                                                                                                                                                                                                                                       
[ RUN      ] test_tsa.shared_capability                                                                                                                                                                                                                                                                                                                                                      
[       OK ] test_tsa.shared_capability (0 ms)                                                                                                                                                                                                                                                                                                                                               
[ RUN      ] test_tsa.return_capability                                                                                                                                                                                                                                                                                                                                                      
[       OK ] test_tsa.return_capability (0 ms)                                                                                                                                                                                                                                                                                                                                               
[ RUN      ] test_tsa.try_acquire                                                                                                                                                                                                                                                                                                                                                            
[       OK ] test_tsa.try_acquire (0 ms)                                                                                                                                                                                                                                                                                                                                                     
[ RUN      ] test_tsa.acquire_ordering                                                                                                                                                                                                                                                                                                                                                       
[       OK ] test_tsa.acquire_ordering (0 ms)                                                                                                                                                                                                                                                                                                                                                
[----------] 7 tests from test_tsa (0 ms total)                                                                                                                                                                                                                                                                                                                                              
                                                                                                                                                                                                                                                                                                                                                                                             
[----------] Global test environment tear-down                                                                                                                                                                                                                                                                                                                                               
[==========] 7 tests from 1 test case ran. (0 ms total)                                                                                                                                                                                                                                                                                                                                      
[  PASSED  ] 7 tests.                                                                                                                                                                                                                                                                                                                                                                        
                                                                                                                                                                                                                                                                                                                                                                                             
=================================================================                                                                                                                                                                                                                                                                                                                            
==30859==ERROR: LeakSanitizer: detected memory leaks                                                                                                                                                                                                                                                                                                                                         
                                                                                                                                                                                                                                                                                                                                                                                             
Direct leak of 4 byte(s) in 1 object(s) allocated from:                                                                                                                                                                                                                                                                                                                                      
    #0 0x7fbefcd0b458 in operator new(unsigned long) (/usr/lib/x86_64-linux-gnu/libasan.so.4+0xe0458)                                                                                                                                                                                                  
    #1 0x5620b4c650a9 in FakeGuarded::FakeGuarded() (/home/ANT.AMAZON.COM/tmoulard/ros2_ws/build-asan/rcpputils/test_basic+0x190a9)                                                                                           
    #2 0x5620b4c63444 in test_tsa_shared_capability_Test::TestBody() (/home/ANT.AMAZON.COM/tmoulard/ros2_ws/build-asan/rcpputils/test_basic+0x17444)                                         
    #3 0x5620b4cdc4fd in void testing::internal::HandleSehExceptionsInMethodIfSupported<testing::Test, void>(testing::Test*, void (testing::Test::*)(), char const*) (/home/ANT.AMAZON.COM/tmoulard/ros2_ws/build-asan/rcpputils/test_basic+0x904fd)                                                      
    #4 0x5620b4cce1e7 in void testing::internal::HandleExceptionsInMethodIfSupported<testing::Test, void>(testing::Test*, void (testing::Test::*)(), char const*) (/home/ANT.AMAZON.COM/tmoulard/ros2_ws/build-asan/rcpputils/test_basic+0x821e7)                                                       
    #5 0x5620b4c79f0f in testing::Test::Run() (/home/ANT.AMAZON.COM/tmoulard/ros2_ws/build-asan/rcpputils/test_basic+0x2df0f)                                                                                                                                                                             
    #6 0x5620b4c7b33a in testing::TestInfo::Run() (/home/ANT.AMAZON.COM/tmoulard/ros2_ws/build-asan/rcpputils/test_basic+0x2f33a)                                                                                                                                                                      
    #7 0x5620b4c7bede in testing::TestCase::Run() (/home/ANT.AMAZON.COM/tmoulard/ros2_ws/build-asan/rcpputils/test_basic+0x2fede)   
    #8 0x5620b4c96fef in testing::internal::UnitTestImpl::RunAllTests() (/home/ANT.AMAZON.COM/tmoulard/ros2_ws/build-asan/rcpputils/test_basic+0x4afef)                                                                                                                                                                                                                                     
    #9 0x5620b4cdefb0 in bool testing::internal::HandleSehExceptionsInMethodIfSupported<testing::internal::UnitTestImpl, bool>(testing::internal::UnitTestImpl*, bool (testing::internal::UnitTestImpl::*)(), char const*) (/home/ANT.AMAZON.COM/tmoulard/ros2_ws/build-asan/rcpputils/test_basic+0x92fb0)   
    #10 0x5620b4cd04b0 in bool testing::internal::HandleExceptionsInMethodIfSupported<testing::internal::UnitTestImpl, bool>(testing::internal::UnitTestImpl*, bool (testing::internal::UnitTestImpl::*)(), char const*) (/home/ANT.AMAZON.COM/tmoulard/ros2_ws/build-asan/rcpputils/test_basic+0x844b0)                                                                                    
    #11 0x5620b4c93d83 in testing::UnitTest::Run() (/home/ANT.AMAZON.COM/tmoulard/ros2_ws/build-asan/rcpputils/test_basic+0x47d83)                                                                                                                                                                                 
    #12 0x5620b4c672d2 in RUN_ALL_TESTS() (/home/ANT.AMAZON.COM/tmoulard/ros2_ws/build-asan/rcpputils/test_basic+0x1b2d2)                                                                                                                                                                                                      
    #13 0x5620b4c67218 in main (/home/ANT.AMAZON.COM/tmoulard/ros2_ws/build-asan/rcpputils/test_basic+0x1b218)                                                                                                                                                                                                     
    #14 0x7fbefc09bb96 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21b96)                                                                                                        
                                                                                                                                           
Direct leak of 4 byte(s) in 1 object(s) allocated from:                                                                                     
    #0 0x7fbefcd0b458 in operator new(unsigned long) (/usr/lib/x86_64-linux-gnu/libasan.so.4+0xe0458)                                                                                                                                               
    #1 0x5620b4c650a9 in FakeGuarded::FakeGuarded() (/home/ANT.AMAZON.COM/tmoulard/ros2_ws/build-asan/rcpputils/test_basic+0x190a9)                                                                                                              
    #2 0x5620b4c62d4b in test_tsa_capability_Test::TestBody() (/home/ANT.AMAZON.COM/tmoulard/ros2_ws/build-asan/rcpputils/test_basic+0x16d4b)   
    #3 0x5620b4cdc4fd in void testing::internal::HandleSehExceptionsInMethodIfSupported<testing::Test, void>(testing::Test*, void (testing::Test::*)(), char const*) (/home/ANT.AMAZON.COM/tmoulard/ros2_ws/build-asan/rcpputils/test_basic+0x904fd)   
    #4 0x5620b4cce1e7 in void testing::internal::HandleExceptionsInMethodIfSupported<testing::Test, void>(testing::Test*, void (testing::Test::*)(), char const*) (/home/ANT.AMAZON.COM/tmoulard/ros2_ws/build-asan/rcpputils/test_basic+0x821e7)   
    #5 0x5620b4c79f0f in testing::Test::Run() (/home/ANT.AMAZON.COM/tmoulard/ros2_ws/build-asan/rcpputils/test_basic+0x2df0f)                                                                 
    #6 0x5620b4c7b33a in testing::TestInfo::Run() (/home/ANT.AMAZON.COM/tmoulard/ros2_ws/build-asan/rcpputils/test_basic+0x2f33a)                                                                                                                                                                         
    #7 0x5620b4c7bede in testing::TestCase::Run() (/home/ANT.AMAZON.COM/tmoulard/ros2_ws/build-asan/rcpputils/test_basic+0x2fede)                                                                                                                                                                       
    #8 0x5620b4c96fef in testing::internal::UnitTestImpl::RunAllTests() (/home/ANT.AMAZON.COM/tmoulard/ros2_ws/build-asan/rcpputils/test_basic+0x4afef)   
    #9 0x5620b4cdefb0 in bool testing::internal::HandleSehExceptionsInMethodIfSupported<testing::internal::UnitTestImpl, bool>(testing::internal::UnitTestImpl*, bool (testing::internal::UnitTestImpl::*)(), char const*) (/home/ANT.AMAZON.COM/tmoulard/ros2_ws/build-asan/rcpputils/test_basic+0x92fb0)   
    #10 0x5620b4cd04b0 in bool testing::internal::HandleExceptionsInMethodIfSupported<testing::internal::UnitTestImpl, bool>(testing::internal::UnitTestImpl*, bool (testing::internal::UnitTestImpl::*)(), char const*) (/home/ANT.AMAZON.COM/tmoulard/ros2_ws/build-asan/rcpputils/test_basic+0x844b0)   
    #11 0x5620b4c93d83 in testing::UnitTest::Run() (/home/ANT.AMAZON.COM/tmoulard/ros2_ws/build-asan/rcpputils/test_basic+0x47d83)                                                            
    #12 0x5620b4c672d2 in RUN_ALL_TESTS() (/home/ANT.AMAZON.COM/tmoulard/ros2_ws/build-asan/rcpputils/test_basic+0x1b2d2)                                                                                                                                                                                 
    #13 0x5620b4c67218 in main (/home/ANT.AMAZON.COM/tmoulard/ros2_ws/build-asan/rcpputils/test_basic+0x1b218)                                                                                                                                                                                          
    #14 0x7fbefc09bb96 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21b96)                                             
                                                                                                                                 
SUMMARY: AddressSanitizer: 8 byte(s) leaked in 2 allocation(s).   

This is now fixed.

Copy link
Copy Markdown

@prajakta-gokhale prajakta-gokhale left a comment

Choose a reason for hiding this comment

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

Looks good to me.

Copy link
Copy Markdown
Contributor

@emersonknapp emersonknapp left a comment

Choose a reason for hiding this comment

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

Good catch

Signed-off-by: Thomas Moulard <tmoulard@amazon.com>
@thomas-moulard thomas-moulard force-pushed the thomas-moulard/fix-leak branch from d39d6f7 to 5d77f18 Compare April 8, 2019 21:47
@thomas-moulard thomas-moulard merged commit 418f95c into master Apr 8, 2019
@delete-merged-branch delete-merged-branch bot deleted the thomas-moulard/fix-leak branch April 8, 2019 21:48
@tfoote tfoote removed the in progress label Apr 8, 2019
@thomas-moulard
Copy link
Copy Markdown
Author

thomas-moulard commented Apr 8, 2019

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

@ros-discourse
Copy link
Copy Markdown

This pull request has been mentioned on ROS Discourse. There might be relevant details there:

https://discourse.ros.org/t/introducing-ros2-sanitizer-report-and-analysis/9287/1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants