Skip to content

Conversation

@arevetchi
Copy link
Contributor

@arevetchi arevetchi commented Jul 19, 2025

TLS socket can block on a force_disconnectwhen network interface is down, or the other end is not responding, as it calls clean_shutdown_and_close witch tries to shutdown tls socket gracefully.

This is a stack trace from one scenario when network is set down, or simply the cable gets pulled out for testing purposes, when pingreq timer fires it tries to to a clean tls socket shutdown and it block indefinitely.

#0  0x00007f26baafa21f in __GI___poll (fds=0x7f26b99f8180, nfds=1, timeout=-1) at ../sysdeps/unix/sysv/linux/poll.c:29
#1  0x000055b37e217265 in boost::asio::detail::socket_ops::poll_read (s=20, state=0 '\000', msec=-1, ec=...) at external/boost/libs/asio/include/boost/asio/detail/impl/socket_ops.ipp:2249
#2  0x000055b37e218349 in boost::asio::detail::socket_ops::sync_recv1 (s=20, state=18 '\022', data=0x7f26b012d800, size=17408, flags=0, ec=...) at external/boost/libs/asio/include/boost/asio/detail/impl/socket_ops.ipp:902
#3  0x000055b37df910d3 in boost::asio::detail::reactive_socket_service_base::receive<boost::asio::mutable_buffer> (this=0x7f26b0003a68, impl=..., buffers=..., flags=0, ec=...) at external/boost/libs/asio/include/boost/asio/detail/reactive_socket_service_base.hpp:366
#4  0x000055b37df90ff8 in boost::asio::basic_stream_socket<boost::asio::ip::tcp, boost::asio::any_io_executor>::read_some<boost::asio::mutable_buffer> (this=0x7f26b011f868, buffers=..., ec=...) at external/boost/libs/asio/include/boost/asio/basic_stream_socket.hpp:1035
#5  0x000055b37df91892 in boost::asio::ssl::detail::io<boost::asio::basic_stream_socket<boost::asio::ip::tcp, boost::asio::any_io_executor>, boost::asio::ssl::detail::shutdown_op> (next_layer=..., core=..., op=..., ec=...) at external/boost/libs/asio/include/boost/asio/ssl/detail/io.hpp:48
#6  0x000055b37df915d0 in boost::asio::ssl::stream<boost::asio::basic_stream_socket<boost::asio::ip::tcp, boost::asio::any_io_executor> >::shutdown (this=0x7f26b011f868, ec=...) at external/boost/libs/asio/include/boost/asio/ssl/stream.hpp:621
#7  0x000055b37df914dd in mqtt::tcp_endpoint<boost::asio::ssl::stream<boost::asio::basic_stream_socket<boost::asio::ip::tcp, boost::asio::any_io_executor> >, boost::asio::strand<boost::asio::io_context::basic_executor_type<std::allocator<void>, 0ul> > >::shutdown_and_close_impl (this=0x7f26b011f860, s=..., ec=...) at external/mqtt_cpp/include/mqtt/tcp_endpoint.hpp:171
#8  0x000055b37df80ab4 in mqtt::tcp_endpoint<boost::asio::ssl::stream<boost::asio::basic_stream_socket<boost::asio::ip::tcp, boost::asio::any_io_executor> >, boost::asio::strand<boost::asio::io_context::basic_executor_type<std::allocator<void>, 0ul> > >::clean_shutdown_and_close (this=0x7f26b011f860, ec=...) at external/mqtt_cpp/include/mqtt/tcp_endpoint.hpp:102
#9  0x000055b37deb27f1 in mqtt::endpoint<std::mutex, std::lock_guard, 2ul>::sync_shutdown (this=0x7f26b00020c0, s=...) at external/mqtt_cpp/include/mqtt/endpoint.hpp:5319
#10 0x000055b37deb2678 in mqtt::endpoint<std::mutex, std::lock_guard, 2ul>::force_disconnect (this=0x7f26b00020c0) at external/mqtt_cpp/include/mqtt/endpoint.hpp:1103
#11 0x000055b37deb25fd in mqtt::endpoint<std::mutex, std::lock_guard, 2ul>::set_pingresp_timer()::{lambda(boost::system::error_code)#1}::operator()(boost::system::error_code)::{lambda()#1}::operator()() const (this=0x7f26b00ad600) at external/mqtt_cpp/include/mqtt/endpoint.hpp:11552
...

@redboltz
Copy link
Owner

@arevetchi Thank you for sending the PR.
It seems that the first commit is essential. But CI reports some errors.
So I fix the CI issue with your commit as #1000,

@redboltz redboltz closed this Jul 21, 2025
@arevetchi
Copy link
Contributor Author

@redboltz Thank you for prompt response

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.

2 participants