memory leak running test
weinberggithub opened this issue · 6 comments
I run the unit test with asan, ASAN_OPTIONS=detect_leaks=1 ./httplib-test
cpp-httplib: commit of 3b6597b on master branch
os: macos ventura 13.5
compiler: clang-1500.1.0.2.5
below is one of the stack
Indirect leak of 128 byte(s) in 1 object(s) allocated from:
#0 0x103a7bc8c in calloc+0x94 (libclang_rt.asan_osx_dynamic.dylib:arm64+0x53c8c)
#1 0x19a936740 in _objc_rootAllocWithZone+0x24 (libobjc.A.dylib:arm64+0xe740)
#2 0x490680019a95cadc (<unknown module>)
#3 0x67388001a1b7f7f8 (<unknown module>)
#4 0x595c0001a196f004 (<unknown module>)
#5 0xfc118001a196ebe4 (<unknown module>)
#6 0xd31a0001a196e4e4 (<unknown module>)
#7 0xde100001a196d300 (<unknown module>)
#8 0x27350001a17dc220 (<unknown module>)
#9 0xa26b80019ad17238 (<unknown module>)
#10 0xa6980019ad03ca0 (<unknown module>)
#11 0x671a80019ad03734 (<unknown module>)
#12 0x173c000103a537d0 (<unknown module>)
#13 0x10264dc34 in int httplib::detail::create_socket<httplib::detail::create_client_socket(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&, int, int, bool, std::__1::function<void (int)>, long, long, long, long, long, long, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&, httplib::Error&)::'lambda'(int, addrinfo&)>(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&, int, int, int, bool, std::__1::function<void (int)>, httplib::detail::create_client_socket(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&, int, int, bool, std::__1::function<void (int)>, long, long, long, long, long, long, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&, httplib::Error&)::'lambda'(int, addrinfo&)) httplib.h:3243
#14 0x10264d620 in httplib::detail::create_client_socket(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&, int, int, bool, std::__1::function<void (int)>, long, long, long, long, long, long, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&, httplib::Error&) httplib.h:3414
#15 0x10264cbdc in httplib::ClientImpl::create_client_socket(httplib::Error&) const httplib.h:6990
#16 0x1027273f4 in httplib::SSLClient::create_and_connect_socket(httplib::ClientImpl::Socket&, httplib::Error&) httplib.h:8885
#17 0x1026dcf70 in httplib::ClientImpl::send_(httplib::Request&, httplib::Response&, httplib::Error&) httplib.h:7107
#18 0x102646674 in httplib::ClientImpl::send_(httplib::Request&&) httplib.h:7180
#19 0x102646230 in httplib::ClientImpl::Get(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&, std::__1::multimap<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>, httplib::detail::ci, std::__1::allocator<std::__1::pair<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>>>> const&, std::__1::function<bool (unsigned long long, unsigned long long)>) httplib.h:7720
#20 0x1024242b0 in RangeTest_FromHTTPBin_Online_Test::TestBody() test.cc:660
#21 0x1028d15f0 in void testing::internal::HandleExceptionsInMethodIfSupported<testing::Test, void>(testing::Test*, void (testing::Test::*)(), char const*) gtest.cc:2671
#22 0x1028d12f4 in testing::Test::Run() gtest.cc:2710
#23 0x1028d3ec0 in testing::TestInfo::Run() gtest.cc:2856
#24 0x1028d66a8 in testing::TestSuite::Run() gtest.cc:3034
#25 0x10290d1f8 in testing::internal::UnitTestImpl::RunAllTests() gtest.cc:5964
#26 0x10290c274 in bool testing::internal::HandleExceptionsInMethodIfSupported<testing::internal::UnitTestImpl, bool>(testing::internal::UnitTestImpl*, bool (testing::internal::UnitTestImpl::*)(), char const*) gtest.cc:2671
#27 0x10290c014 in testing::UnitTest::Run() gtest.cc:5543
#28 0x102883930 in main gtest_main.cc:64
#29 0x19a973f24 (<unknown module>)
@weinberggithub do you mean that this problem starts happening since the commit 3b6597b?
@weinberggithub do you mean that this problem starts happening since the commit 3b6597b?
no,I mean my test based on this commit
@weinberggithub could you try with f10720e?
@weinberggithub could you try with f10720e?
httplib.txt
this is the result.
I'll try to reproduce the problem on my machine. How did you make your httplib-test
which supports ASAN_OPTIONS=detect_leaks=1
with cmake
?
I'll try to reproduce the problem on my machine. How did you make your
httplib-test
which supportsASAN_OPTIONS=detect_leaks=1
withcmake
?
set(CMAKE_CXX_COMPILER "/opt/homebrew/opt/llvm@17/bin/clang++")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address -fno-omit-frame-pointer -g -O1")
on macos(M2, apple chips), simply add two line to CMakeLists.txt and enable HTTPLIB-TEST.