Memory Leaks in SstWriter
Created by: NAThompson
Add the following lines to the ADIOS2
CMakeLists.txt
:
if(CMAKE_BUILD_TYPE MATCHES "Debug")
if(CMAKE_CXX_COMPILER_ID MATCHES "^(AppleClang|Clang|GNU)")
set(CMAKE_CXX_FLAGS_DEBUG "-Wall -g -O2 -Wfatal-errors -fsanitize=address -fsanitize=undefined -fno-omit-frame-pointer")
endif()
endif()
Then we observe a memory leak:
build_adios2$ /bin/TestSstParamFails "--gtest_filter=SstParamFailTest.CompressionMethodUnknown"
Note: Google Test filter = SstParamFailTest.CompressionMethodUnknown
[==========] Running 1 test from 1 test case.
[----------] Global test environment set-up.
[----------] 1 test from SstParamFailTest
[ RUN ] SstParamFailTest.CompressionMethodUnknown
[ OK ] SstParamFailTest.CompressionMethodUnknown (1 ms)
[----------] 1 test from SstParamFailTest (1 ms total)
[----------] Global test environment tear-down
[==========] 1 test from 1 test case ran. (1 ms total)
[ PASSED ] 1 test.
=================================================================
==15219==ERROR: LeakSanitizer: detected memory leaks
Direct leak of 10 byte(s) in 1 object(s) allocated from:
#0 0x7f2f11419618 in operator new[](unsigned long) (/usr/lib/x86_64-linux-gnu/libasan.so.4+0xe0618)
#1 0x7f2f09afee65 in adios2::core::engine::SstWriter::SstWriter(adios2::core::IO&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, adios2::Mode, int)/ADIOS2/source/adios2/engine/sst/SstWriter.cpp:30
#2 0x7f2f07dc88cf in void __gnu_cxx::new_allocator<adios2::core::engine::SstWriter>::construct<adios2::core::engine::SstWriter, adios2::core::IO&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, adios2::Mode const&, int&>(adios2::core::engine::SstWriter*, adios2::core::IO&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, adios2::Mode const&, int&) /usr/include/c++/7/ext/new_allocator.h:136
#3 0x7f2f07dc88cf in void std::allocator_traits<std::allocator<adios2::core::engine::SstWriter> >::construct<adios2::core::engine::SstWriter, adios2::core::IO&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, adios2::Mode const&, int&>(std::allocator<adios2::core::engine::SstWriter>&, adios2::core::engine::SstWriter*, adios2::core::IO&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, adios2::Mode const&, int&) /usr/include/c++/7/bits/alloc_traits.h:475
#4 0x7f2f07dc88cf in std::_Sp_counted_ptr_inplace<adios2::core::engine::SstWriter, std::allocator<adios2::core::engine::SstWriter>, (__gnu_cxx::_Lock_policy)2>::_Sp_counted_ptr_inplace<adios2::core::IO&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, adios2::Mode const&, int&>(std::allocator<adios2::core::engine::SstWriter>, adios2::core::IO&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, adios2::Mode const&, int&) /usr/include/c++/7/bits/shared_ptr_base.h:526
#5 0x7f2f07dc88cf in std::__shared_count<(__gnu_cxx::_Lock_policy)2>::__shared_count<adios2::core::engine::SstWriter, std::allocator<adios2::core::engine::SstWriter>, adios2::core::IO&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, adios2::Mode const&, int&>(std::_Sp_make_shared_tag, adios2::core::engine::SstWriter*, std::allocator<adios2::core::engine::SstWriter> const&, adios2::core::IO&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, adios2::Mode const&, int&) /usr/include/c++/7/bits/shared_ptr_base.h:637
#6 0x7f2f07dc88cf in std::__shared_ptr<adios2::core::engine::SstWriter, (__gnu_cxx::_Lock_policy)2>::__shared_ptr<std::allocator<adios2::core::engine::SstWriter>, adios2::core::IO&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, adios2::Mode const&, int&>(std::_Sp_make_shared_tag, std::allocator<adios2::core::engine::SstWriter> const&, adios2::core::IO&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, adios2::Mode const&, int&) /usr/include/c++/7/bits/shared_ptr_base.h:1295
#7 0x7f2f07dc88cf in std::shared_ptr<adios2::core::engine::SstWriter>::shared_ptr<std::allocator<adios2::core::engine::SstWriter>, adios2::core::IO&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, adios2::Mode const&, int&>(std::_Sp_make_shared_tag, std::allocator<adios2::core::engine::SstWriter> const&, adios2::core::IO&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, adios2::Mode const&, int&) /usr/include/c++/7/bits/shared_ptr.h:344
#8 0x7f2f07dc88cf in std::shared_ptr<adios2::core::engine::SstWriter> std::allocate_shared<adios2::core::engine::SstWriter, std::allocator<adios2::core::engine::SstWriter>, adios2::core::IO&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, adios2::Mode const&, int&>(std::allocator<adios2::core::engine::SstWriter> const&, adios2::core::IO&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, adios2::Mode const&, int&) /usr/include/c++/7/bits/shared_ptr.h:691
#9 0x7f2f07dc88cf in std::shared_ptr<adios2::core::engine::SstWriter> std::make_shared<adios2::core::engine::SstWriter, adios2::core::IO&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, adios2::Mode const&, int&>(adios2::core::IO&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, adios2::Mode const&, int&) /usr/include/c++/7/bits/shared_ptr.h:707
#10 0x7f2f07dc88cf in adios2::core::IO::Open(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, adios2::Mode, int) /ADIOS2/source/adios2/core/IO.cpp:567
#11 0x7f2f09e8d2e4 in adios2::IO::Open(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, adios2::Mode) /ADIOS2/bindings/CXX11/adios2/cxx11/IO.cpp:120
#12 0x55acba0213d8 in SstParamFailTest_CompressionMethodUnknown_Test::TestBody() /home/4nt/ADIOS2/testing/adios2/engine/sst/TestSstParamFails.cpp:115
#13 0x55acba1c4c3d in void testing::internal::HandleSehExceptionsInMethodIfSupported<testing::Test, void>(testing::Test*, void (testing::Test::*)(), char const*)/ADIOS2/thirdparty/GTest/googletest/googletest/src/gtest.cc:2411
#14 0x55acba1c4c3d in void testing::internal::HandleExceptionsInMethodIfSupported<testing::Test, void>(testing::Test*, void (testing::Test::*)(), char const*) /ADIOS2/thirdparty/GTest/googletest/googletest/src/gtest.cc:2447
#15 0x55acba13dcbd in testing::Test::Run() /ADIOS2/thirdparty/GTest/googletest/googletest/src/gtest.cc:2485
#16 0x55acba13ec0b in testing::Test::Run() /ADIOS2/thirdparty/GTest/googletest/googletest/src/gtest.cc:2665
#17 0x55acba13ec0b in testing::TestInfo::Run() /ADIOS2/thirdparty/GTest/googletest/googletest/src/gtest.cc:2661
#18 0x55acba13fe95 in testing::TestCase::Run() /ADIOS2/thirdparty/GTest/googletest/googletest/src/gtest.cc:2779
#19 0x55acba14418c in testing::internal::UnitTestImpl::RunAllTests() /ADIOS2/thirdparty/GTest/googletest/googletest/src/gtest.cc:5036
#20 0x55acba1c6d6d in bool testing::internal::HandleSehExceptionsInMethodIfSupported<testing::internal::UnitTestImpl, bool>(testing::internal::UnitTestImpl*, bool (testing::internal::UnitTestImpl::*)(), char const*) /ADIOS2/thirdparty/GTest/googletest/googletest/src/gtest.cc:2411
#21 0x55acba1c6d6d in bool testing::internal::HandleExceptionsInMethodIfSupported<testing::internal::UnitTestImpl, bool>(testing::internal::UnitTestImpl*, bool (testing::internal::UnitTestImpl::*)(), char const*) /ADIOS2/thirdparty/GTest/googletest/googletest/src/gtest.cc:2447
#22 0x55acba146931 in testing::UnitTest::Run() /ADIOS2/thirdparty/GTest/googletest/googletest/src/gtest.cc:4652
#23 0x55acba0131c0 in RUN_ALL_TESTS() /ADIOS2/thirdparty/GTest/googletest/googletest/include/gtest/gtest.h:2314
#24 0x55acba0131c0 in main /ADIOS2/testing/adios2/engine/sst/TestSstParamFails.cpp:206
#25 0x7f2f011b8b96 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21b96)
SUMMARY: AddressSanitizer: 10 byte(s) leaked in 1 allocation(s).
You will forgive me for the perpetual stream of seemingly small bugs, but I'm too dumb to program in C++ without the google sanitizer suite, and I'm dream that we can get a clean run of the units tests so that I can be confident that I didn't add any problems as I start to contribute more code.