Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Assertion when using WebTorrent #5100

Closed
vktr opened this issue Sep 4, 2020 · 15 comments
Closed

Assertion when using WebTorrent #5100

vktr opened this issue Sep 4, 2020 · 15 comments
Labels

Comments

@vktr
Copy link
Contributor

vktr commented Sep 4, 2020

libtorrent version (or branch): master (ea183a1)
platform/architecture: win64
compiler and compiler version: msvc-19

I'm trying to verify WebTorrent support in PicoTorrent and am hitting this assertions here,

TORRENT_ASSERT(i_ == m_connections.end()
	|| (*i_)->type() != connection_type::bittorrent);

This only happens for WebTorrents. When using regular torrents (with WebTorrent support enabled) I don't hit the assertion. I'm using the Sintel torrent from here, https://webtorrent.io/torrents/sintel.torrent)

Here's the call stack (MSVC style so frames are in descending order)

> PicoTorrent.exe!libtorrent::assert_fail(const char * expr, int line, const char * file, const char * function, const char * value, int kind) Line 362	C++
PicoTorrent.exe!libtorrent::aux::torrent::connect_to_peer(libtorrent::aux::torrent_peer * peerinfo, bool ignore_limit) Line 7056	C++
PicoTorrent.exe!libtorrent::aux::torrent::try_connect_peer() Line 10639	C++
PicoTorrent.exe!libtorrent::aux::session_impl::try_connect_more_peers() Line 4223	C++
PicoTorrent.exe!libtorrent::aux::session_impl::on_tick(const boost::system::error_code & e) Line 3524	C++
PicoTorrent.exe!libtorrent::aux::session_impl::wrap<void (__cdecl libtorrent::aux::session_impl::*)(boost::system::error_code const &),boost::system::error_code const &>(void(libtorrent::aux::session_impl::*)(const boost::system::error_code &) f, const boost::system::error_code & <a_0>) Line 530	C++
PicoTorrent.exe!libtorrent::aux::session_impl::on_tick::__l2::<lambda>(const boost::system::error_code & err) Line 3288	C++
PicoTorrent.exe!libtorrent::aux::allocating_handler<void <lambda>(const boost::system::error_code &),144,3>::operator()<boost::system::error_code const &>(const boost::system::error_code & <a_0>) Line 245	C++
PicoTorrent.exe!boost::asio::detail::binder1<libtorrent::aux::allocating_handler<void <lambda>(const boost::system::error_code &),144,3>,boost::system::error_code>::operator()() Line 66	C++
PicoTorrent.exe!boost::asio::asio_handler_invoke<boost::asio::detail::binder1<libtorrent::aux::allocating_handler<void <lambda>(const boost::system::error_code &),144,3>,boost::system::error_code>>(boost::asio::detail::binder1<libtorrent::aux::allocating_handler<void <lambda>(const boost::system::error_code &),144,3>,boost::system::error_code> & function, ...) Line 70	C++
PicoTorrent.exe!boost_asio_handler_invoke_helpers::invoke<boost::asio::detail::binder1<libtorrent::aux::allocating_handler<void <lambda>(const boost::system::error_code &),144,3>,boost::system::error_code>,libtorrent::aux::allocating_handler<void <lambda>(const boost::system::error_code &),144,3>>(boost::asio::detail::binder1<libtorrent::aux::allocating_handler<void <lambda>(const boost::system::error_code &),144,3>,boost::system::error_code> & function, libtorrent::aux::allocating_handler<void <lambda>(const boost::system::error_code &),144,3> & context) Line 39	C++
PicoTorrent.exe!boost::asio::detail::asio_handler_invoke<boost::asio::detail::binder1<libtorrent::aux::allocating_handler<void <lambda>(const boost::system::error_code &),144,3>,boost::system::error_code>,libtorrent::aux::allocating_handler<void <lambda>(const boost::system::error_code &),144,3>,boost::system::error_code>(boost::asio::detail::binder1<libtorrent::aux::allocating_handler<void <lambda>(const boost::system::error_code &),144,3>,boost::system::error_code> & function, boost::asio::detail::binder1<libtorrent::aux::allocating_handler<void <lambda>(const boost::system::error_code &),144,3>,boost::system::error_code> * this_handler) Line 108	C++
PicoTorrent.exe!boost_asio_handler_invoke_helpers::invoke<boost::asio::detail::binder1<libtorrent::aux::allocating_handler<void <lambda>(const boost::system::error_code &),144,3>,boost::system::error_code>,boost::asio::detail::binder1<libtorrent::aux::allocating_handler<void <lambda>(const boost::system::error_code &),144,3>,boost::system::error_code>>(boost::asio::detail::binder1<libtorrent::aux::allocating_handler<void <lambda>(const boost::system::error_code &),144,3>,boost::system::error_code> & function, boost::asio::detail::binder1<libtorrent::aux::allocating_handler<void <lambda>(const boost::system::error_code &),144,3>,boost::system::error_code> & context) Line 39	C++
PicoTorrent.exe!boost::asio::detail::io_object_executor<boost::asio::executor>::dispatch<boost::asio::detail::binder1<libtorrent::aux::allocating_handler<void <lambda>(const boost::system::error_code &),144,3>,boost::system::error_code>,libtorrent::aux::handler_allocator<libtorrent::aux::allocating_handler<void <lambda>(const boost::system::error_code &),144,3>,144,3>>(boost::asio::detail::binder1<libtorrent::aux::allocating_handler<void <lambda>(const boost::system::error_code &),144,3>,boost::system::error_code> && f, const libtorrent::aux::handler_allocator<libtorrent::aux::allocating_handler<void <lambda>(const boost::system::error_code &),144,3>,144,3> & a) Line 120	C++
PicoTorrent.exe!boost::asio::detail::handler_work<libtorrent::aux::allocating_handler<void <lambda>(const boost::system::error_code &),144,3>,boost::asio::detail::io_object_executor<boost::asio::executor>,boost::asio::detail::io_object_executor<boost::asio::executor>>::complete<boost::asio::detail::binder1<libtorrent::aux::allocating_handler<void <lambda>(const boost::system::error_code &),144,3>,boost::system::error_code>>(boost::asio::detail::binder1<libtorrent::aux::allocating_handler<void <lambda>(const boost::system::error_code &),144,3>,boost::system::error_code> & function, libtorrent::aux::allocating_handler<void <lambda>(const boost::system::error_code &),144,3> & handler) Line 74	C++
PicoTorrent.exe!boost::asio::detail::wait_handler<libtorrent::aux::allocating_handler<void <lambda>(const boost::system::error_code &),144,3>,boost::asio::detail::io_object_executor<boost::asio::executor>>::do_complete(void * owner, boost::asio::detail::win_iocp_operation * base, const boost::system::error_code & __formal, unsigned __int64 __formal) Line 73	C++
PicoTorrent.exe!boost::asio::detail::win_iocp_operation::complete(void * owner, const boost::system::error_code & ec, unsigned __int64 bytes_transferred) Line 48	C++
PicoTorrent.exe!boost::asio::detail::win_iocp_io_context::do_one(unsigned long msec, boost::system::error_code & ec) Line 461	C++
PicoTorrent.exe!boost::asio::detail::win_iocp_io_context::run(boost::system::error_code & ec) Line 203	C++
PicoTorrent.exe!boost::asio::io_context::run() Line 63	C++
PicoTorrent.exe!libtorrent::session::start::__l21::<lambda>() Line 294	C++

Let me know if you need more information or if I should try something else!

@paullouisageneau
Copy link
Contributor

paullouisageneau commented Sep 25, 2020

The assertion ensures that there is no duplicate addresses in the connections list. It should be bypassed for WebRTC peers, but it doesn't work somehow. I'm having a look.

In the meantime, a temporary fix could be set allow_multiple_connections_per_ip=true in the settings.

@paullouisageneau
Copy link
Contributor

The peer list sorting was broken when using webRTC peers, resulting in potential duplicate peers triggering the assertion.

Thanks for reporting, it should be fixed by #5184

@paullouisageneau
Copy link
Contributor

@vktr Can this issue be closed?

@vktr
Copy link
Contributor Author

vktr commented Oct 2, 2020

@paullouisageneau I'm hitting this assert,

image

with this call stack

>	KernelBase.dll!wil::details::DebugBreak(void)	Unknown	Non-user code. Symbols loaded.
 	PicoTorrent.exe!libtorrent::assert_fail(const char * expr, int line, const char * file, const char * function, const char * value, int kind) Line 362	C++	Symbols loaded.
 	PicoTorrent.exe!libtorrent::piece_picker::mark_as_downloading(libtorrent::piece_block block, libtorrent::aux::torrent_peer * peer, libtorrent::flags::bitfield_flag<unsigned short,libtorrent::picker_options_tag,void> options) Line 3244	C++	Symbols loaded.
 	PicoTorrent.exe!libtorrent::peer_connection::add_request(const libtorrent::piece_block & block, libtorrent::flags::bitfield_flag<unsigned char,libtorrent::request_flags_tag,void> flags) Line 3587	C++	Symbols loaded.
 	PicoTorrent.exe!libtorrent::request_a_block(libtorrent::aux::torrent & t, libtorrent::peer_connection & c) Line 298	C++	Symbols loaded.
 	PicoTorrent.exe!libtorrent::peer_connection::incoming_piece(const libtorrent::peer_request & p, const char * data) Line 3059	C++	Symbols loaded.
 	PicoTorrent.exe!libtorrent::aux::bt_peer_connection::on_piece(int received) Line 1103	C++	Symbols loaded.
 	PicoTorrent.exe!libtorrent::aux::bt_peer_connection::dispatch_message(int received) Line 2102	C++	Symbols loaded.
 	PicoTorrent.exe!libtorrent::aux::bt_peer_connection::on_receive_impl(unsigned __int64 bytes_transferred) Line 3657	C++	Symbols loaded.
 	PicoTorrent.exe!libtorrent::aux::bt_peer_connection::on_receive(const boost::system::error_code & error, unsigned __int64 bytes_transferred) Line 2702	C++	Symbols loaded.
 	PicoTorrent.exe!libtorrent::peer_connection::on_receive_data(const boost::system::error_code & error, unsigned __int64 bytes_transferred) Line 6120	C++	Symbols loaded.
 	PicoTorrent.exe!libtorrent::aux::handler<libtorrent::peer_connection,void (__cdecl libtorrent::peer_connection::*)(boost::system::error_code const &,unsigned __int64),{libtorrent::peer_connection::on_receive_data,0},{libtorrent::peer_connection::on_error,0},{libtorrent::peer_connection::on_exception,0},libtorrent::aux::handler_storage<576,1>,1040>::operator()<boost::system::error_code const &,unsigned __int64>(const boost::system::error_code & <a_0>, unsigned __int64 && <a_1>) Line 311	C++	Symbols loaded.
 	PicoTorrent.exe!std::invoke<libtorrent::aux::handler<libtorrent::peer_connection,void (__cdecl libtorrent::peer_connection::*)(boost::system::error_code const &,unsigned __int64),{libtorrent::peer_connection::on_receive_data,0},{libtorrent::peer_connection::on_error,0},{libtorrent::peer_connection::on_exception,0},libtorrent::aux::handler_storage<576,1>,1040> &,boost::system::error_code const &,unsigned __int64>(libtorrent::aux::handler<libtorrent::peer_connection,void (__cdecl libtorrent::peer_connection::*)(boost::system::error_code const &,unsigned __int64),{libtorrent::peer_connection::on_receive_data,0},{libtorrent::peer_connection::on_error,0},{libtorrent::peer_connection::on_exception,0},libtorrent::aux::handler_storage<576,1>,1040> & _Obj, const boost::system::error_code & _Arg1, unsigned __int64 && <_Args2_0>) Line 1626	C++	Non-user code. Symbols loaded.
 	PicoTorrent.exe!std::_Invoker_ret<void,1>::_Call<libtorrent::aux::handler<libtorrent::peer_connection,void (__cdecl libtorrent::peer_connection::*)(boost::system::error_code const &,unsigned __int64),{libtorrent::peer_connection::on_receive_data,0},{libtorrent::peer_connection::on_error,0},{libtorrent::peer_connection::on_exception,0},libtorrent::aux::handler_storage<576,1>,1040> &,boost::system::error_code const &,unsigned __int64>(libtorrent::aux::handler<libtorrent::peer_connection,void (__cdecl libtorrent::peer_connection::*)(boost::system::error_code const &,unsigned __int64),{libtorrent::peer_connection::on_receive_data,0},{libtorrent::peer_connection::on_error,0},{libtorrent::peer_connection::on_exception,0},libtorrent::aux::handler_storage<576,1>,1040> & <_Vals_0>, const boost::system::error_code & <_Vals_1>, unsigned __int64 && <_Vals_2>) Line 1641	C++	Non-user code. Symbols loaded.
 	PicoTorrent.exe!std::_Func_impl_no_alloc<libtorrent::aux::handler<libtorrent::peer_connection,void (__cdecl libtorrent::peer_connection::*)(boost::system::error_code const &,unsigned __int64),{libtorrent::peer_connection::on_receive_data,0},{libtorrent::peer_connection::on_error,0},{libtorrent::peer_connection::on_exception,0},libtorrent::aux::handler_storage<576,1>,1040>,void,boost::system::error_code const &,unsigned __int64>::_Do_call(const boost::system::error_code & <_Args_0>, unsigned __int64 && <_Args_1>) Line 904	C++	Non-user code. Symbols loaded.
 	PicoTorrent.exe!std::_Func_class<void,boost::system::error_code const &,unsigned __int64>::operator()(const boost::system::error_code & <_Args_0>, unsigned __int64 <_Args_1>) Line 952	C++	Non-user code. Symbols loaded.
 	PicoTorrent.exe!std::invoke<std::function<void __cdecl(boost::system::error_code const &,unsigned __int64)> &,boost::system::error_code &,unsigned __int64 &>(std::function<void __cdecl(boost::system::error_code const &,unsigned __int64)> & _Obj, boost::system::error_code & _Arg1, unsigned __int64 & <_Args2_0>) Line 1626	C++	Non-user code. Symbols loaded.
 	PicoTorrent.exe!std::_Invoker_ret<std::_Unforced,0>::_Call<std::function<void __cdecl(boost::system::error_code const &,unsigned __int64)> &,boost::system::error_code &,unsigned __int64 &>(std::function<void __cdecl(boost::system::error_code const &,unsigned __int64)> & <_Vals_0>, boost::system::error_code & <_Vals_1>, unsigned __int64 & <_Vals_2>) Line 1658	C++	Non-user code. Symbols loaded.
 	PicoTorrent.exe!std::_Call_binder<std::_Unforced,0,1,std::function<void __cdecl(boost::system::error_code const &,unsigned __int64)>,std::tuple<boost::system::error_code,unsigned __int64>,std::tuple<>>(std::_Invoker_ret<std::_Unforced,0> __formal, std::integer_sequence<unsigned __int64,0,1> __formal, std::function<void __cdecl(boost::system::error_code const &,unsigned __int64)> & _Obj, std::tuple<boost::system::error_code,unsigned __int64> & _Tpl, std::tuple<> && _Ut) Line 1388	C++	Non-user code. Symbols loaded.
 	PicoTorrent.exe!std::_Binder<std::_Unforced,std::function<void __cdecl(boost::system::error_code const &,unsigned __int64)>,boost::system::error_code &,unsigned __int64 &>::operator()<>() Line 1427	C++	Non-user code. Symbols loaded.
 	PicoTorrent.exe!boost::asio::asio_handler_invoke<std::_Binder<std::_Unforced,std::function<void __cdecl(boost::system::error_code const &,unsigned __int64)>,boost::system::error_code &,unsigned __int64 &>>(std::_Binder<std::_Unforced,std::function<void __cdecl(boost::system::error_code const &,unsigned __int64)>,boost::system::error_code &,unsigned __int64 &> & function, ...) Line 70	C++	Symbols loaded.
 	PicoTorrent.exe!boost_asio_handler_invoke_helpers::invoke<std::_Binder<std::_Unforced,std::function<void __cdecl(boost::system::error_code const &,unsigned __int64)>,boost::system::error_code &,unsigned __int64 &>,std::_Binder<std::_Unforced,std::function<void __cdecl(boost::system::error_code const &,unsigned __int64)>,boost::system::error_code &,unsigned __int64 &>>(std::_Binder<std::_Unforced,std::function<void __cdecl(boost::system::error_code const &,unsigned __int64)>,boost::system::error_code &,unsigned __int64 &> & function, std::_Binder<std::_Unforced,std::function<void __cdecl(boost::system::error_code const &,unsigned __int64)>,boost::system::error_code &,unsigned __int64 &> & context) Line 39	C++	Symbols loaded.
 	PicoTorrent.exe!boost::asio::system_executor::dispatch<std::_Binder<std::_Unforced,std::function<void __cdecl(boost::system::error_code const &,unsigned __int64)>,boost::system::error_code &,unsigned __int64 &>,std::allocator<void>>(std::_Binder<std::_Unforced,std::function<void __cdecl(boost::system::error_code const &,unsigned __int64)>,boost::system::error_code &,unsigned __int64 &> && f, const std::allocator<void> & __formal) Line 39	C++	Symbols loaded.
 	PicoTorrent.exe!boost::asio::detail::work_dispatcher<std::_Binder<std::_Unforced,std::function<void __cdecl(boost::system::error_code const &,unsigned __int64)>,boost::system::error_code &,unsigned __int64 &>>::operator()() Line 61	C++	Symbols loaded.
 	PicoTorrent.exe!boost::asio::asio_handler_invoke<boost::asio::detail::work_dispatcher<std::_Binder<std::_Unforced,std::function<void __cdecl(boost::system::error_code const &,unsigned __int64)>,boost::system::error_code &,unsigned __int64 &>>>(boost::asio::detail::work_dispatcher<std::_Binder<std::_Unforced,std::function<void __cdecl(boost::system::error_code const &,unsigned __int64)>,boost::system::error_code &,unsigned __int64 &>> & function, ...) Line 70	C++	Symbols loaded.
 	PicoTorrent.exe!boost_asio_handler_invoke_helpers::invoke<boost::asio::detail::work_dispatcher<std::_Binder<std::_Unforced,std::function<void __cdecl(boost::system::error_code const &,unsigned __int64)>,boost::system::error_code &,unsigned __int64 &>>,boost::asio::detail::work_dispatcher<std::_Binder<std::_Unforced,std::function<void __cdecl(boost::system::error_code const &,unsigned __int64)>,boost::system::error_code &,unsigned __int64 &>>>(boost::asio::detail::work_dispatcher<std::_Binder<std::_Unforced,std::function<void __cdecl(boost::system::error_code const &,unsigned __int64)>,boost::system::error_code &,unsigned __int64 &>> & function, boost::asio::detail::work_dispatcher<std::_Binder<std::_Unforced,std::function<void __cdecl(boost::system::error_code const &,unsigned __int64)>,boost::system::error_code &,unsigned __int64 &>> & context) Line 39	C++	Symbols loaded.
 	PicoTorrent.exe!boost::asio::detail::executor_op<boost::asio::detail::work_dispatcher<std::_Binder<std::_Unforced,std::function<void __cdecl(boost::system::error_code const &,unsigned __int64)>,boost::system::error_code &,unsigned __int64 &>>,std::allocator<void>,boost::asio::detail::win_iocp_operation>::do_complete(void * owner, boost::asio::detail::win_iocp_operation * base, const boost::system::error_code & __formal, unsigned __int64 __formal) Line 70	C++	Symbols loaded.
 	PicoTorrent.exe!boost::asio::detail::win_iocp_operation::complete(void * owner, const boost::system::error_code & ec, unsigned __int64 bytes_transferred) Line 48	C++	Symbols loaded.
 	PicoTorrent.exe!boost::asio::detail::win_iocp_io_context::do_one(unsigned long msec, boost::system::error_code & ec) Line 461	C++	Symbols loaded.
 	PicoTorrent.exe!boost::asio::detail::win_iocp_io_context::run(boost::system::error_code & ec) Line 203	C++	Symbols loaded.
 	PicoTorrent.exe!boost::asio::io_context::run() Line 63	C++	Symbols loaded.
 	PicoTorrent.exe!libtorrent::session::start::__l21::<lambda>() Line 294	C++	Symbols loaded.
 	PicoTorrent.exe!std::invoke<void <lambda>(void)>(libtorrent::session::start::__l21::void <lambda>(void) && _Obj) Line 1597	C++	Non-user code. Symbols loaded.
 	PicoTorrent.exe!std::thread::_Invoke<std::tuple<void <lambda>(void)>,0>(void * _RawVals) Line 44	C++	Non-user code. Symbols loaded.
 	ucrtbased.dll!thread_start<unsigned int (__cdecl*)(void *),1>(void * const parameter) Line 97	C++	Non-user code. Symbols loaded.
 	kernel32.dll!BaseThreadInitThunk�()	Unknown	Non-user code. Symbols loaded.
 	ntdll.dll!00007ff97305cec1()	Unknown	Non-user code. Cannot find or open the PDB file.

Might not be related - I'm not qualified to say :) I'm not hitting the assertion in this issue anyway so if you want to close this, do it, and I can open a new one with this new assertion.

Thanks for the effort put in! 😃

@paullouisageneau
Copy link
Contributor

OK thank you for reporting, I'll have a look over the weekend to see if it is linked.

@vktr
Copy link
Contributor Author

vktr commented Oct 2, 2020

I'm also hitting this one,

TORRENT_ASSERT(m_recv_buffer.packet_size() == dh_key_len);

With this call stack,

 	KernelBase.dll!wil::details::DebugBreak(void)	Unknown	Non-user code. Symbols loaded.
 	PicoTorrent.exe!libtorrent::assert_fail(const char * expr, int line, const char * file, const char * function, const char * value, int kind) Line 362	C++	Symbols loaded.
>	PicoTorrent.exe!libtorrent::aux::bt_peer_connection::on_receive_impl(unsigned __int64 bytes_transferred) Line 2721	C++	Symbols loaded.
 	PicoTorrent.exe!libtorrent::aux::bt_peer_connection::on_receive(const boost::system::error_code & error, unsigned __int64 bytes_transferred) Line 2702	C++	Symbols loaded.
 	PicoTorrent.exe!libtorrent::peer_connection::on_receive_data(const boost::system::error_code & error, unsigned __int64 bytes_transferred) Line 6120	C++	Symbols loaded.
 	PicoTorrent.exe!libtorrent::aux::handler<libtorrent::peer_connection,void (__cdecl libtorrent::peer_connection::*)(boost::system::error_code const &,unsigned __int64),{libtorrent::peer_connection::on_receive_data,0},{libtorrent::peer_connection::on_error,0},{libtorrent::peer_connection::on_exception,0},libtorrent::aux::handler_storage<576,1>,1040>::operator()<boost::system::error_code const &,unsigned __int64>(const boost::system::error_code & <a_0>, unsigned __int64 && <a_1>) Line 311	C++	Symbols loaded.
 	PicoTorrent.exe!std::invoke<libtorrent::aux::handler<libtorrent::peer_connection,void (__cdecl libtorrent::peer_connection::*)(boost::system::error_code const &,unsigned __int64),{libtorrent::peer_connection::on_receive_data,0},{libtorrent::peer_connection::on_error,0},{libtorrent::peer_connection::on_exception,0},libtorrent::aux::handler_storage<576,1>,1040> &,boost::system::error_code const &,unsigned __int64>(libtorrent::aux::handler<libtorrent::peer_connection,void (__cdecl libtorrent::peer_connection::*)(boost::system::error_code const &,unsigned __int64),{libtorrent::peer_connection::on_receive_data,0},{libtorrent::peer_connection::on_error,0},{libtorrent::peer_connection::on_exception,0},libtorrent::aux::handler_storage<576,1>,1040> & _Obj, const boost::system::error_code & _Arg1, unsigned __int64 && <_Args2_0>) Line 1626	C++	Non-user code. Symbols loaded.
 	PicoTorrent.exe!std::_Invoker_ret<void,1>::_Call<libtorrent::aux::handler<libtorrent::peer_connection,void (__cdecl libtorrent::peer_connection::*)(boost::system::error_code const &,unsigned __int64),{libtorrent::peer_connection::on_receive_data,0},{libtorrent::peer_connection::on_error,0},{libtorrent::peer_connection::on_exception,0},libtorrent::aux::handler_storage<576,1>,1040> &,boost::system::error_code const &,unsigned __int64>(libtorrent::aux::handler<libtorrent::peer_connection,void (__cdecl libtorrent::peer_connection::*)(boost::system::error_code const &,unsigned __int64),{libtorrent::peer_connection::on_receive_data,0},{libtorrent::peer_connection::on_error,0},{libtorrent::peer_connection::on_exception,0},libtorrent::aux::handler_storage<576,1>,1040> & <_Vals_0>, const boost::system::error_code & <_Vals_1>, unsigned __int64 && <_Vals_2>) Line 1641	C++	Non-user code. Symbols loaded.
 	PicoTorrent.exe!std::_Func_impl_no_alloc<libtorrent::aux::handler<libtorrent::peer_connection,void (__cdecl libtorrent::peer_connection::*)(boost::system::error_code const &,unsigned __int64),{libtorrent::peer_connection::on_receive_data,0},{libtorrent::peer_connection::on_error,0},{libtorrent::peer_connection::on_exception,0},libtorrent::aux::handler_storage<576,1>,1040>,void,boost::system::error_code const &,unsigned __int64>::_Do_call(const boost::system::error_code & <_Args_0>, unsigned __int64 && <_Args_1>) Line 904	C++	Non-user code. Symbols loaded.
 	PicoTorrent.exe!std::_Func_class<void,boost::system::error_code const &,unsigned __int64>::operator()(const boost::system::error_code & <_Args_0>, unsigned __int64 <_Args_1>) Line 952	C++	Non-user code. Symbols loaded.
 	PicoTorrent.exe!std::invoke<std::function<void __cdecl(boost::system::error_code const &,unsigned __int64)> &,boost::system::error_code &,unsigned __int64 &>(std::function<void __cdecl(boost::system::error_code const &,unsigned __int64)> & _Obj, boost::system::error_code & _Arg1, unsigned __int64 & <_Args2_0>) Line 1626	C++	Non-user code. Symbols loaded.
 	PicoTorrent.exe!std::_Invoker_ret<std::_Unforced,0>::_Call<std::function<void __cdecl(boost::system::error_code const &,unsigned __int64)> &,boost::system::error_code &,unsigned __int64 &>(std::function<void __cdecl(boost::system::error_code const &,unsigned __int64)> & <_Vals_0>, boost::system::error_code & <_Vals_1>, unsigned __int64 & <_Vals_2>) Line 1658	C++	Non-user code. Symbols loaded.
 	PicoTorrent.exe!std::_Call_binder<std::_Unforced,0,1,std::function<void __cdecl(boost::system::error_code const &,unsigned __int64)>,std::tuple<boost::system::error_code,unsigned __int64>,std::tuple<>>(std::_Invoker_ret<std::_Unforced,0> __formal, std::integer_sequence<unsigned __int64,0,1> __formal, std::function<void __cdecl(boost::system::error_code const &,unsigned __int64)> & _Obj, std::tuple<boost::system::error_code,unsigned __int64> & _Tpl, std::tuple<> && _Ut) Line 1388	C++	Non-user code. Symbols loaded.
 	PicoTorrent.exe!std::_Binder<std::_Unforced,std::function<void __cdecl(boost::system::error_code const &,unsigned __int64)>,boost::system::error_code &,unsigned __int64 &>::operator()<>() Line 1427	C++	Non-user code. Symbols loaded.
 	PicoTorrent.exe!boost::asio::asio_handler_invoke<std::_Binder<std::_Unforced,std::function<void __cdecl(boost::system::error_code const &,unsigned __int64)>,boost::system::error_code &,unsigned __int64 &>>(std::_Binder<std::_Unforced,std::function<void __cdecl(boost::system::error_code const &,unsigned __int64)>,boost::system::error_code &,unsigned __int64 &> & function, ...) Line 70	C++	Symbols loaded.
 	PicoTorrent.exe!boost_asio_handler_invoke_helpers::invoke<std::_Binder<std::_Unforced,std::function<void __cdecl(boost::system::error_code const &,unsigned __int64)>,boost::system::error_code &,unsigned __int64 &>,std::_Binder<std::_Unforced,std::function<void __cdecl(boost::system::error_code const &,unsigned __int64)>,boost::system::error_code &,unsigned __int64 &>>(std::_Binder<std::_Unforced,std::function<void __cdecl(boost::system::error_code const &,unsigned __int64)>,boost::system::error_code &,unsigned __int64 &> & function, std::_Binder<std::_Unforced,std::function<void __cdecl(boost::system::error_code const &,unsigned __int64)>,boost::system::error_code &,unsigned __int64 &> & context) Line 39	C++	Symbols loaded.
 	PicoTorrent.exe!boost::asio::system_executor::dispatch<std::_Binder<std::_Unforced,std::function<void __cdecl(boost::system::error_code const &,unsigned __int64)>,boost::system::error_code &,unsigned __int64 &>,std::allocator<void>>(std::_Binder<std::_Unforced,std::function<void __cdecl(boost::system::error_code const &,unsigned __int64)>,boost::system::error_code &,unsigned __int64 &> && f, const std::allocator<void> & __formal) Line 39	C++	Symbols loaded.
 	PicoTorrent.exe!boost::asio::detail::work_dispatcher<std::_Binder<std::_Unforced,std::function<void __cdecl(boost::system::error_code const &,unsigned __int64)>,boost::system::error_code &,unsigned __int64 &>>::operator()() Line 61	C++	Symbols loaded.
 	PicoTorrent.exe!boost::asio::asio_handler_invoke<boost::asio::detail::work_dispatcher<std::_Binder<std::_Unforced,std::function<void __cdecl(boost::system::error_code const &,unsigned __int64)>,boost::system::error_code &,unsigned __int64 &>>>(boost::asio::detail::work_dispatcher<std::_Binder<std::_Unforced,std::function<void __cdecl(boost::system::error_code const &,unsigned __int64)>,boost::system::error_code &,unsigned __int64 &>> & function, ...) Line 70	C++	Symbols loaded.
 	PicoTorrent.exe!boost_asio_handler_invoke_helpers::invoke<boost::asio::detail::work_dispatcher<std::_Binder<std::_Unforced,std::function<void __cdecl(boost::system::error_code const &,unsigned __int64)>,boost::system::error_code &,unsigned __int64 &>>,boost::asio::detail::work_dispatcher<std::_Binder<std::_Unforced,std::function<void __cdecl(boost::system::error_code const &,unsigned __int64)>,boost::system::error_code &,unsigned __int64 &>>>(boost::asio::detail::work_dispatcher<std::_Binder<std::_Unforced,std::function<void __cdecl(boost::system::error_code const &,unsigned __int64)>,boost::system::error_code &,unsigned __int64 &>> & function, boost::asio::detail::work_dispatcher<std::_Binder<std::_Unforced,std::function<void __cdecl(boost::system::error_code const &,unsigned __int64)>,boost::system::error_code &,unsigned __int64 &>> & context) Line 39	C++	Symbols loaded.
 	PicoTorrent.exe!boost::asio::detail::executor_op<boost::asio::detail::work_dispatcher<std::_Binder<std::_Unforced,std::function<void __cdecl(boost::system::error_code const &,unsigned __int64)>,boost::system::error_code &,unsigned __int64 &>>,std::allocator<void>,boost::asio::detail::win_iocp_operation>::do_complete(void * owner, boost::asio::detail::win_iocp_operation * base, const boost::system::error_code & __formal, unsigned __int64 __formal) Line 70	C++	Symbols loaded.
 	PicoTorrent.exe!boost::asio::detail::win_iocp_operation::complete(void * owner, const boost::system::error_code & ec, unsigned __int64 bytes_transferred) Line 48	C++	Symbols loaded.
 	PicoTorrent.exe!boost::asio::detail::win_iocp_io_context::do_one(unsigned long msec, boost::system::error_code & ec) Line 461	C++	Symbols loaded.
 	PicoTorrent.exe!boost::asio::detail::win_iocp_io_context::run(boost::system::error_code & ec) Line 203	C++	Symbols loaded.
 	PicoTorrent.exe!boost::asio::io_context::run() Line 63	C++	Symbols loaded.
 	PicoTorrent.exe!libtorrent::session::start::__l21::<lambda>() Line 294	C++	Symbols loaded.
 	PicoTorrent.exe!std::invoke<void <lambda>(void)>(libtorrent::session::start::__l21::void <lambda>(void) && _Obj) Line 1597	C++	Non-user code. Symbols loaded.
 	PicoTorrent.exe!std::thread::_Invoke<std::tuple<void <lambda>(void)>,0>(void * _RawVals) Line 44	C++	Non-user code. Symbols loaded.
 	ucrtbased.dll!thread_start<unsigned int (__cdecl*)(void *),1>(void * const parameter) Line 97	C++	Non-user code. Symbols loaded.
 	kernel32.dll!BaseThreadInitThunk�()	Unknown	Non-user code. Symbols loaded.
 	ntdll.dll!00007ff97305cec1()	Unknown	Non-user code. Cannot find or open the PDB file.

I can provide you with the dump file for this one if you want - it's 100mb compressed so was too big to attach.

@paullouisageneau
Copy link
Contributor

It's not obvious to me how the first assertion in piece_picker::mark_as_downloading could be related.

The second one in aux::bt_peer_connection::on_receive_impl could be but I'm puzzled because WebTorrent is not supposed to use Protocol Encryption, so why would it end up there in the first place?

@vktr
Copy link
Contributor Author

vktr commented Oct 4, 2020

I'm using the sintel.torrent file from webtorrent.io - it contains both wss and regular trackers. As mentioned in the original post, the asserts does not happen with WebTorrent support disabled. It might not be WebTorrent connection related, but it seems like it's WebTorrent feature related. Let me know if you want me to try anything!

@paullouisageneau
Copy link
Contributor

@vktr Thanks for the precision!

@arvidn I couldn't find where the key size checked by this assert is enforced. Do you know if it just checks for what could be read from the other peer?

TORRENT_ASSERT(m_recv_buffer.packet_size() == dh_key_len);

@arvidn
Copy link
Owner

arvidn commented Oct 4, 2020

The receive buffer class keeps track of the current packet size. That assert is related to the protocol "encryption" where it performs a diffie Hellman key exchange during the handshake. At that point it expects the packet size to be the size of the DH key. There should have been a call earlier to set the packet size to receive.

(I haven't had time to look closely at this yet)

@paullouisageneau
Copy link
Contributor

OK thank you, I see how it works now.
The packet size is actually set here:

m_recv_buffer.reset(dh_key_len);

m_recv_buffer.reset(dh_key_len);

@stale
Copy link

stale bot commented Jan 4, 2021

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Jan 4, 2021
@paullouisageneau
Copy link
Contributor

paullouisageneau commented Jan 17, 2021

I found a new assertion failed while debugging, I'm investigating:

#0  0x00007ffff67f9f75 in raise () from /usr/lib/libpthread.so.0
#1  0x00007ffff70befb6 in libtorrent::assert_fail (expr=0x7ffff7aa0bd2 "p->connection == &c", line=1176, 
    file=0x7ffff7aa0508 "/home/paulo/src/libtorrent/src/peer_list.cpp", function=0x7ffff7aa0bc0 "connection_closed", value=0x0, 
    kind=0) at /home/paulo/src/libtorrent/src/assert.cpp:360
#2  0x00007ffff73a5f94 in libtorrent::aux::peer_list::connection_closed (this=0x7ffff005d000, c=..., session_time=72, 
    state=0x7ffff5ed5a80) at /home/paulo/src/libtorrent/src/peer_list.cpp:1176
#3  0x00007ffff752fee4 in libtorrent::aux::torrent::remove_peer (this=0x7ffff0005bb0, 
    p=std::shared_ptr<libtorrent::aux::peer_connection> (use count 7, weak count 1) = {...})
    at /home/paulo/src/libtorrent/src/torrent.cpp:6010
#4  0x00007ffff727189e in libtorrent::aux::peer_connection::disconnect (this=0x7ffff00dafc0, ec=..., 
    op=libtorrent::operation_t::bittorrent, error=...) at /home/paulo/src/libtorrent/src/peer_connection.cpp:4442
#5  0x00007ffff7334ae0 in libtorrent::aux::bt_peer_connection::on_receive_impl (this=0x7ffff00dafc0, bytes_transferred=20)
    at /home/paulo/src/libtorrent/src/bt_peer_connection.cpp:3502
#6  0x00007ffff733096c in libtorrent::aux::bt_peer_connection::on_receive (this=0x7ffff00dafc0, error=..., bytes_transferred=20)
    at /home/paulo/src/libtorrent/src/bt_peer_connection.cpp:2707
#7  0x00007ffff7279b61 in libtorrent::aux::peer_connection::on_receive_data (this=0x7ffff00dafc0, error=..., bytes_transferred=68)
    at /home/paulo/src/libtorrent/src/peer_connection.cpp:6125

@arvidn
Copy link
Owner

arvidn commented Jan 17, 2021

this assert ensures that the torrent_peer object (which represents a peer in the peer_list, not necessarily connected) is consistent with the actual connected peer peer_connection. Both have references to each other.

@stale
Copy link

stale bot commented Apr 17, 2021

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Apr 17, 2021
@stale stale bot closed this as completed May 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants