2

如果我在没有实际使用 boost::asio 的情况下将 boost ASIO 包含在头文件中,那么在我调用的任何时候Aws::GameLift::Server::InitSDK(),应用程序都会从​​不同的线程崩溃。这样的事情怎么可能?

Exception thrown at 0x00007FFC4ADEA6AB (ntdll.dll) in MyApp.exe: 0xC0000005: Access violation writing location 0x0000000100000023.

ntdll.dll!RtlpWaitOnCriticalSection()   Unknown
ntdll.dll!RtlpEnterCriticalSectionContended()   Unknown
ntdll.dll!RtlEnterCriticalSection() Unknown
MyApp.exe!boost::asio::detail::win_iocp_io_service::do_add_timer_queue(class boost::asio::detail::timer_queue_base &)   C++
MyApp.exe!boost::asio::waitable_timer_service<struct std::chrono::steady_clock,struct boost::asio::wait_traits<struct std::chrono::steady_clock> >::waitable_timer_service<struct std::chrono::steady_clock,struct boost::asio::wait_traits<struct std::chrono::steady_clock> >(class boost::asio::io_service &)    C++
MyApp.exe!boost::asio::detail::service_registry::create<class boost::asio::waitable_timer_service<struct std::chrono::steady_clock,struct boost::asio::wait_traits<struct std::chrono::steady_clock> > >(class boost::asio::io_service &)   C++
MyApp.exe!boost::asio::detail::service_registry::do_use_service(const boost::asio::io_service::service::key & key, boost::asio::io_service::service *(*)(boost::asio::io_service &) factory) Line 124   C++
MyApp.exe!boost::asio::detail::win_iocp_io_service::do_one(bool block, boost::system::error_code & ec) Line 397 C++
MyApp.exe!boost::asio::detail::win_iocp_io_service::run(boost::system::error_code & ec) Line 159    C++ 

这是我的包含 - 只要在任何头文件的顶部添加它都会在 InitSDK 调用后触发异常。

#define BOOST_ASIO_HAS_MOVE
#define CreateEvent CreateEventA
#include <boost/asio.hpp>
#undef CreateEvent

我在用着:

  • Visual Studio 2015 工具集 v140

  • 提升 1.52.0

  • Windows 8.1 SDK(运行 Windows 10)

我看过这个问题:boost::asio::io_service crash in win_mutex lock

当我添加#define BOOST_ASIO_DISABLE_IOCP时,异常发生变化并且调用堆栈在主线程上。这使我相信它与套接字服务的不同实现有关,具体取决于使用的定义。

MyApp.exe!boost::asio::detail::win_iocp_socket_service_base::construct(struct boost::asio::detail::win_iocp_socket_service_base::base_implementation_type &)    C++
MyApp.exe!boost::asio::basic_io_object<class boost::asio::socket_acceptor_service<class boost::asio::ip::tcp>,1>::basic_io_object<class boost::asio::socket_acceptor_service<class boost::asio::ip::tcp>,1>(class boost::asio::io_service &)    C++
MyApp.exe!std::make_shared<class boost::asio::basic_socket_acceptor<class boost::asio::ip::tcp,class boost::asio::socket_acceptor_service<class boost::asio::ip::tcp> >,class boost::reference_wrapper<class boost::asio::io_service> const >(class boost::reference_wrapper<class boost::asio::io_service> const &&)   C++
MyApp.exe!websocketpp::transport::asio::endpoint<struct websocketpp::config::asio_client::transport_config>::init_asio(class boost::asio::io_service *,class std::error_code &) C++
MyApp.exe!websocketpp::transport::asio::endpoint<struct websocketpp::config::asio_client::transport_config>::init_asio(class boost::asio::io_service *) C++
MyApp.exe!sio::client_impl::client_impl(void)   C++
MyApp.exe!sio::client::client(void) C++
MyApp.exe!Aws::GameLift::Internal::GameLiftServerState::InitializeNetworking(void)  Unknown
MyApp.exe!Aws::GameLift::Server::InitSDK(void)  Unknown
4

1 回答 1

1

看来我拥有的 Gamelift SDK 版本使用的是 Boost 1.61,这与我在主项目中使用的 Boost 1.52 冲突。

我将我对 Boost 的使用升级到 1.61 以匹配他们的使用,然后突然间 - Gamelift 也不例外了。惊喜。

于 2018-12-10T19:15:54.073 回答