gpt4 book ai didi

c++ - libtorrent 和 tcp::acceptor 在 Windows 上因访问冲突而崩溃

转载 作者:行者123 更新时间:2023-11-28 04:53:59 25 4
gpt4 key购买 nike

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)。

关于c++ - libtorrent 和 tcp::acceptor 在 Windows 上因访问冲突而崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47570608/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com