libgo icon indicating copy to clipboard operation
libgo copied to clipboard

win下 socket连接失败会崩溃

Open xiaolanpingguo opened this issue 6 years ago • 1 comments

libgo分支:master 系统:win10, 编译器:VS2017, boost版本:1.67

代码如下: #include <boost/asio.hpp> using namespace boost::asio; using namespace boost::asio::ip; using boost::system::error_code; int main() { io_context ioc;

go[&]()
{
	tcp::socket sock(ioc);

	error_code ec;
	tcp::endpoint addr(address_t::from_string("127.0.0.1"), 26001);
	sock.connect(addr, ec);
	if (ec)
	{
		cout << 11 << endl;
	}
};

co_sched.Start();
std::getchar();
return 0;

}

调用堆栈: sample5_asio.t.exe!std::_List_const_iterator<std::_List_val<std::_List_simple_types<std::pair<unsigned __int64 const ,std::list<co::Reactor::Entry,std::allocatorco::Reactor::Entry > > > > >::operator*() 行 186 C++ sample5_asio.t.exe!std::_List_iterator<std::_List_val<std::_List_simple_types<std::pair<unsigned __int64 const ,std::list<co::Reactor::Entry,std::allocatorco::Reactor::Entry > > > > >::operator*() 行 297 C++ sample5_asio.t.exe!std::_List_iterator<std::_List_val<std::_List_simple_types<std::pair<unsigned __int64 const ,std::list<co::Reactor::Entry,std::allocatorco::Reactor::Entry > > > > >::operator->() 行 301 C++ sample5_asio.t.exe!co::Reactor::Selector::Perform(fd_set & set, short pollEvent, std::unordered_map<unsigned __int64,std::list<co::Reactor::Entry,std::allocatorco::Reactor::Entry >,std::hash,std::equal_to,std::allocator<std::pair<unsigned __int64 const ,std::list<co::Reactor::Entry,std::allocatorco::Reactor::Entry > > > > & sockets, std::set<co::Processer::SuspendEntry,std::lessco::Processer::SuspendEntry,std::allocatorco::Processer::SuspendEntry > & suspendEntries) 行 135 C++ sample5_asio.t.exe!co::Reactor::Selector::ThreadRun() 行 85 C++

sample5_asio.t.exe!co::Reactor::Selector::{ctor}::__l2::() 行 38 C++ [外部代码] sample5_asio.t.exe!invoke_thread_procedure(unsigned int(*)(void ) procedure, void * const context) 行 92 C++ sample5_asio.t.exe!thread_start<unsigned int (__cdecl)(void * __ptr64)>(void * const parameter) 行 115 C++ [外部代码]

崩溃的文件:libgo\netio\windows\reactor.cpp, 所在函数:Reactor::Selector::Perform, 崩溃原因:在libgo\netio\windows\reactor.cpp 第135行, if (&sockets == &excepters_) { readers_.erase(it->first); writers_.erase(it->first); } readers_为空,但是进行了erase,导致迭代器错误

xiaolanpingguo avatar Feb 14 '19 10:02 xiaolanpingguo

已修复,bug原因:迭代器删除后还在使用

yyzybb537 avatar Feb 19 '19 04:02 yyzybb537