websocketpp icon indicating copy to clipboard operation
websocketpp copied to clipboard

websocktpp crash when conecton joined and receive first message

Open dq5070410 opened this issue 4 years ago • 3 comments

Hi, I meet a crash when use websocketpp as a client at centos7 ,and conncet to server when connection established, the receive first message , websocketpp crash.

core like blew: 0 0x0000000000000000 in ?? () #1 0x00002addf98d85dc in pre_init (callback=..., this=0x15f0920) at /home/admin/coderoom/linux_meeting_sdk/AMRTCMediaSdk/../include/header/websocketpp/transport/asio/security/tls.hpp:244 #2 init (callback=..., this=0x15f0920) at /home/admin/coderoom/linux_meeting_sdk/AMRTCMediaSdk/../include/header/websocketpp/transport/asio/connection.hpp:418 #3 websocketpp::connectionwebsocketpp::config::asio_tls_client::start (this=0x15f0920) at /home/admin/coderoom/linux_meeting_sdk/AMRTCMediaSdk/../include/header/websocketpp/impl/connection_impl.hpp:730 #4 0x00002addf98d87d1 in websocketpp::clientwebsocketpp::config::asio_tls_client::handle_connect (this=0x15eeb48, con=<error reading variable: Cannot access memory at address 0x37>, ec=...) at /home/admin/coderoom/linux_meeting_sdk/AMRTCMediaSdk/../include/header/websocketpp/roles/client_endpoint.hpp:163 #5 0x00002addf98c56b3 in std::_Function_handler<void (std::error_code const&), std::_Bind<std::_Mem_fn<void (websocketpp::clientwebsocketpp::config::asio_tls_client::)(std::shared_ptr<websocketpp::connectionwebsocketpp::config::asio_tls_client >, std::error_code const&)> (websocketpp::clientwebsocketpp::config::asio_tls_client, std::shared_ptr<websocketpp::connectionwebsocketpp::config::asio_tls_client >, std::_Placeholder<1>)> >::_M_invoke(std::_Any_data const&, std::error_code const&) (__functor=..., __args#0=...) at /usr/include/c++/4.8.2/functional:2073 #6 0x00002addf98d1042 in error_code (this=0x2addfd0395c0) at /usr/include/c++/4.8.2/system_error:119 #7 websocketpp::transport::asio::endpointwebsocketpp::config::asio_tls_client::transport_config::handle_connect(std::shared_ptr<websocketpp::transport::asio::connectionwebsocketpp::config::asio_tls_client::transport_config >, std::shared_ptr<asio::basic_waitable_timer<std::chrono::_V2::steady_clock, asio::wait_traitsstd::chrono::_V2::steady_clock > >, std::function<void (std::error_code const&)>, std::error_code const&) (this=0x15eeb48, tcon=..., con_timer=..., callback=..., ec=...) at /home/admin/coderoom/linux_meeting_sdk/AMRTCMediaSdk/../include/header/websocketpp/transport/asio/endpoint.hpp:1103 #8 0x00002addf98d41a7 in std::_Mem_fn<void (websocketpp::transport::asio::endpointwebsocketpp::config::asio_tls_client::transport_config::)(std::shared_ptr<websocketpp::transport::asio::connectionwebsocketpp::config::asio_tls_client::transport_config >, std::shared_ptr<asio::basic_waitable_timer<std::chrono::_V2::steady_clock, asio::wait_traitsstd::chrono::_V2::steady_clock > >, std::function<void (std::error_codeconst&)>, std::error_code const&)>::operator()<std::shared_ptr<websocketpp::transport::asio::connectionwebsocketpp::config::asio_tls_client::transport_config >&, std::shared_ptr<asio::basic_waitable_timer<std::chrono::_V2::steady_clock, asio::wait_traitsstd::chrono::_V2::steady_clock > >&, std::function<void (std::error_code const&)>&, std::error_code const&, void>(websocketpp::transport::asio::endpointwebsocketpp::config::asio_tls_client::transport_config, std::shared_ptr<websocketpp::transport::asio::connectionwebsocketpp::config::asio_tls_client::transport_config >&, std::shared_ptr<asio::basic_waitable_timer<std::chrono::_V2::steady_clock, asio::wait_traitsstd::chrono::_V2::steady_clock > >&, std::function<void (std::error_code const&)>&, std::error_code const&) const (this=0x2addfd039790, __object=0x15eeb48) at /usr/include/c++/4.8.2/functional:601 #9 0x00002addf98d46f6 in __call<void, std::error_code const&, asio::ip::basic_resolver_iteratorasio::ip::tcp const&, 0ul, 1ul, 2ul, 3ul, 4ul> (__args=, this=0x2addfd039790) at /usr/include/c++/4.8.2/functional:1296 #10 operator()<const std::error_code&, const asio::ip::basic_resolver_iteratorasio::ip::tcp&, void> (this=0x2addfd039790) at /usr/include/c++/4.8.2/functional:1355 #11 operator() (this=0x2addfd039790) at /home/admin/coderoom/linux_meeting_sdk/AMRTCMediaSdk/../include/header/asio/detail/bind_handler.hpp:163 #12 asio_handler_invoke<asio::detail::binder2<std::_Bind<std::_Mem_fn<void (websocketpp::transport::asio::endpointwebsocketpp::config::asio_tls_client::transport_config::)(std::shared_ptr<websocketpp::transport::asio::connectionwebsocketpp::config::asio_tls_client::transport_config >, std::shared_ptr<asio::basic_waitable_timerstd::chrono::_V2::steady_clock >, std::function<void(const std::error_code&)>, const std::error_code&)>(websocketpp::transport::asio::endpointwebsocketpp::config::asio_tls_client::transport_config, std::shared_ptr<websocketpp::transport::asio::connectionwebsocketpp::config::asio_tls_client::transport_config >, std::shared_ptr<asio::basic_waitable_timerstd::chrono::_V2::steady_clock >, std::function<void(const std::error_code&)>, std::_Placeholder<1>)>, std::error_code, asio::ip::basic_resolver_iteratorasio::ip::tcp > > (function=...) at /home/admin/coderoom/linux_meeting_sdk/AMRTCMediaSdk/../include/header/asio/handler_invoke_hook.hpp:68 #13 invoke<asio::detail::binder2<std::_Bind<std::_Mem_fn<void (websocketpp::transport::asio::endpointwebsocketpp::config::asio_tls_client::transport_config::)(std::shared_ptr<websocketpp::transport::asio::connectionwebsocketpp::config::asio_tls_client::transport_config >, std::shared_ptr<asio::basic_waitable_timerstd::chrono::_V2::steady_clock >, std::function<void(const std::error_code&)>, const std::error_code&)>(websocketpp::transport::asio::endpointwebsocketpp::config::asio_tls_client::transport_config, std::shared_ptr<websocketpp::transport::asio::connectionwebsocketpp::config::asio_tls_client::transport_config >,std::shared_ptr<asio::basic_waitable_timerstd::chrono::_V2::steady_clock >, std::function<void(const std::error_code&)>, std::_Placeholder<1>)>, std::error_code, asio::ip::basic_resolver_iteratorasio::ip::tcp>, std::_Bind<std::_Mem_fn<void (websocketpp::transport::asio::endpointwebsocketpp::config::asio_tls_client::transport_config::)(std::shared_ptr<websocketpp::transport::asio::connectionwebsocketpp::config::asio_tls_client::transport_config >, std::shared_ptr<asio::basic_waitable_timerstd::chrono::_V2::steady_clock >, std::function<void(const std::error_code&)>, const std::error_code&)>(websocketpp::transport::asio::endpointwebsocketpp::config::asio_tls_client::transport_config, std::shared_ptr<websocketpp::transport::asio::connectionwebsocketpp::config::asio_tls_client::transport_config >, std::shared_ptr<asio::basic_waitable_timerstd::chrono::_V2::steady_clock >, std::function<void(const std::error_code&)>, std::_Placeholder<1>)> > (context=..., function=...) at /home/admin/coderoom/linux_meeting_sdk/AMRTCMediaSdk/../include/header/asio/detail/handler_invoke_helpers.hpp:37

dq5070410 avatar Jul 27 '20 13:07 dq5070410

Can you confirm when the crash happens? You mentioned the connection completes and the issue is on first message, but the stack trace shows the library in the connection initialization phase (well before the websocket handshake) in the code that sets the TLS SNI hostname for OpenSSL. What version of OpenSSL are you using? Is the hostname you are connecting to unusual in any way (like a raw IP address)?

zaphoyd avatar Jul 29 '20 11:07 zaphoyd

yes, it crash in the initialization phas sets the TLS SNI hostname for openssl. when call SSL_set_tlsext_host_name, it crash. openssl 1.0.2k and 1.1.1g are tested and they are crash. I connect to host name not a raw address.

dq5070410 avatar Jul 29 '20 13:07 dq5070410

hi dq5-70410, I also get similar trace,how did you resolve the problem?

YXZhai97 avatar Apr 18 '23 09:04 YXZhai97