libtorrent和tcp ::受体在Windows上崩溃并违反访问



libtorrent版本(或分支):主/libtorrent-1_1_5

平台/体系结构:win32

编译器和编译器版本:MSVC-14.0

提升版本:BOOST-1.65.1

下面的代码始终导致崩溃。

#include "libtorrent/session.hpp"
#include <chrono>
#include <thread>
using namespace std;
int main()
{
    libtorrent::session session;
    boost::asio::io_service io_service;
        boost::asio::ip::tcp::acceptor acceptor(io_service);
    std::this_thread::sleep_for(chrono::seconds(15));
    return 0;
}

呼叫堆栈:

>   test-crow-libtorrent.exe!boost::asio::detail::win_iocp_socket_service_base::do_open(struct boost::asio::detail::win_iocp_socket_service_base::base_implementation_type &,int,int,int,class boost::system::error_code &) C++
    test-crow-libtorrent.exe!libtorrent::aux::session_impl::setup_listener(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,class boost::asio::ip::tcp const &,int,int,class boost::system::error_code &)    C++
    test-crow-libtorrent.exe!libtorrent::aux::session_impl::open_listen_port(void)  C++
    test-crow-libtorrent.exe!libtorrent::aux::session_impl::init(class boost::shared_ptr<struct libtorrent::settings_pack>) C++
    test-crow-libtorrent.exe!boost::_mfi::mf1<void,struct libtorrent::aux::session_impl,class boost::shared_ptr<struct libtorrent::settings_pack> >::operator()(struct libtorrent::aux::session_impl *,class boost::shared_ptr<struct libtorrent::settings_pack>)   C++
    test-crow-libtorrent.exe!boost::asio::asio_handler_invoke<class boost::_bi::bind_t<void,class boost::_mfi::mf1<void,struct libtorrent::aux::session_impl,class boost::shared_ptr<struct libtorrent::settings_pack> >,class boost::_bi::list2<class boost::_bi::value<struct libtorrent::aux::session_impl *>,class boost::_bi::value<class boost::shared_ptr<struct libtorrent::settings_pack> > > > >(class boost::_bi::bind_t<void,class boost::_mfi::mf1<void,struct libtorrent::aux::session_impl,class boost::shared_ptr<struct libtorrent::settings_pack> >,class boost::_bi::list2<class boost::_bi::value<struct libtorrent::aux::session_impl *>,class boost::_bi::value<class boost::shared_ptr<struct libtorrent::settings_pack> > > > &,...)    C++
    test-crow-libtorrent.exe!boost::asio::detail::completion_handler<class boost::_bi::bind_t<void,class boost::_mfi::mf1<void,struct libtorrent::aux::session_impl,class boost::shared_ptr<struct libtorrent::settings_pack> >,class boost::_bi::list2<class boost::_bi::value<struct libtorrent::aux::session_impl *>,class boost::_bi::value<class boost::shared_ptr<struct libtorrent::settings_pack> > > > >::do_complete(class boost::asio::detail::win_iocp_io_service *,class boost::asio::detail::win_iocp_operation *,class boost::system::error_code const &,unsigned int)   C++
    test-crow-libtorrent.exe!boost::asio::detail::win_iocp_io_service::do_one(bool,class boost::system::error_code &)   C++
    test-crow-libtorrent.exe!boost::asio::detail::win_iocp_io_service::run(class boost::system::error_code &)   C++
    test-crow-libtorrent.exe!boost::asio::io_service::run(void) C++
    test-crow-libtorrent.exe!thread_start<unsigned int (__stdcall*)(void *)>(void * const parameter) Line 115   C++
    kernel32.dll!@BaseThreadInitThunk@12�() Unknown
    ntdll.dll!__RtlUserThreadStart()    Unknown
    ntdll.dll!__RtlUserThreadStart@8�() Unknown

libtorrent编译选项:

toolset=msvc-14.0 boost-link=static dht=on encryption=on mutable-torrents=on crypto=openssl openssl-version=1.1 link=static runtime-link=static variant=debug,release i2p=on

崩溃仅发生在释放构建上。

谁能帮我吗?

这很可能是由构建libtorrent和带有链接兼容选项的测试应用程序引起的。如果libtorrent在静态上与运行时链接,则您有责任确保与之链接的任何内容也可以。

另外,您可以使用适当的构建工具来执行链接兼容(例如Boost-Build)。

问题是在预处理器中。当您使用Boost-Build以外的工具构建应用程序(使用LibTorrent)时,需要添加BOOST_ASIO_ENABLE_CANCELIO

在这里您可以找到有关此问题的更多信息。

最新更新