Boost SSL handshake(http_server_sync_ssl) : still reachable memory keeps increasing
Hi all, I am using boost 1.76.0 version. I have slightly modified the example program http_server_sync_ssl.cpp to just dump the payload it receives and i have used certificates with ssl context. When I run the program with valgrind, the "still reachable" memory keeps increasing with time. This is one example: ==17719== 38,880 bytes in 60 blocks are still reachable in loss record 740 of 740 ==17719== at 0x4C312EF: malloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so) ==17719== by 0x567F438: CRYPTO_zalloc (in /usr/lib64/libcrypto.so.1.1) ==17719== by 0x52AA5CA: SSL_SESSION_new (in /usr/lib64/libssl.so.1.1) ==17719== by 0x52AAE22: ??? (in /usr/lib64/libssl.so.1.1) ==17719== by 0x52C8A06: ??? (in /usr/lib64/libssl.so.1.1) ==17719== by 0x52B7FF6: ??? (in /usr/lib64/libssl.so.1.1) ==17719== by 0x52A3F43: SSL_do_handshake (in /usr/lib64/libssl.so.1.1) ==17719== by 0x419630: boost::asio::ssl::detail::engine::do_accept(void*, unsigned long) (engine.ipp:316) ==17719== by 0x4193E3: boost::asio::ssl::detail::engine::perform(int (boost::asio::ssl::detail::engine::*)(void*, unsigned long), void*, unsigned long, boost::system::error_code&, unsigned long*) (engine.ipp:248) ==17719== by 0x418F6D: boost::asio::ssl::detail::engine::handshake(boost::asio::ssl::stream_base::handshake_type, boost::system::error_code&) (engine.ipp:148) ==17719== by 0x419778: boost::asio::ssl::detail::handshake_op::operator()(boost::asio::ssl::detail::engine&, boost::system::error_code&, unsigned long&) const (handshake_op.hpp:47) ==17719== by 0x424DB8: unsigned long boost::asio::ssl::detail::io<boost::asio::basic_stream_socket<boost::asio::ip::tcp, boost::asio::any_io_executor>, boost::asio::ssl::detail::handshake_op>(boost::asio::basic_stream_socket<boost::asio::ip::tcp, boost::asio::any_io_executor>&, boost::asio::ssl::detail::stream_core&, boost::asio::ssl::detail::handshake_op const&, boost::system::error_code&) (io.hpp:38) ==17719== by 0x421332: boost::asio::ssl::stream<boost::asio::basic_stream_socket<boost::asio::ip::tcp, boost::asio::any_io_executor>&>::handshake(boost::asio::ssl::stream_base::handshake_type, boost::system::error_code&) (stream.hpp:389) ==17719== by 0x41D5FC: boost::beast::ssl_stream<boost::asio::basic_stream_socket<boost::asio::ip::tcp, boost::asio::any_io_executor>&>::handshake(boost::asio::ssl::stream_base::handshake_type, boost::system::error_code&) (ssl_stream.hpp:344) ==17719== by 0x406971: do_session(boost::asio::basic_stream_socket<boost::asio::ip::tcp, boost::asio::any_io_executor>&, boost::asio::ssl::context&, std::shared_ptr<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const> const&) (boost_server.cpp:219) I have attached the test program. Can anyone point out what needs to be done here? Thanks & Regards, Sandeep
On Thu, 3 Feb 2022 at 15:52, Sandeep Bhardwaj via Boost-users < boost-users@lists.boost.org> wrote:
Hi all,
I am using boost 1.76.0 version. I have slightly modified the example program http_server_sync_ssl.cpp to just dump the payload it receives and i have used certificates with ssl context. When I run the program with valgrind, the "still reachable" memory keeps increasing with time. This is one example:
Thanks for posting a complete program. I'll compile it up and have a look.
==17719== 38,880 bytes in 60 blocks are still reachable in loss record 740 of 740 ==17719== at 0x4C312EF: malloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so) ==17719== by 0x567F438: CRYPTO_zalloc (in /usr/lib64/libcrypto.so.1.1) ==17719== by 0x52AA5CA: SSL_SESSION_new (in /usr/lib64/libssl.so.1.1) ==17719== by 0x52AAE22: ??? (in /usr/lib64/libssl.so.1.1) ==17719== by 0x52C8A06: ??? (in /usr/lib64/libssl.so.1.1) ==17719== by 0x52B7FF6: ??? (in /usr/lib64/libssl.so.1.1) ==17719== by 0x52A3F43: SSL_do_handshake (in /usr/lib64/libssl.so.1.1) ==17719== by 0x419630: boost::asio::ssl::detail::engine::do_accept(void*, unsigned long) (engine.ipp:316) ==17719== by 0x4193E3: boost::asio::ssl::detail::engine::perform(int (boost::asio::ssl::detail::engine::*)(void*, unsigned long), void*, unsigned long, boost::system::error_code&, unsigned long*) (engine.ipp:248) ==17719== by 0x418F6D: boost::asio::ssl::detail::engine::handshake(boost::asio::ssl::stream_base::handshake_type, boost::system::error_code&) (engine.ipp:148) ==17719== by 0x419778: boost::asio::ssl::detail::handshake_op::operator()(boost::asio::ssl::detail::engine&, boost::system::error_code&, unsigned long&) const (handshake_op.hpp:47) ==17719== by 0x424DB8: unsigned long boost::asio::ssl::detail::io<boost::asio::basic_stream_socket<boost::asio::ip::tcp, boost::asio::any_io_executor>, boost::asio::ssl::detail::handshake_op>(boost::asio::basic_stream_socket<boost::asio::ip::tcp, boost::asio::any_io_executor>&, boost::asio::ssl::detail::stream_core&, boost::asio::ssl::detail::handshake_op const&, boost::system::error_code&) (io.hpp:38) ==17719== by 0x421332: boost::asio::ssl::stream<boost::asio::basic_stream_socket<boost::asio::ip::tcp, boost::asio::any_io_executor>&>::handshake(boost::asio::ssl::stream_base::handshake_type, boost::system::error_code&) (stream.hpp:389) ==17719== by 0x41D5FC: boost::beast::ssl_stream<boost::asio::basic_stream_socket<boost::asio::ip::tcp, boost::asio::any_io_executor>&>::handshake(boost::asio::ssl::stream_base::handshake_type, boost::system::error_code&) (ssl_stream.hpp:344) ==17719== by 0x406971: do_session(boost::asio::basic_stream_socket<boost::asio::ip::tcp, boost::asio::any_io_executor>&, boost::asio::ssl::context&, std::shared_ptr<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const> const&) (boost_server.cpp:219)
I have attached the test program. Can anyone point out what needs to be done here?
Thanks & Regards, Sandeep
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org https://lists.boost.org/mailman/listinfo.cgi/boost-users
I am using OpenSSL 1.1.1d. On Thu, 3 Feb 2022 at 22:43, Richard Hodges via Boost-users < boost-users@lists.boost.org> wrote:
On Thu, 3 Feb 2022 at 15:52, Sandeep Bhardwaj via Boost-users < boost-users@lists.boost.org> wrote:
Hi all,
I am using boost 1.76.0 version. I have slightly modified the example program http_server_sync_ssl.cpp to just dump the payload it receives and i have used certificates with ssl context. When I run the program with valgrind, the "still reachable" memory keeps increasing with time. This is one example:
Thanks for posting a complete program. I'll compile it up and have a look.
==17719== 38,880 bytes in 60 blocks are still reachable in loss record 740 of 740 ==17719== at 0x4C312EF: malloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so) ==17719== by 0x567F438: CRYPTO_zalloc (in /usr/lib64/libcrypto.so.1.1) ==17719== by 0x52AA5CA: SSL_SESSION_new (in /usr/lib64/libssl.so.1.1) ==17719== by 0x52AAE22: ??? (in /usr/lib64/libssl.so.1.1) ==17719== by 0x52C8A06: ??? (in /usr/lib64/libssl.so.1.1) ==17719== by 0x52B7FF6: ??? (in /usr/lib64/libssl.so.1.1) ==17719== by 0x52A3F43: SSL_do_handshake (in /usr/lib64/libssl.so.1.1) ==17719== by 0x419630: boost::asio::ssl::detail::engine::do_accept(void*, unsigned long) (engine.ipp:316) ==17719== by 0x4193E3: boost::asio::ssl::detail::engine::perform(int (boost::asio::ssl::detail::engine::*)(void*, unsigned long), void*, unsigned long, boost::system::error_code&, unsigned long*) (engine.ipp:248) ==17719== by 0x418F6D: boost::asio::ssl::detail::engine::handshake(boost::asio::ssl::stream_base::handshake_type, boost::system::error_code&) (engine.ipp:148) ==17719== by 0x419778: boost::asio::ssl::detail::handshake_op::operator()(boost::asio::ssl::detail::engine&, boost::system::error_code&, unsigned long&) const (handshake_op.hpp:47) ==17719== by 0x424DB8: unsigned long boost::asio::ssl::detail::io<boost::asio::basic_stream_socket<boost::asio::ip::tcp, boost::asio::any_io_executor>, boost::asio::ssl::detail::handshake_op>(boost::asio::basic_stream_socket<boost::asio::ip::tcp, boost::asio::any_io_executor>&, boost::asio::ssl::detail::stream_core&, boost::asio::ssl::detail::handshake_op const&, boost::system::error_code&) (io.hpp:38) ==17719== by 0x421332: boost::asio::ssl::stream<boost::asio::basic_stream_socket<boost::asio::ip::tcp, boost::asio::any_io_executor>&>::handshake(boost::asio::ssl::stream_base::handshake_type, boost::system::error_code&) (stream.hpp:389) ==17719== by 0x41D5FC: boost::beast::ssl_stream<boost::asio::basic_stream_socket<boost::asio::ip::tcp, boost::asio::any_io_executor>&>::handshake(boost::asio::ssl::stream_base::handshake_type, boost::system::error_code&) (ssl_stream.hpp:344) ==17719== by 0x406971: do_session(boost::asio::basic_stream_socket<boost::asio::ip::tcp, boost::asio::any_io_executor>&, boost::asio::ssl::context&, std::shared_ptr<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const> const&) (boost_server.cpp:219)
I have attached the test program. Can anyone point out what needs to be done here?
Thanks & Regards, Sandeep
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org https://lists.boost.org/mailman/listinfo.cgi/boost-users
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org https://lists.boost.org/mailman/listinfo.cgi/boost-users
On Thu, Feb 3, 2022 at 9:41 AM Sandeep Bhardwaj via Boost-users <boost-users@lists.boost.org> wrote:
http_server_sync_ssl.cpp
Oh, right. Synchronous APIs have no way to time out. So if the remote host does not close gracefully (i.e. just slams the connection shut) then you will be left with a connection object which either has no way to be destroyed, or has to wait what could be a very long time (up to 2 hours) for the operating system to time out the synchronous read. Please try the asynchronous example, http_server_async_ssl.cpp and determine if the problem persists. Thanks
participants (3)
-
Richard Hodges
-
Sandeep Bhardwaj
-
Vinnie Falco