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

Torrent Assert When Using Automatic Piece Size #6979

Closed
cyrillicw opened this issue Jul 25, 2022 · 6 comments
Closed

Torrent Assert When Using Automatic Piece Size #6979

cyrillicw opened this issue Jul 25, 2022 · 6 comments
Labels

Comments

@cyrillicw
Copy link
Contributor

cyrillicw commented Jul 25, 2022

I try to do the following experiment: create torrents of different size on one machine and download them by several others. If I use constant piece size = 16KB, then everything works fine. But if I use automatic piece size (so some torrents have piece size 16 KB and other have piece size 32 KB) then sometimes I catch the following torrent assert:

TORRENT_ASSERT(!m_picker->has_piece_passed(index));

https://github.com/arvidn/libtorrent/tree/RC_2_0/src#L4275

Here is the stack:

raise 0x00007f87128612ab
libtorrent::assert_fail assert.cpp:386
libtorrent::torrent::piece_passed torrent.cpp:4263
libtorrent::torrent::add_hashes torrent.cpp:6781
libtorrent::bt_peer_connection::on_hashes bt_peer_connection.cpp:1494
libtorrent::bt_peer_connection::dispatch_message bt_peer_connection.cpp:2394
libtorrent::bt_peer_connection::dispatch_message bt_peer_connection.cpp:2339
libtorrent::bt_peer_connection::on_receive_impl bt_peer_connection.cpp:4138
libtorrent::bt_peer_connection::on_receive bt_peer_connection.cpp:3087
libtorrent::peer_connection::on_receive_data peer_connection.cpp:6264
libtorrent::aux::handler<libtorrent::peer_connection, void (libtorrent::peer_connection::*)(boost::system::error_code const&, unsigned long), &libtorrent::peer_connection::on_receive_data, &libtorrent::peer_connection::on_error, &libtorrent::peer_connection::on_exception, libtorrent::aux::handler_storage<320ul, (libtorrent::aux::HandlerName)1>, &libtorrent::peer_connection::m_read_handler_storage>::operator()<boost::system::error_code const&, unsigned long> allocating_handler.hpp:334
std::_Function_handler<void (boost::system::error_code const&, unsigned long), libtorrent::aux::handler<libtorrent::peer_connection, void (libtorrent::peer_connection::*)(boost::system::error_code const&, unsigned long), &libtorrent::peer_connection::on_receive_data, &libtorrent::peer_connection::on_error, &libtorrent::peer_connection::on_exception, libtorrent::aux::handler_storage<320ul, (libtorrent::aux::HandlerName)1>, &libtorrent::peer_connection::m_read_handler_storage> >::_M_invoke(std::_Any_data const&, boost::system::error_code const&, unsigned long&&) std_function.h:300
std::function<void (boost::system::error_code const&, unsigned long)>::operator()(boost::system::error_code const&, unsigned long) const std_function.h:688
std::__invoke_impl<void, std::function<void (boost::system::error_code const&, unsigned long)>&, boost::system::error_code&, unsigned long&>(std::__invoke_other, std::function<void (boost::system::error_code const&, unsigned long)>&, boost::system::error_code&, unsigned long&) invoke.h:60
std::__invoke<std::function<void (boost::system::error_code const&, unsigned long)>&, boost::system::error_code&, unsigned long&>(std::function<void (boost::system::error_code const&, unsigned long)>&, boost::system::error_code&, unsigned long&) invoke.h:95
std::_Bind_result<void, std::function<void (boost::system::error_code const&, unsigned long)> (boost::system::error_code, unsigned long)>::__call<void, , 0ul, 1ul>(std::tuple<>&&, std::_Index_tuple<0ul, 1ul>) functional:565
std::_Bind_result<void, std::function<void (boost::system::error_code const&, unsigned long)> (boost::system::error_code, unsigned long)>::operator()<>() functional:651
boost::asio::asio_handler_invoke<std::_Bind_result<void, std::function<void (boost::system::error_code const&, unsigned long)> (boost::system::error_code, unsigned long)> >(std::_Bind_result<void, std::function<void (boost::system::error_code const&, unsigned long)> (boost::system::error_code, unsigned long)>&, ...) handler_invoke_hook.hpp:69
boost_asio_handler_invoke_helpers::invoke<std::_Bind_result<void, std::function<void (boost::system::error_code const&, unsigned long)> (boost::system::error_code, unsigned long)>, std::_Bind_result<void, std::function<void (boost::system::error_code const&, unsigned long)> (boost::system::error_code, unsigned long)> >(std::_Bind_result<void, std::function<void (boost::system::error_code const&, unsigned long)> (boost::system::error_code, unsigned long)>&, std::_Bind_result<void, std::function<void (boost::system::error_code const&, unsigned long)> (boost::system::error_code, unsigned long)>&) handler_invoke_helpers.hpp:37
boost::asio::system_executor::dispatch<std::_Bind_result<void, std::function<void (boost::system::error_code const&, unsigned long)> (boost::system::error_code, unsigned long)>, std::allocator<void> >(std::_Bind_result<void, std::function<void (boost::system::error_code const&, unsigned long)> (boost::system::error_code, unsigned long)>&&, std::allocator<void> const&) const system_executor.hpp:39
boost::asio::detail::work_dispatcher<std::_Bind_result<void, std::function<void (boost::system::error_code const&, unsigned long)> (boost::system::error_code, unsigned long)> >::operator()() work_dispatcher.hpp:59
boost::asio::asio_handler_invoke<boost::asio::detail::work_dispatcher<std::_Bind_result<void, std::function<void (boost::system::error_code const&, unsigned long)> (boost::system::error_code, unsigned long)> > >(boost::asio::detail::work_dispatcher<std::_Bind_result<void, std::function<void (boost::system::error_code const&, unsigned long)> (boost::system::error_code, unsigned long)> >&, ...) handler_invoke_hook.hpp:69
boost_asio_handler_invoke_helpers::invoke<boost::asio::detail::work_dispatcher<std::_Bind_result<void, std::function<void (boost::system::error_code const&, unsigned long)> (boost::system::error_code, unsigned long)> >, boost::asio::detail::work_dispatcher<std::_Bind_result<void, std::function<void (boost::system::error_code const&, unsigned long)> (boost::system::error_code, unsigned long)> > >(boost::asio::detail::work_dispatcher<std::_Bind_result<void, std::function<void (boost::system::error_code const&, unsigned long)> (boost::system::error_code, unsigned long)> >&, boost::asio::detail::work_dispatcher<std::_Bind_result<void, std::function<void (boost::system::error_code const&, unsigned long)> (boost::system::error_code, unsigned long)> >&) handler_invoke_helpers.hpp:37
boost::asio::detail::executor_op<boost::asio::detail::work_dispatcher<std::_Bind_result<void, std::function<void (boost::system::error_code const&, unsigned long)> (boost::system::error_code, unsigned long)> >, std::allocator<void>, boost::asio::detail::scheduler_operation>::do_complete(void*, boost::asio::detail::scheduler_operation*, boost::system::error_code const&, unsigned long) executor_op.hpp:70
boost::asio::detail::scheduler_operation::complete scheduler_operation.hpp:40
boost::asio::detail::scheduler::do_run_one scheduler.ipp:447
boost::asio::detail::scheduler::run scheduler.ipp:200
boost::asio::io_context::run io_context.ipp:63
sirius::drive::DefaultReplicator::start()::{lambda()#2}::operator()() const Replicator.cpp:203
std::__invoke_impl<void, sirius::drive::DefaultReplicator::start()::{lambda()#2}>(std::__invoke_other, sirius::drive::DefaultReplicator::start()::{lambda()#2}&&) invoke.h:60
std::__invoke<sirius::drive::DefaultReplicator::start()::{lambda()#2}>(sirius::drive::DefaultReplicator::start()::{lambda()#2}&&) invoke.h:95
std::thread::_Invoker<std::tuple<sirius::drive::DefaultReplicator::start()::{lambda()#2}> >::_M_invoke<0ul>(std::_Index_tuple<0ul>) thread:244
std::thread::_Invoker<std::tuple<sirius::drive::DefaultReplicator::start()::{lambda()#2}> >::operator()() thread:251
std::thread::_State_impl<std::thread::_Invoker<std::tuple<sirius::drive::DefaultReplicator::start()::{lambda()#2}> > >::_M_run() thread:195
<unknown> 0x00007f871273fde4
start_thread 0x00007f8712855609
clone 0x00007f871257b133
@arvidn
Copy link
Owner

arvidn commented Aug 21, 2022

does this happen consistently with certain torrents you generate?
Is there any chance you could help me reproduce this or have a stress test as part of libtorrent CI?

@cyrillicw
Copy link
Contributor Author

Will generate a reproducible example in a few days

@cyrillicw
Copy link
Contributor Author

Here is an example https://github.com/cyrillicw/LibtorrentExample

@cyrillicw
Copy link
Contributor Author

In this example five downloaders try to download 1GB file from the single uploader and other downloaders. In order to run it you have to bind ip addresses - you can do it with create_ip.sh script

@cyrillicw
Copy link
Contributor Author

The assert does not arise always but quite often

@stale
Copy link

stale bot commented Jan 7, 2023

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 7, 2023
@stale stale bot closed this as completed Feb 18, 2023
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

2 participants